2 This file is part of I am car.
4 I am car is free 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.
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.
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/>.
30 #define IXSTEP (1.0 * ((VMAX) - (VMIN)) / IXSIZE)
31 #define IXI(x) ({ __typeof__ (x) _x = (x); \
32 (int) floor(_x / IXSTEP); })
34 #define IYSTEP (1.0 * ((HMAX) - (HMIN)) / IYSIZE)
35 #define IYI(y) ({ __typeof__ (y) _y = (y); \
36 (int) floor(_y / IYSTEP); })
40 std::vector<RRTNode *> nodes_;
42 bool changed_ = false;
48 std::vector<RRTNode *> nodes();
51 void add_node(RRTNode *n);
56 RRTNode *root_ = nullptr;
57 RRTNode *goal_ = nullptr;
59 std::vector<RRTNode *> nodes_;
60 std::vector<RRTNode *> dnodes_;
61 std::vector<RRTNode *> samples_;
62 std::vector<CircleObstacle> *cobstacles_;
63 std::vector<SegmentObstacle> *sobstacles_;
65 bool goal_found_ = false;
66 std::chrono::high_resolution_clock::time_point tstart_;
67 std::chrono::high_resolution_clock::time_point tend_;
69 std::vector<float> clog_; // costs of trajectories
70 std::vector<float> nlog_; // #nodes of RRT
71 std::vector<std::vector<RRTEdge *>> rlog_; // log tree
72 std::vector<float> slog_; // seconds of trajectories
73 std::vector<std::vector<RRTNode *>> tlog_; // trajectories
75 const float GOAL_FOUND_DISTANCE = 0.2;
76 const float GOAL_FOUND_ANGLE = M_PI / 32;
80 RRTBase(RRTNode *init, RRTNode *goal);
85 std::vector<RRTNode *> &nodes();
86 std::vector<RRTNode *> &dnodes();
87 std::vector<RRTNode *> &samples();
88 std::vector<RRTNode *> iy_[IYSIZE];
89 std::vector<CircleObstacle> *co();
90 std::vector<SegmentObstacle> *so();
91 std::vector<float> &clog();
92 std::vector<float> &nlog();
93 std::vector<std::vector<RRTEdge *>> &rlog();
94 std::vector<float> &slog();
95 std::vector<std::vector<RRTNode *>> &tlog();
100 void root(RRTNode *node);
101 void goal(RRTNode *node);
102 bool logr(RRTNode *root);
103 float ocost(RRTNode *n);
104 bool tlog(std::vector<RRTNode *> t);
108 std::vector<CircleObstacle> *cobstacles,
109 std::vector<SegmentObstacle> *sobstacles);
110 bool add_iy(RRTNode *n);
111 bool goal_found(bool f);
117 float (*cost)(RRTNode *, RRTNode *));
118 bool collide(RRTNode *init, RRTNode *goal);
120 std::vector<RRTNode *> &cusps,
121 std::vector<int> &npi);
123 std::vector<RRTNode *> &cusps,
124 std::vector<int> &npi);
126 std::vector<RRTNode *> &cusps,
127 std::vector<int> &npi);
129 bool rebase(RRTNode *nr);
130 std::vector<RRTNode *> findt();
131 std::vector<RRTNode *> findt(RRTNode *n);
135 float cost(RRTNode *init, RRTNode *goal);
136 RRTNode *nn(RRTNode *rs);
137 std::vector<RRTNode *> nv(RRTNode *node, float dist);
138 std::vector<RRTNode *> steer(RRTNode *init, RRTNode *goal);
139 std::vector<RRTNode *> steer(
144 // virtuals - implemented by child classes
145 virtual bool next() = 0;