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 /*! Use Dijkstra-based path optimization, goal zone for interesting nodes. */
20 class RRTExt13 : public virtual RRTS {
24 std::vector<RRTNode *> orig_path_;
25 double orig_path_cost_ = 9999;
26 std::vector<RRTNode *> first_optimized_path_;
27 double first_optimized_path_cost_ = 9999;
28 void first_path_optimization();
29 void second_path_optimization();
32 void json(Json::Value jvi);
35 std::vector<RRTNode *> &orig_path()
37 return this->orig_path_;
39 double &orig_path_cost() { return this->orig_path_cost_; }
40 void orig_path_cost(double c) { this->orig_path_cost_ = c; }
41 std::vector<RRTNode *> &first_optimized_path()
43 return this->first_optimized_path_;
45 double &first_optimized_path_cost() {
46 return this->first_optimized_path_cost_;
48 void first_optimized_path_cost(double c) {
49 this->first_optimized_path_cost_ = c;
53 /*! \brief Different `steer` procedures.
55 Use sampling in control input for `steer1`. Use R&S steering for `steer2`.
57 class RRTExt12 : public virtual RRTS {
59 void steer1(RRTNode &f, RRTNode &t);
68 class RRTExt11 : public virtual RRTS {
70 bool goal_found(RRTNode &f);
73 /*! \brief Different costs extension.
75 Use different cost for bulding tree data structure and searching in the
76 structure. The cost function is from Elbanhawi, Mohamed, Milan Simic, and Reza
77 Jazar. “Randomized Bidirectional B-Spline Parameterization Motion Planning.”
78 IEEE Transactions on Intelligent Transportation Systems 17, no. 2 (February
79 2016): 406–19. https://doi.org/10.1109/TITS.2015.2477355.
82 class RRTExt10 : public virtual RRTS {
84 /*! \brief Reeds and Shepp path length.
86 double cost_build(RRTNode &f, RRTNode &t);
87 /*! \brief Heuristics distance.
89 double cost_search(RRTNode &f, RRTNode &t);
92 /*! \brief Use grid data structure to store RRT nodes.
94 This approach speeds up the search process for the nearest neighbor and
95 the near vertices procedures.
97 class RRTExt9 : public virtual RRTS {
101 bool changed_ = false;
102 std::vector<RRTNode *> nodes_;
104 void nn(RRTNode *t, RRTNode **nn, RRTS *p);
105 void store_node(RRTNode *n);
110 return this->changed_;
112 std::vector<RRTNode *> &nodes()
119 Cell grid_[GRID_MAX_XI][GRID_MAX_YI][GRID_MAX_HI];
125 double h_max_ = 2 * M_PI;
127 unsigned int xi(RRTNode n);
128 unsigned int yi(RRTNode n);
129 unsigned int hi(RRTNode n);
133 void store_node(RRTNode n);
134 RRTNode *nn(RRTNode &t);
135 std::vector<RRTNode *> nv(RRTNode &t);
138 /*! \brief Use k-d tree data structure to store RRT nodes.
140 This approach speeds up the search process for the nearest neighbor and
141 the near vertices procedures. This extension implements 3D K-d tree.
143 \see https://en.wikipedia.org/wiki/K-d_tree
145 class RRTExt8 : public virtual RRTS {
149 RRTNode *node_ = nullptr;
150 KdNode *left_ = nullptr;
151 KdNode *right_ = nullptr;
154 RRTNode *node() const { return this->node_; }
155 KdNode *&left() { return this->left_; }
156 KdNode *&right() { return this->right_; }
159 KdNode *kdroot_ = nullptr;
160 void delete_kd_nodes(KdNode *n);
161 void store_node(RRTNode *n, KdNode *&r, int l);
162 void nn(RRTNode *&n, RRTNode &t, KdNode *r, int l, double &d);
164 std::vector<RRTNode*>& n,
171 void delete_kd_nodes()
173 this->delete_kd_nodes(this->kdroot_);
174 this->kdroot_ = nullptr;
179 void store_node(RRTNode n);
180 RRTNode *nn(RRTNode &t);
181 std::vector<RRTNode *> nv(RRTNode &t);
184 /*! \brief Use k-d tree data structure to store RRT nodes.
186 This approach speeds up the search process for the nearest neighbor and
187 the near vertices procedures. This extension implements 2D K-d tree.
189 \see https://en.wikipedia.org/wiki/K-d_tree
191 class RRTExt7 : public virtual RRTS {
195 RRTNode *node_ = nullptr;
196 KdNode *left_ = nullptr;
197 KdNode *right_ = nullptr;
200 RRTNode *node() const { return this->node_; }
201 KdNode *&left() { return this->left_; }
202 KdNode *&right() { return this->right_; }
205 KdNode *kdroot_ = nullptr;
206 void delete_kd_nodes(KdNode *n);
207 void store_node(RRTNode *n, KdNode *&r, int l);
208 void nn(RRTNode *&n, RRTNode &t, KdNode *r, int l, double &d);
212 void store_node(RRTNode n);
213 RRTNode *nn(RRTNode &t);
214 std::vector<RRTNode *> nv(RRTNode &t);
217 /*! \brief Reeds and Shepp cost for building and search.
219 class RRTExt6 : public virtual RRTS {
221 /*! \brief Reeds and Shepp path length.
223 double cost_build(RRTNode &f, RRTNode &t);
224 /*! \brief Reeds and Shepp path length.
226 double cost_search(RRTNode &f, RRTNode &t);
229 /*! \brief Different costs extension.
231 Use different cost for bulding tree data structure and searching in the
232 structure. This one is complementary to `rrtext1.cc`.
234 class RRTExt5 : public virtual RRTS {
236 /*! \brief Reeds and Shepp path length.
238 double cost_build(RRTNode &f, RRTNode &t);
239 /*! \brief Euclidean distance.
241 double cost_search(RRTNode &f, RRTNode &t);
244 /*! \brief Use grid data structure to store RRT nodes.
246 This approach speeds up the search process for the nearest neighbor and
247 the near vertices procedures.
249 class RRTExt4 : public virtual RRTS {
253 bool changed_ = false;
254 std::vector<RRTNode *> nodes_;
256 void nn(RRTNode *t, RRTNode **nn, RRTS *p);
257 void store_node(RRTNode *n);
262 return this->changed_;
264 std::vector<RRTNode *> &nodes()
271 Cell grid_[GRID_MAX_XI][GRID_MAX_YI]; // [0, 0] is bottom left
277 unsigned int xi(RRTNode n);
278 unsigned int yi(RRTNode n);
282 void store_node(RRTNode n);
283 RRTNode *nn(RRTNode &t);
284 std::vector<RRTNode *> nv(RRTNode &t);
287 /*! \brief Use Dijkstra algorithm to find the shorter path.
289 class RRTExt3 : public virtual RRTS {
293 std::vector<RRTNode *> orig_path_;
294 double orig_path_cost_ = 9999;
295 std::vector<RRTNode *> first_optimized_path_;
296 double first_optimized_path_cost_ = 9999;
297 void first_path_optimization();
298 void second_path_optimization();
301 void json(Json::Value jvi);
304 std::vector<RRTNode *> &orig_path()
306 return this->orig_path_;
308 double &orig_path_cost() { return this->orig_path_cost_; }
309 void orig_path_cost(double c) { this->orig_path_cost_ = c; }
310 std::vector<RRTNode *> &first_optimized_path()
312 return this->first_optimized_path_;
314 double &first_optimized_path_cost() {
315 return this->first_optimized_path_cost_;
317 void first_optimized_path_cost(double c) {
318 this->first_optimized_path_cost_ = c;
322 /*! \brief Use cute_c2 for collision detection.
324 \see https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h
326 class RRTExt2 : public virtual RRTS {
330 std::vector<c2Poly> c2_obstacles_;
331 bool collide(RRTNode const& n);
332 bool collide_steered();
335 Json::Value json() const;
336 void json(Json::Value jvi);
339 /*! \brief Different costs extension.
341 Use different cost for bulding tree data structure and searching in the
344 class RRTExt1 : public virtual RRTS {
346 /*! \brief Reeds and Shepp path length.
348 double cost_build(RRTNode &f, RRTNode &t);
349 /*! \brief Matej's heuristics.
351 double cost_search(RRTNode &f, RRTNode &t);
355 #endif /* RRTS_RRTEXT_H */