]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blob - base/main.cc
9e63dfe6e3275dc6d4279c279fce8242f1965645
[hubacji1/iamcar.git] / base / main.cc
1 /*
2 This file is part of I am car.
3
4 I am car is nree software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 I am car is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with I am car. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <iostream>
19 #include <jsoncpp/json/json.h>
20 #include "obstacle.h"
21 #include "rrtplanner.h"
22
23 int main()
24 {
25         Json::Value jvi; // JSON input
26         std::cin >> jvi;
27         std::string encoding = jvi.get("encoding", "UTF-8" ).asString();
28
29         LaValle1998 p(new RRTNode(0, 0, 0), new RRTNode(9, 9, 0));
30         std::vector<CircleObstacle> co;
31         std::vector<SegmentObstacle> so;
32         p.link_obstacles(&co, &so);
33
34         p.tstart();
35         while (!p.goal_found())
36                 p.next();
37         p.tend();
38
39         std::cerr << "Elapsed is " << p.elapsed() << std::endl;
40         std::cerr << "Goal found is " << p.goal_found() << std::endl;
41         std::cerr << "`tlog` size is " << p.tlog().size() << std::endl;
42
43         Json::Value jvo; // JSON output
44         int i = 0;
45         int j = 0;
46         for (auto traj: p.tlog()) {
47                 i = 0;
48                 for (auto n: traj) {
49                         jvo["traj"][j][i][0] = n->x();
50                         jvo["traj"][j][i][1] = n->y();
51                         jvo["traj"][j][i][2] = n->h();
52                         i++;
53                 }
54                 j++;
55         }
56         std::cout << jvo << std::endl;
57         return 0;
58 }