]> rtime.felk.cvut.cz Git - hubacji1/rrts.git/blobdiff - incl/rrtext.hh
Improve docs for (collision) ext 20
[hubacji1/rrts.git] / incl / rrtext.hh
index b09f1c4829db9b5ad72ee163be02cf30774ae09d..d8bcfd6eed1c4bcd4a37da59b0950b4a04123927 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * SPDX-FileCopyrightText: 2021 Jiri Vlasak <jiri.vlasak.2@cvut.cz>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+/*! \brief RRT* extensions.
+ *
+ * The extensions are used to implement or change the default behavior of the
+ * RRT* algorithm.
+ *
+ * \file
+ * \defgroup ext-col Collision detection extensions
+ * \defgroup ext-store Node storage and searching tree extensions
+ * \defgroup ext-cost Cost extensions
+ * \defgroup ext-opt Path optimization extensions
+ * \defgroup ext-sampl Random sampling extensions
+ * \defgroup ext-steer Steering procedure extensions
+ * \defgroup ext-aux Auxilliary extensions
+ */
 #ifndef RRTS_RRTEXT_H
 #define RRTS_RRTEXT_H
 
 
 namespace rrts {
 
+/*! \brief Collision check based on occupancy grid.
+ *
+ * This approach expects obstacles to be represented by points and the collision
+ * occures whenever the point is inside the frame given by the car pose and the
+ * car size.
+ *
+ * \ingroup ext-col
+ */
+class RRTExt20 : public virtual RRTS {
+private:
+       std::vector<bcar::Point> const *_points_to_check = nullptr;
+       bool collide_steered();
+public:
+       void set_points_to_check(std::vector<bcar::Point> const *p);
+};
+
+/*! \brief Use Dubins paths-based steering procedure.
+ *
+ * \ingroup ext-steer
+ * \see https://github.com/AndrewWalker/Dubins-Curves
+ */
+class RRTExt19 : public virtual RRTS {
+private:
+       void steer(RRTNode const &f, RRTNode const &t);
+};
+
+/*! \brief Finish when more than 1000 iterations.
+ *
+ * \ingroup ext-aux
+ */
 class RRTExt18 : public virtual RRTS {
 private:
        bool should_finish() const;
 };
 
+/*! \brief Finish when goal found or more than 1000 iterations.
+ *
+ * \ingroup ext-aux
+ */
 class RRTExt17 : public virtual RRTS {
 private:
        bool should_finish() const;
 };
 
+/*! \brief Use Reeds & Shepp steering procedure.
+ *
+ * \ingroup ext-steer
+ */
 class RRTExt16 : public virtual RRTS {
 private:
        void steer(RRTNode const& f, RRTNode const& t);
 };
 
+/*! \brief Log goal's cumulative cost each iteration.
+ *
+ * \ingroup ext-aux
+ */
 class RRTExt15 : public virtual RRTS {
 private:
        std::vector<double> log_path_cost_;
@@ -44,6 +106,7 @@ public:
 
 /*! \brief Random sampling in the circuit between root and goal.
  *
+ * \ingroup ext-sampl
  * \see https://stackoverflow.com/questions/5837572/generate-a-random-point-within-a-circle-uniformly/50746409#50746409
  */
 class RRTExt14 : public virtual RRTS {
@@ -59,7 +122,13 @@ public:
        void reset();
 };
 
-/*! Use Dijkstra-based path optimization, goal zone for interesting nodes. */
+/*! \brief Use Dijkstra algorithm to find path between interesting nodes.
+ *
+ * The search for interesting nodes starts at root, the last drivable nodes is
+ * added to interesting nodes until goal is reached.
+ *
+ * \ingroup ext-opt
+ */
 class RRTExt13 : public virtual RRTS {
 private:
        class DijkstraNode {
@@ -67,6 +136,7 @@ private:
                RRTNode* node = nullptr;
                unsigned int i = 0;
                bool v = false;
+               double d = 0.0;
                bool vi();
                DijkstraNode(RRTNode* n);
        };
@@ -74,11 +144,16 @@ private:
        public:
                int operator() (DijkstraNode const& n1, DijkstraNode const& n2);
        };
+       class DijkstraNodeBackwardComparator {
+       public:
+               int operator() (DijkstraNode const& n1, DijkstraNode const& n2);
+       };
        std::vector<RRTNode*> opath_;
        double ogoal_cc_ = 0.0;
        double otime_ = 0.0;
        std::vector<DijkstraNode> dn_;
-       void pick_interesting();
+       void interesting_forward();
+       void interesting_backward();
        void dijkstra_forward();
        void dijkstra_backward();
        void compute_path();
@@ -89,7 +164,7 @@ public:
        void reset();
 };
 
-/*! \brief Different `steer` procedures.
+/* \brief Different `steer` procedures.
 
 Use sampling in control input for `steer1`. Use R&S steering for `steer2`.
 */
@@ -101,7 +176,7 @@ class RRTExt12 : public virtual RRTS {
                bool next();
 };
 
-/*! \brief Goal Zone.
+/* \brief Goal Zone.
 
 */
 class RRTExt11 : public virtual RRTS {
@@ -109,13 +184,14 @@ class RRTExt11 : public virtual RRTS {
                bool goal_found(RRTNode &f);
 };
 
-/*! \brief Different costs extension.
+/*! \brief Reeds & Shepp (build) and Euclidean + abs angle (search).
  *
- * Use different cost for bulding tree data structure and searching in the
- * structure. The cost function is from Elbanhawi, Mohamed, Milan Simic, and
- * Reza Jazar. “Randomized Bidirectional B-Spline Parameterization Motion
- * Planning.” IEEE Transactions on Intelligent Transportation Systems 17, no. 2
- * (February 2016): 406–19. https://doi.org/10.1109/TITS.2015.2477355.
+ * Use Reeds & Shepp path length for building tree data structure and Euclidean
+ * distance + (abs) heading difference + 0.1 * backward-forward direction
+ * changes for searching it.
+ *
+ * \ingroup ext-cost
+ * \see https://doi.org/10.1109/TITS.2015.2477355
  */
 class RRTExt10 : public virtual RRTS {
 protected:
@@ -123,7 +199,7 @@ protected:
        double cost_search(RRTNode const& f, RRTNode const& t) const;
 };
 
-/*! \brief Use grid data structure to store RRT nodes.
+/* \brief Use grid data structure to store RRT nodes.
 
 This approach speeds up the search process for the nearest neighbor and
 the near vertices procedures.
@@ -169,11 +245,12 @@ class RRTExt9 : public virtual RRTS {
                std::vector<RRTNode *> nv(RRTNode &t);
 };
 
-/*! \brief Use k-d tree data structure to store RRT nodes.
+/*! \brief Use 3D k-d tree data structure to store RRT nodes.
  *
  * This approach speeds up the search process for the nearest neighbor and the
  * near vertices procedures. This extension implements 3D K-d tree.
  *
+ * \ingroup ext-store
  * \see https://en.wikipedia.org/wiki/K-d_tree
  */
 class RRTExt8 : public virtual RRTS {
@@ -198,7 +275,7 @@ public:
        void find_nv(RRTNode const& t);
 };
 
-/*! \brief Use k-d tree data structure to store RRT nodes.
+/* \brief Use k-d tree data structure to store RRT nodes.
 
 This approach speeds up the search process for the nearest neighbor and
 the near vertices procedures. This extension implements 2D K-d tree.
@@ -244,22 +321,22 @@ private:
        double cost_search(RRTNode const& f, RRTNode const& t) const;
 };
 
-/*! \brief Different costs extension.
+/* \brief Different costs extension.
 
 Use different cost for bulding tree data structure and searching in the
 structure. This one is complementary to `rrtext1.cc`.
 */
 class RRTExt5 : public virtual RRTS {
        public:
-               /*! \brief Reeds and Shepp path length.
+               /* \brief Reeds and Shepp path length.
                */
                double cost_build(RRTNode &f, RRTNode &t);
-               /*! \brief Euclidean distance.
+               /* \brief Euclidean distance.
                */
                double cost_search(RRTNode &f, RRTNode &t);
 };
 
-/*! \brief Use grid data structure to store RRT nodes.
+/* \brief Use grid data structure to store RRT nodes.
 
 This approach speeds up the search process for the nearest neighbor and
 the near vertices procedures.
@@ -302,7 +379,7 @@ class RRTExt4 : public virtual RRTS {
                std::vector<RRTNode *> nv(RRTNode &t);
 };
 
-/*! \brief Use Dijkstra algorithm to find the shorter path.
+/* \brief Use Dijkstra algorithm to find the shorter path.
 */
 class RRTExt3 : public virtual RRTS {
        private:
@@ -337,10 +414,11 @@ class RRTExt3 : public virtual RRTS {
                }
 };
 
-/*! \brief Use cute_c2 for collision detection.
-
-\see https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h
-*/
+/*! \brief Use cute_c2 library for collision detection.
+ *
+ * \ingroup ext-col
+ * \see https://github.com/RandyGaul/cute_headers/blob/master/cute_c2.h
+ */
 class RRTExt2 : public virtual RRTS {
 private:
        c2Poly c2_bc_;
@@ -352,19 +430,20 @@ public:
        RRTExt2();
        Json::Value json() const;
        void json(Json::Value jvi);
+       void reset();
 };
 
-/*! \brief Different costs extension.
+/* \brief Different costs extension.
 
 Use different cost for bulding tree data structure and searching in the
 structure.
 */
 class RRTExt1 : public virtual RRTS {
        public:
-               /*! \brief Reeds and Shepp path length.
+               /* \brief Reeds and Shepp path length.
                */
                double cost_build(RRTNode &f, RRTNode &t);
-               /*! \brief Matej's heuristics.
+               /* \brief Matej's heuristics.
                */
                double cost_search(RRTNode &f, RRTNode &t);
 };