10 #define GRID 1 // in meters
11 #define GRID_WIDTH 20 // in meters
12 #define GRID_HEIGHT 50 // 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
16 /*! \brief Use grid data structure to store RRT nodes.
18 This approach speeds up the search process for the nearest neighbor and
19 the near vertices procedures.
21 class RRTExt9 : public virtual RRTS {
25 bool changed_ = false;
26 std::vector<RRTNode *> nodes_;
28 void nn(RRTNode *t, RRTNode **nn, RRTS *p);
29 void store_node(RRTNode *n);
34 return this->changed_;
36 std::vector<RRTNode *> &nodes()
43 Cell grid_[GRID_MAX_XI][GRID_MAX_YI]; // [0, 0] is bottom left
44 unsigned int x_min_ = 0;
45 unsigned int x_max_ = 0;
46 unsigned int y_min_ = 0;
47 unsigned int y_max_ = 0;
49 unsigned int xi(RRTNode n);
50 unsigned int yi(RRTNode n);
54 void store_node(RRTNode n);
55 RRTNode *nn(RRTNode &t);
56 std::vector<RRTNode *> nv(RRTNode &t);
59 /*! \brief Use k-d tree data structure to store RRT nodes.
61 This approach speeds up the search process for the nearest neighbor and
62 the near vertices procedures. This extension implements 3D K-d tree.
64 \see https://en.wikipedia.org/wiki/K-d_tree
66 class RRTExt8 : public virtual RRTS {
70 RRTNode *node_ = nullptr;
71 KdNode *left_ = nullptr;
72 KdNode *right_ = nullptr;
75 RRTNode *node() const { return this->node_; }
76 KdNode *&left() { return this->left_; }
77 KdNode *&right() { return this->right_; }
80 KdNode *kdroot_ = nullptr;
81 void delete_kd_nodes(KdNode *n);
82 void store_node(RRTNode *n, KdNode *&r, int l);
83 void nn(RRTNode *&n, RRTNode &t, KdNode *r, int l, double &d);
87 void store_node(RRTNode n);
88 RRTNode *nn(RRTNode &t);
89 std::vector<RRTNode *> nv(RRTNode &t);
92 /*! \brief Use k-d tree data structure to store RRT nodes.
94 This approach speeds up the search process for the nearest neighbor and
95 the near vertices procedures. This extension implements 2D K-d tree.
97 \see https://en.wikipedia.org/wiki/K-d_tree
99 class RRTExt7 : public virtual RRTS {
103 RRTNode *node_ = nullptr;
104 KdNode *left_ = nullptr;
105 KdNode *right_ = nullptr;
108 RRTNode *node() const { return this->node_; }
109 KdNode *&left() { return this->left_; }
110 KdNode *&right() { return this->right_; }
113 KdNode *kdroot_ = nullptr;
114 void delete_kd_nodes(KdNode *n);
115 void store_node(RRTNode *n, KdNode *&r, int l);
116 void nn(RRTNode *&n, RRTNode &t, KdNode *r, int l, double &d);
120 void store_node(RRTNode n);
121 RRTNode *nn(RRTNode &t);
122 std::vector<RRTNode *> nv(RRTNode &t);
125 /*! \brief Reeds and Shepp cost for building and search.
127 class RRTExt6 : public virtual RRTS {
129 /*! \brief Reeds and Shepp path length.
131 double cost_build(RRTNode &f, RRTNode &t);
132 /*! \brief Reeds and Shepp path length.
134 double cost_search(RRTNode &f, RRTNode &t);
137 /*! \brief Different costs extension.
139 Use different cost for bulding tree data structure and searching in the
140 structure. This one is complementary to `rrtext1.cc`.
142 class RRTExt5 : public virtual RRTS {
144 /*! \brief Reeds and Shepp path length.
146 double cost_build(RRTNode &f, RRTNode &t);
147 /*! \brief Euclidean distance.
149 double cost_search(RRTNode &f, RRTNode &t);
152 /*! \brief Use grid data structure to store RRT nodes.
154 This approach speeds up the search process for the nearest neighbor and
155 the near vertices procedures.
157 class RRTExt4 : public virtual RRTS {
161 bool changed_ = false;
162 std::vector<RRTNode *> nodes_;
164 void nn(RRTNode *t, RRTNode **nn, RRTS *p);
165 void store_node(RRTNode *n);
170 return this->changed_;
172 std::vector<RRTNode *> &nodes()
179 Cell grid_[GRID_MAX_XI][GRID_MAX_YI]; // [0, 0] is bottom left
180 unsigned int x_min_ = 0;
181 unsigned int x_max_ = 0;
182 unsigned int y_min_ = 0;
183 unsigned int y_max_ = 0;
185 unsigned int xi(RRTNode n);
186 unsigned int yi(RRTNode n);
190 void store_node(RRTNode n);
191 RRTNode *nn(RRTNode &t);
192 std::vector<RRTNode *> nv(RRTNode &t);
195 /*! \brief Use Dijkstra algorithm to find the shorter path.
197 class RRTExt3 : public virtual RRTS {
199 std::vector<RRTNode *> orig_path_;
200 double orig_path_cost_;
202 std::vector<RRTNode *> path();
205 std::vector<RRTNode *> &orig_path()
207 return this->orig_path_;
209 double &orig_path_cost() { return this->orig_path_cost_; }
210 void orig_path_cost(double c) { this->orig_path_cost_ = c; }
213 /*! \brief Use cute_c2 for collision detection.
215 \see https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h
217 class RRTExt2 : public virtual RRTS {
221 std::vector<c2Poly> c2_obstacles_;
226 // Collide RRT procedures
227 std::tuple<bool, unsigned int, unsigned int>
228 collide_steered_from(RRTNode &f);
230 std::tuple<bool, unsigned int, unsigned int>
231 collide_two_nodes(RRTNode &f, RRTNode &t);
234 c2Poly &c2_bc() { return this->c2_bc_; }
235 c2x &c2x_bc() { return this->c2x_bc_; }
236 std::vector<c2Poly> &c2_obstacles() {
237 return this->c2_obstacles_;
241 /*! \brief Different costs extension.
243 Use different cost for bulding tree data structure and searching in the
246 class RRTExt1 : public virtual RRTS {
248 /*! \brief Reeds and Shepp path length.
250 double cost_build(RRTNode &f, RRTNode &t);
251 /*! \brief Matej's heuristics.
253 double cost_search(RRTNode &f, RRTNode &t);
256 #endif /* RRTEXT_H */