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
19 /*! \brief Use k-d tree data structure to store RRT nodes.
21 This approach speeds up the search process for the nearest neighbor and
22 the near vertices procedures. This extension implements 2D K-d tree.
24 \see https://en.wikipedia.org/wiki/K-d_tree
26 class RRTExt7 : public virtual RRTS {
30 RRTNode *node_ = nullptr;
31 KdNode *left_ = nullptr;
32 KdNode *right_ = nullptr;
35 RRTNode *node() const { return this->node_; }
36 KdNode *&left() { return this->left_; }
37 KdNode *&right() { return this->right_; }
40 KdNode *kdroot_ = nullptr;
41 void store_node(RRTNode *n, KdNode *&r, int l);
42 void nn(RRTNode *&n, RRTNode &t, KdNode *r, int l, double &d);
46 void store_node(RRTNode n);
47 RRTNode *nn(RRTNode &t);
48 std::vector<RRTNode *> nv(RRTNode &t);
51 /*! \brief Reeds and Shepp cost for building and search.
53 class RRTExt6 : public virtual RRTS {
55 /*! \brief Reeds and Shepp path length.
57 double cost_build(RRTNode &f, RRTNode &t);
58 /*! \brief Reeds and Shepp path length.
60 double cost_search(RRTNode &f, RRTNode &t);
63 /*! \brief Different costs extension.
65 Use different cost for bulding tree data structure and searching in the
66 structure. This one is complementary to `rrtext1.cc`.
68 class RRTExt5 : public virtual RRTS {
70 /*! \brief Reeds and Shepp path length.
72 double cost_build(RRTNode &f, RRTNode &t);
73 /*! \brief Euclidean distance.
75 double cost_search(RRTNode &f, RRTNode &t);
78 /*! \brief Use grid data structure to store RRT nodes.
80 This approach speeds up the search process for the nearest neighbor and
81 the near vertices procedures.
83 class RRTExt4 : public virtual RRTS {
87 bool changed_ = false;
88 std::vector<RRTNode *> nodes_;
90 void nn(RRTNode *t, RRTNode **nn, RRTS *p);
91 void store_node(RRTNode *n);
96 return this->changed_;
98 std::vector<RRTNode *> &nodes()
105 Cell grid_[GRID_MAX_XI][GRID_MAX_YI]; // [0, 0] is bottom left
106 unsigned int x_min_ = 0;
107 unsigned int x_max_ = 0;
108 unsigned int y_min_ = 0;
109 unsigned int y_max_ = 0;
111 unsigned int xi(RRTNode n);
112 unsigned int yi(RRTNode n);
116 void store_node(RRTNode n);
117 RRTNode *nn(RRTNode &t);
118 std::vector<RRTNode *> nv(RRTNode &t);
121 /*! \brief Use Dijkstra algorithm to find the shorter path.
123 class RRTExt3 : public virtual RRTS {
125 std::vector<RRTNode *> orig_path_;
126 double orig_path_cost_;
128 std::vector<RRTNode *> path();
131 std::vector<RRTNode *> &orig_path()
133 return this->orig_path_;
135 double &orig_path_cost() { return this->orig_path_cost_; }
136 void orig_path_cost(double c) { this->orig_path_cost_ = c; }
139 /*! \brief Use cute_c2 for collision detection.
141 \see https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h
143 class RRTExt2 : public virtual RRTS {
147 std::vector<c2Poly> c2_obstacles_;
152 // Collide RRT procedures
153 std::tuple<bool, unsigned int, unsigned int>
154 collide_steered_from(RRTNode &f);
156 std::tuple<bool, unsigned int, unsigned int>
157 collide_two_nodes(RRTNode &f, RRTNode &t);
160 c2Poly &c2_bc() { return this->c2_bc_; }
161 c2x &c2x_bc() { return this->c2x_bc_; }
162 std::vector<c2Poly> &c2_obstacles() {
163 return this->c2_obstacles_;
167 /*! \brief Different costs extension.
169 Use different cost for bulding tree data structure and searching in the
172 class RRTExt1 : public virtual RRTS {
174 /*! \brief Reeds and Shepp path length.
176 double cost_build(RRTNode &f, RRTNode &t);
177 /*! \brief Matej's heuristics.
179 double cost_search(RRTNode &f, RRTNode &t);
182 #endif /* RRTEXT_H */