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);
34 class RRTExt11 : public virtual RRTS {
36 bool goal_found(RRTNode &f);
39 /*! \brief Different costs extension.
41 Use different cost for bulding tree data structure and searching in the
42 structure. The cost function is from Elbanhawi, Mohamed, Milan Simic, and Reza
43 Jazar. “Randomized Bidirectional B-Spline Parameterization Motion Planning.”
44 IEEE Transactions on Intelligent Transportation Systems 17, no. 2 (February
45 2016): 406–19. https://doi.org/10.1109/TITS.2015.2477355.
48 class RRTExt10 : public virtual RRTS {
50 /*! \brief Reeds and Shepp path length.
52 double cost_build(RRTNode &f, RRTNode &t);
53 /*! \brief Heuristics distance.
55 double cost_search(RRTNode &f, RRTNode &t);
58 /*! \brief Use grid data structure to store RRT nodes.
60 This approach speeds up the search process for the nearest neighbor and
61 the near vertices procedures.
63 class RRTExt9 : public virtual RRTS {
67 bool changed_ = false;
68 std::vector<RRTNode *> nodes_;
70 void nn(RRTNode *t, RRTNode **nn, RRTS *p);
71 void store_node(RRTNode *n);
76 return this->changed_;
78 std::vector<RRTNode *> &nodes()
85 Cell grid_[GRID_MAX_XI][GRID_MAX_YI][GRID_MAX_HI];
91 double h_max_ = 2 * M_PI;
93 unsigned int xi(RRTNode n);
94 unsigned int yi(RRTNode n);
95 unsigned int hi(RRTNode n);
99 void store_node(RRTNode n);
100 RRTNode *nn(RRTNode &t);
101 std::vector<RRTNode *> nv(RRTNode &t);
104 /*! \brief Use k-d tree data structure to store RRT nodes.
106 This approach speeds up the search process for the nearest neighbor and
107 the near vertices procedures. This extension implements 3D K-d tree.
109 \see https://en.wikipedia.org/wiki/K-d_tree
111 class RRTExt8 : public virtual RRTS {
115 RRTNode *node_ = nullptr;
116 KdNode *left_ = nullptr;
117 KdNode *right_ = nullptr;
120 RRTNode *node() const { return this->node_; }
121 KdNode *&left() { return this->left_; }
122 KdNode *&right() { return this->right_; }
125 KdNode *kdroot_ = nullptr;
126 void delete_kd_nodes(KdNode *n);
127 void store_node(RRTNode *n, KdNode *&r, int l);
128 void nn(RRTNode *&n, RRTNode &t, KdNode *r, int l, double &d);
132 void store_node(RRTNode n);
133 RRTNode *nn(RRTNode &t);
134 std::vector<RRTNode *> nv(RRTNode &t);
137 /*! \brief Use k-d tree data structure to store RRT nodes.
139 This approach speeds up the search process for the nearest neighbor and
140 the near vertices procedures. This extension implements 2D K-d tree.
142 \see https://en.wikipedia.org/wiki/K-d_tree
144 class RRTExt7 : public virtual RRTS {
148 RRTNode *node_ = nullptr;
149 KdNode *left_ = nullptr;
150 KdNode *right_ = nullptr;
153 RRTNode *node() const { return this->node_; }
154 KdNode *&left() { return this->left_; }
155 KdNode *&right() { return this->right_; }
158 KdNode *kdroot_ = nullptr;
159 void delete_kd_nodes(KdNode *n);
160 void store_node(RRTNode *n, KdNode *&r, int l);
161 void nn(RRTNode *&n, RRTNode &t, KdNode *r, int l, double &d);
165 void store_node(RRTNode n);
166 RRTNode *nn(RRTNode &t);
167 std::vector<RRTNode *> nv(RRTNode &t);
170 /*! \brief Reeds and Shepp cost for building and search.
172 class RRTExt6 : public virtual RRTS {
174 /*! \brief Reeds and Shepp path length.
176 double cost_build(RRTNode &f, RRTNode &t);
177 /*! \brief Reeds and Shepp path length.
179 double cost_search(RRTNode &f, RRTNode &t);
182 /*! \brief Different costs extension.
184 Use different cost for bulding tree data structure and searching in the
185 structure. This one is complementary to `rrtext1.cc`.
187 class RRTExt5 : public virtual RRTS {
189 /*! \brief Reeds and Shepp path length.
191 double cost_build(RRTNode &f, RRTNode &t);
192 /*! \brief Euclidean distance.
194 double cost_search(RRTNode &f, RRTNode &t);
197 /*! \brief Use grid data structure to store RRT nodes.
199 This approach speeds up the search process for the nearest neighbor and
200 the near vertices procedures.
202 class RRTExt4 : public virtual RRTS {
206 bool changed_ = false;
207 std::vector<RRTNode *> nodes_;
209 void nn(RRTNode *t, RRTNode **nn, RRTS *p);
210 void store_node(RRTNode *n);
215 return this->changed_;
217 std::vector<RRTNode *> &nodes()
224 Cell grid_[GRID_MAX_XI][GRID_MAX_YI]; // [0, 0] is bottom left
230 unsigned int xi(RRTNode n);
231 unsigned int yi(RRTNode n);
235 void store_node(RRTNode n);
236 RRTNode *nn(RRTNode &t);
237 std::vector<RRTNode *> nv(RRTNode &t);
240 /*! \brief Use Dijkstra algorithm to find the shorter path.
242 class RRTExt3 : public virtual RRTS {
244 std::vector<RRTNode *> orig_path_;
245 double orig_path_cost_ = 9999;
246 std::vector<RRTNode *> first_optimized_path_;
247 double first_optimized_path_cost_ = 9999;
249 std::vector<RRTNode *> first_path_optimization();
250 std::vector<RRTNode *> second_path_optimization();
251 std::vector<RRTNode *> path();
253 void json(Json::Value jvi);
256 std::vector<RRTNode *> &orig_path()
258 return this->orig_path_;
260 double &orig_path_cost() { return this->orig_path_cost_; }
261 void orig_path_cost(double c) { this->orig_path_cost_ = c; }
262 std::vector<RRTNode *> &first_optimized_path()
264 return this->first_optimized_path_;
266 double &first_optimized_path_cost() {
267 return this->first_optimized_path_cost_;
269 void first_optimized_path_cost(double c) {
270 this->first_optimized_path_cost_ = c;
274 /*! \brief Use cute_c2 for collision detection.
276 \see https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h
278 class RRTExt2 : public virtual RRTS {
282 std::vector<c2Poly> c2_obstacles_;
287 // Collide RRT procedures
288 std::tuple<bool, unsigned int, unsigned int>
289 collide_steered_from(RRTNode &f);
290 std::tuple<bool, unsigned int, unsigned int>
291 collide_tmp_steered_from(RRTNode &f);
293 std::tuple<bool, unsigned int, unsigned int>
294 collide_two_nodes(RRTNode &f, RRTNode &t);
297 c2Poly &c2_bc() { return this->c2_bc_; }
298 c2x &c2x_bc() { return this->c2x_bc_; }
299 std::vector<c2Poly> &c2_obstacles() {
300 return this->c2_obstacles_;
304 /*! \brief Different costs extension.
306 Use different cost for bulding tree data structure and searching in the
309 class RRTExt1 : public virtual RRTS {
311 /*! \brief Reeds and Shepp path length.
313 double cost_build(RRTNode &f, RRTNode &t);
314 /*! \brief Matej's heuristics.
316 double cost_search(RRTNode &f, RRTNode &t);
319 #endif /* RRTEXT_H */