]> rtime.felk.cvut.cz Git - hubacji1/rrts.git/commitdiff
Implement naive steer
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Fri, 26 Jul 2019 07:59:09 +0000 (09:59 +0200)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Sun, 28 Jul 2019 19:10:37 +0000 (21:10 +0200)
api/rrts.h
src/rrts.cc

index 910b3e41de87b06904aa8c5b95b886e69ff9f7c9..b18858643c9806b0ea71e35f1b2fcbd605aee6d2 100644 (file)
@@ -41,6 +41,7 @@ class RRTS {
                 std::vector<RRTNode> goals_;
                 std::vector<RRTNode> nodes_;
                 std::vector<RRTNode> samples_;
+                std::vector<RRTNode> steered_;
 
                 // RRT procedures
                 bool collide();
@@ -59,7 +60,7 @@ class RRTS {
         public:
                 /*! \brief Return path found by RRT*.
                 */
-                std::vector<std::reference_wrapper<RRTNode>> path();
+                std::vector<RRTNode *> path();
                 /*! \brief Run next RRT* iteration.
                 */
                 bool next();
@@ -68,6 +69,7 @@ class RRTS {
                 std::vector<RRTNode> &goals() { return this->goals_; }
                 std::vector<RRTNode> &nodes() { return this->nodes_; }
                 std::vector<RRTNode> &samples() { return this->samples_; }
+                std::vector<RRTNode> &steered() { return this->steered_; }
 
                 RRTS();
 };
index c038dd17c9846c9b4dc3ff4f2896c5470336b385..4c5c004e3d0ff3ca3206cc3864b6764e33c5b5de 100644 (file)
@@ -58,13 +58,14 @@ std::vector<RRTNode *> RRTS::nv(RRTNode &t)
         return nv;
 }
 
-bool RRTS::steer(
-        RRTNode &f,
-        RRTNode &t
-)
+void RRTS::steer(RRTNode &f, RRTNode &t)
 {
-        bool next = false;
-        return next;
+        double angl = atan2(t.y() - f.y(), t.x() - f.x());
+        this->steered().clear();
+        this->steered().push_back(RRTNode());
+        this->steered().back().x(f.x() + ETA * cos(angl));
+        this->steered().back().y(f.y() + ETA * sin(angl));
+        this->steered().back().h(angl);
 }
 
 // RRT* procedures