]> rtime.felk.cvut.cz Git - hubacji1/rrts.git/blobdiff - api/rrtext.h
Add reset method, remove debug print
[hubacji1/rrts.git] / api / rrtext.h
index 89e6d5c3f2a7ef7f9393e3f9381ef996e1fa8ded..4e1f825cbef208dfc7488f04e7f6fc7ba4831db5 100644 (file)
@@ -8,14 +8,60 @@
 
 // ext4
 #define GRID 1 // in meters
-#define GRID_WIDTH 100 // in meters
-#define GRID_HEIGHT 100 // in meters
+#define GRID_WIDTH 40 // in meters
+#define GRID_HEIGHT 40 // in meters
 #define GRID_MAX_XI ((unsigned int) floor(GRID_WIDTH / GRID)) // min is 0
 #define GRID_MAX_YI ((unsigned int) floor(GRID_HEIGHT / GRID)) // min is 0
 
 // ext9
 #define GRID_MAX_HI 60
 
+/*! Use Dijkstra-based path optimization, goal zone for interesting nodes. */
+class RRTExt13 : public virtual RRTS {
+        private:
+        public:
+                void reset();
+                std::vector<RRTNode *> orig_path_;
+                double orig_path_cost_ = 9999;
+                std::vector<RRTNode *> first_optimized_path_;
+                double first_optimized_path_cost_ = 9999;
+                void first_path_optimization();
+                void second_path_optimization();
+                void compute_path();
+                Json::Value json();
+                void json(Json::Value jvi);
+
+                // getter, setter
+                std::vector<RRTNode *> &orig_path()
+                {
+                        return this->orig_path_;
+                };
+                double &orig_path_cost() { return this->orig_path_cost_; }
+                void orig_path_cost(double c) { this->orig_path_cost_ = c; }
+                std::vector<RRTNode *> &first_optimized_path()
+                {
+                        return this->first_optimized_path_;
+                };
+                double &first_optimized_path_cost() {
+                        return this->first_optimized_path_cost_;
+                }
+                void first_optimized_path_cost(double c) {
+                        this->first_optimized_path_cost_ = c;
+                }
+};
+
+/*! \brief Different `steer` procedures.
+
+Use sampling in control input for `steer1`. Use R&S steering for `steer2`.
+*/
+class RRTExt12 : public virtual RRTS {
+        protected:
+                void steer1(RRTNode &f, RRTNode &t);
+                bool connect();
+        public:
+                bool next();
+};
+
 /*! \brief Goal Zone.
 
 */
@@ -114,8 +160,21 @@ class RRTExt8 : public virtual RRTS {
                 void delete_kd_nodes(KdNode *n);
                 void store_node(RRTNode *n, KdNode *&r, int l);
                 void nn(RRTNode *&n, RRTNode &t, KdNode *r, int l, double &d);
+                void nv(
+                        std::vector<RRTNode*>& n,
+                        RRTNode &t,
+                        KdNode *r,
+                        int l,
+                        double const& d
+                );
         public:
+                void delete_kd_nodes()
+                {
+                    this->delete_kd_nodes(this->kdroot_);
+                    this->kdroot_ = nullptr;
+                }
                 void init();
+                void reset();
                 void deinit();
                 void store_node(RRTNode n);
                 RRTNode *nn(RRTNode &t);
@@ -229,14 +288,15 @@ class RRTExt4 : public virtual RRTS {
 */
 class RRTExt3 : public virtual RRTS {
         private:
+        public:
+                void reset();
                 std::vector<RRTNode *> orig_path_;
                 double orig_path_cost_ = 9999;
                 std::vector<RRTNode *> first_optimized_path_;
                 double first_optimized_path_cost_ = 9999;
-        public:
-                std::vector<RRTNode *> first_path_optimization();
-                std::vector<RRTNode *> second_path_optimization();
-                std::vector<RRTNode *> path();
+                void first_path_optimization();
+                void second_path_optimization();
+                void compute_path();
                 Json::Value json();
                 void json(Json::Value jvi);
 
@@ -275,6 +335,8 @@ class RRTExt2 : public virtual RRTS {
                 // Collide RRT procedures
                 std::tuple<bool, unsigned int, unsigned int>
                 collide_steered_from(RRTNode &f);
+                std::tuple<bool, unsigned int, unsigned int>
+                collide_tmp_steered_from(RRTNode &f);
 
                 std::tuple<bool, unsigned int, unsigned int>
                 collide_two_nodes(RRTNode &f, RRTNode &t);