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
21 class RRTExt15 : public virtual RRTS {
23 std::vector<double> log_path_cost_;
25 Json::Value json() const;
26 void json(Json::Value jvi);
30 /*! \brief Random sampling in the circuit between root and goal.
32 * \see https://stackoverflow.com/questions/5837572/generate-a-random-point-within-a-circle-uniformly/50746409#50746409
34 class RRTExt14 : public virtual RRTS {
37 double circle_r_ = 0.0;
38 std::uniform_real_distribution<double> udr_;
39 std::uniform_real_distribution<double> udt_;
40 std::uniform_real_distribution<double> udh_;
47 /*! Use Dijkstra-based path optimization, goal zone for interesting nodes. */
48 class RRTExt13 : public virtual RRTS {
52 RRTNode* node = nullptr;
56 DijkstraNode(RRTNode* n);
58 class DijkstraNodeComparator {
60 int operator() (DijkstraNode const& n1, DijkstraNode const& n2);
62 std::vector<RRTNode*> opath_;
63 double ogoal_cc_ = 0.0;
65 std::vector<DijkstraNode> dn_;
66 void pick_interesting();
67 void dijkstra_forward();
68 void dijkstra_backward();
72 Json::Value json() const;
73 void json(Json::Value jvi);
77 /*! \brief Different `steer` procedures.
79 Use sampling in control input for `steer1`. Use R&S steering for `steer2`.
81 class RRTExt12 : public virtual RRTS {
83 void steer1(RRTNode &f, RRTNode &t);
92 class RRTExt11 : public virtual RRTS {
94 bool goal_found(RRTNode &f);
97 /*! \brief Different costs extension.
99 * Use different cost for bulding tree data structure and searching in the
100 * structure. The cost function is from Elbanhawi, Mohamed, Milan Simic, and
101 * Reza Jazar. “Randomized Bidirectional B-Spline Parameterization Motion
102 * Planning.” IEEE Transactions on Intelligent Transportation Systems 17, no. 2
103 * (February 2016): 406–19. https://doi.org/10.1109/TITS.2015.2477355.
105 class RRTExt10 : public virtual RRTS {
107 double cost_build(RRTNode const& f, RRTNode const& t) const;
108 double cost_search(RRTNode const& f, RRTNode const& t) const;
111 /*! \brief Use grid data structure to store RRT nodes.
113 This approach speeds up the search process for the nearest neighbor and
114 the near vertices procedures.
116 class RRTExt9 : public virtual RRTS {
120 bool changed_ = false;
121 std::vector<RRTNode *> nodes_;
123 void nn(RRTNode *t, RRTNode **nn, RRTS *p);
124 void store_node(RRTNode *n);
129 return this->changed_;
131 std::vector<RRTNode *> &nodes()
138 Cell grid_[GRID_MAX_XI][GRID_MAX_YI][GRID_MAX_HI];
144 double h_max_ = 2 * M_PI;
146 unsigned int xi(RRTNode n);
147 unsigned int yi(RRTNode n);
148 unsigned int hi(RRTNode n);
152 void store_node(RRTNode n);
153 RRTNode *nn(RRTNode &t);
154 std::vector<RRTNode *> nv(RRTNode &t);
157 /*! \brief Use k-d tree data structure to store RRT nodes.
159 * This approach speeds up the search process for the nearest neighbor and the
160 * near vertices procedures. This extension implements 3D K-d tree.
162 * \see https://en.wikipedia.org/wiki/K-d_tree
164 class RRTExt8 : public virtual RRTS {
168 RRTNode* node = nullptr;
169 KdNode* left = nullptr;
170 KdNode* right = nullptr;
173 KdNode* kdroot_ = nullptr;
174 std::vector<KdNode> kdnodes_;
175 void store(RRTNode* n, KdNode*& ref, unsigned int lvl);
176 void find_nn(RRTNode const& t, KdNode const* const r, unsigned int lvl);
177 void find_nv(RRTNode const& t, KdNode const* const r, unsigned int lvl);
181 void store(RRTNode n);
182 void find_nn(RRTNode const& t);
183 void find_nv(RRTNode const& t);
186 /*! \brief Use k-d tree data structure to store RRT nodes.
188 This approach speeds up the search process for the nearest neighbor and
189 the near vertices procedures. This extension implements 2D K-d tree.
191 \see https://en.wikipedia.org/wiki/K-d_tree
193 class RRTExt7 : public virtual RRTS {
197 RRTNode *node_ = nullptr;
198 KdNode *left_ = nullptr;
199 KdNode *right_ = nullptr;
202 RRTNode *node() const { return this->node_; }
203 KdNode *&left() { return this->left_; }
204 KdNode *&right() { return this->right_; }
207 KdNode *kdroot_ = nullptr;
208 void delete_kd_nodes(KdNode *n);
209 void store_node(RRTNode *n, KdNode *&r, int l);
210 void nn(RRTNode *&n, RRTNode &t, KdNode *r, int l, double &d);
214 void store_node(RRTNode n);
215 RRTNode *nn(RRTNode &t);
216 std::vector<RRTNode *> nv(RRTNode &t);
219 /*! \brief Reeds and Shepp cost for building and search.
221 class RRTExt6 : public virtual RRTS {
223 /*! \brief Reeds and Shepp path length.
225 double cost_build(RRTNode &f, RRTNode &t);
226 /*! \brief Reeds and Shepp path length.
228 double cost_search(RRTNode &f, RRTNode &t);
231 /*! \brief Different costs extension.
233 Use different cost for bulding tree data structure and searching in the
234 structure. This one is complementary to `rrtext1.cc`.
236 class RRTExt5 : public virtual RRTS {
238 /*! \brief Reeds and Shepp path length.
240 double cost_build(RRTNode &f, RRTNode &t);
241 /*! \brief Euclidean distance.
243 double cost_search(RRTNode &f, RRTNode &t);
246 /*! \brief Use grid data structure to store RRT nodes.
248 This approach speeds up the search process for the nearest neighbor and
249 the near vertices procedures.
251 class RRTExt4 : public virtual RRTS {
255 bool changed_ = false;
256 std::vector<RRTNode *> nodes_;
258 void nn(RRTNode *t, RRTNode **nn, RRTS *p);
259 void store_node(RRTNode *n);
264 return this->changed_;
266 std::vector<RRTNode *> &nodes()
273 Cell grid_[GRID_MAX_XI][GRID_MAX_YI]; // [0, 0] is bottom left
279 unsigned int xi(RRTNode n);
280 unsigned int yi(RRTNode n);
284 void store_node(RRTNode n);
285 RRTNode *nn(RRTNode &t);
286 std::vector<RRTNode *> nv(RRTNode &t);
289 /*! \brief Use Dijkstra algorithm to find the shorter path.
291 class RRTExt3 : public virtual RRTS {
295 std::vector<RRTNode *> orig_path_;
296 double orig_path_cost_ = 9999;
297 std::vector<RRTNode *> first_optimized_path_;
298 double first_optimized_path_cost_ = 9999;
299 void first_path_optimization();
300 void second_path_optimization();
303 void json(Json::Value jvi);
306 std::vector<RRTNode *> &orig_path()
308 return this->orig_path_;
310 double &orig_path_cost() { return this->orig_path_cost_; }
311 void orig_path_cost(double c) { this->orig_path_cost_ = c; }
312 std::vector<RRTNode *> &first_optimized_path()
314 return this->first_optimized_path_;
316 double &first_optimized_path_cost() {
317 return this->first_optimized_path_cost_;
319 void first_optimized_path_cost(double c) {
320 this->first_optimized_path_cost_ = c;
324 /*! \brief Use cute_c2 for collision detection.
326 \see https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h
328 class RRTExt2 : public virtual RRTS {
332 std::vector<c2Poly> c2_obstacles_;
333 bool collide(RRTNode const& n);
334 bool collide_steered();
337 Json::Value json() const;
338 void json(Json::Value jvi);
341 /*! \brief Different costs extension.
343 Use different cost for bulding tree data structure and searching in the
346 class RRTExt1 : public virtual RRTS {
348 /*! \brief Reeds and Shepp path length.
350 double cost_build(RRTNode &f, RRTNode &t);
351 /*! \brief Matej's heuristics.
353 double cost_search(RRTNode &f, RRTNode &t);
357 #endif /* RRTS_RRTEXT_H */