10 #define GRID 1 // in meters
11 #define GRID_WIDTH 40 // in meters
12 #define GRID_HEIGHT 40 // in meters
13 #define GRID_MAX_XI ((unsigned int) floor(GRID_WIDTH / GRID)) // min is 0
14 #define GRID_MAX_YI ((unsigned int) floor(GRID_HEIGHT / GRID)) // min is 0
17 #define GRID_MAX_HI 60
19 /*! \brief Different `steer` procedures.
21 Use sampling in control input for `steer1`. Use R&S steering for `steer2`.
23 class RRTExt12 : public virtual RRTS {
25 void steer1(RRTNode &f, RRTNode &t);
31 class RRTExt11 : public virtual RRTS {
33 bool goal_found(RRTNode &f);
36 /*! \brief Different costs extension.
38 Use different cost for bulding tree data structure and searching in the
39 structure. The cost function is from Elbanhawi, Mohamed, Milan Simic, and Reza
40 Jazar. “Randomized Bidirectional B-Spline Parameterization Motion Planning.”
41 IEEE Transactions on Intelligent Transportation Systems 17, no. 2 (February
42 2016): 406–19. https://doi.org/10.1109/TITS.2015.2477355.
45 class RRTExt10 : public virtual RRTS {
47 /*! \brief Reeds and Shepp path length.
49 double cost_build(RRTNode &f, RRTNode &t);
50 /*! \brief Heuristics distance.
52 double cost_search(RRTNode &f, RRTNode &t);
55 /*! \brief Use grid data structure to store RRT nodes.
57 This approach speeds up the search process for the nearest neighbor and
58 the near vertices procedures.
60 class RRTExt9 : public virtual RRTS {
64 bool changed_ = false;
65 std::vector<RRTNode *> nodes_;
67 void nn(RRTNode *t, RRTNode **nn, RRTS *p);
68 void store_node(RRTNode *n);
73 return this->changed_;
75 std::vector<RRTNode *> &nodes()
82 Cell grid_[GRID_MAX_XI][GRID_MAX_YI][GRID_MAX_HI];
88 double h_max_ = 2 * M_PI;
90 unsigned int xi(RRTNode n);
91 unsigned int yi(RRTNode n);
92 unsigned int hi(RRTNode n);
96 void store_node(RRTNode n);
97 RRTNode *nn(RRTNode &t);
98 std::vector<RRTNode *> nv(RRTNode &t);
101 /*! \brief Use k-d tree data structure to store RRT nodes.
103 This approach speeds up the search process for the nearest neighbor and
104 the near vertices procedures. This extension implements 3D K-d tree.
106 \see https://en.wikipedia.org/wiki/K-d_tree
108 class RRTExt8 : public virtual RRTS {
112 RRTNode *node_ = nullptr;
113 KdNode *left_ = nullptr;
114 KdNode *right_ = nullptr;
117 RRTNode *node() const { return this->node_; }
118 KdNode *&left() { return this->left_; }
119 KdNode *&right() { return this->right_; }
122 KdNode *kdroot_ = nullptr;
123 void delete_kd_nodes(KdNode *n);
124 void store_node(RRTNode *n, KdNode *&r, int l);
125 void nn(RRTNode *&n, RRTNode &t, KdNode *r, int l, double &d);
129 void store_node(RRTNode n);
130 RRTNode *nn(RRTNode &t);
131 std::vector<RRTNode *> nv(RRTNode &t);
134 /*! \brief Use k-d tree data structure to store RRT nodes.
136 This approach speeds up the search process for the nearest neighbor and
137 the near vertices procedures. This extension implements 2D K-d tree.
139 \see https://en.wikipedia.org/wiki/K-d_tree
141 class RRTExt7 : public virtual RRTS {
145 RRTNode *node_ = nullptr;
146 KdNode *left_ = nullptr;
147 KdNode *right_ = nullptr;
150 RRTNode *node() const { return this->node_; }
151 KdNode *&left() { return this->left_; }
152 KdNode *&right() { return this->right_; }
155 KdNode *kdroot_ = nullptr;
156 void delete_kd_nodes(KdNode *n);
157 void store_node(RRTNode *n, KdNode *&r, int l);
158 void nn(RRTNode *&n, RRTNode &t, KdNode *r, int l, double &d);
162 void store_node(RRTNode n);
163 RRTNode *nn(RRTNode &t);
164 std::vector<RRTNode *> nv(RRTNode &t);
167 /*! \brief Reeds and Shepp cost for building and search.
169 class RRTExt6 : public virtual RRTS {
171 /*! \brief Reeds and Shepp path length.
173 double cost_build(RRTNode &f, RRTNode &t);
174 /*! \brief Reeds and Shepp path length.
176 double cost_search(RRTNode &f, RRTNode &t);
179 /*! \brief Different costs extension.
181 Use different cost for bulding tree data structure and searching in the
182 structure. This one is complementary to `rrtext1.cc`.
184 class RRTExt5 : public virtual RRTS {
186 /*! \brief Reeds and Shepp path length.
188 double cost_build(RRTNode &f, RRTNode &t);
189 /*! \brief Euclidean distance.
191 double cost_search(RRTNode &f, RRTNode &t);
194 /*! \brief Use grid data structure to store RRT nodes.
196 This approach speeds up the search process for the nearest neighbor and
197 the near vertices procedures.
199 class RRTExt4 : public virtual RRTS {
203 bool changed_ = false;
204 std::vector<RRTNode *> nodes_;
206 void nn(RRTNode *t, RRTNode **nn, RRTS *p);
207 void store_node(RRTNode *n);
212 return this->changed_;
214 std::vector<RRTNode *> &nodes()
221 Cell grid_[GRID_MAX_XI][GRID_MAX_YI]; // [0, 0] is bottom left
227 unsigned int xi(RRTNode n);
228 unsigned int yi(RRTNode n);
232 void store_node(RRTNode n);
233 RRTNode *nn(RRTNode &t);
234 std::vector<RRTNode *> nv(RRTNode &t);
237 /*! \brief Use Dijkstra algorithm to find the shorter path.
239 class RRTExt3 : public virtual RRTS {
241 std::vector<RRTNode *> orig_path_;
242 double orig_path_cost_ = 9999;
243 std::vector<RRTNode *> first_optimized_path_;
244 double first_optimized_path_cost_ = 9999;
246 std::vector<RRTNode *> first_path_optimization();
247 std::vector<RRTNode *> second_path_optimization();
248 std::vector<RRTNode *> path();
250 void json(Json::Value jvi);
253 std::vector<RRTNode *> &orig_path()
255 return this->orig_path_;
257 double &orig_path_cost() { return this->orig_path_cost_; }
258 void orig_path_cost(double c) { this->orig_path_cost_ = c; }
259 std::vector<RRTNode *> &first_optimized_path()
261 return this->first_optimized_path_;
263 double &first_optimized_path_cost() {
264 return this->first_optimized_path_cost_;
266 void first_optimized_path_cost(double c) {
267 this->first_optimized_path_cost_ = c;
271 /*! \brief Use cute_c2 for collision detection.
273 \see https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h
275 class RRTExt2 : public virtual RRTS {
279 std::vector<c2Poly> c2_obstacles_;
284 // Collide RRT procedures
285 std::tuple<bool, unsigned int, unsigned int>
286 collide_steered_from(RRTNode &f);
287 std::tuple<bool, unsigned int, unsigned int>
288 collide_tmp_steered_from(RRTNode &f);
290 std::tuple<bool, unsigned int, unsigned int>
291 collide_two_nodes(RRTNode &f, RRTNode &t);
294 c2Poly &c2_bc() { return this->c2_bc_; }
295 c2x &c2x_bc() { return this->c2x_bc_; }
296 std::vector<c2Poly> &c2_obstacles() {
297 return this->c2_obstacles_;
301 /*! \brief Different costs extension.
303 Use different cost for bulding tree data structure and searching in the
306 class RRTExt1 : public virtual RRTS {
308 /*! \brief Reeds and Shepp path length.
310 double cost_build(RRTNode &f, RRTNode &t);
311 /*! \brief Matej's heuristics.
313 double cost_search(RRTNode &f, RRTNode &t);
316 #endif /* RRTEXT_H */