]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/blobdiff - rrts/src/rrts.cc
Rename set parent of rrt node method argument
[hubacji1/iamcar2.git] / rrts / src / rrts.cc
index 0c1a663e0f7e5e5beaa9d16404bddd090240f33b..bc87c7f1ada2bab0417d07d7fb028f97d86f3060 100644 (file)
@@ -55,10 +55,10 @@ RRTNode::p() const
 }
 
 void
-RRTNode::p(RRTNode& p, bool connecting_goal)
+RRTNode::p(RRTNode& p, bool can_be_too_close)
 {
        assert(this != &p);
-       if (!connecting_goal) {
+       if (!can_be_too_close) {
                assert(!(std::abs(p.x() - this->x()) < 1e-3
                        && std::abs(p.y() - this->y()) < 1e-3
                        && std::abs(p.h() - this->h()) < 1e-3));
@@ -450,9 +450,20 @@ RRTS::json(void) const
                        jvo["paths"][j][i][2] = n.h();
                        jvo["paths"][j][i][3] = n.sp();
                        jvo["paths"][j][i][4] = n.st();
-                       jvo["paths"][j][i][5] = n.p_is_cusp();
+                       jvo["paths"][j][i][5] = false;
+                       if (n.p_is_cusp()) {
+                               assert(i > 0);
+                               jvo["paths"][j][i - 1][5] = true;
+                       }
                        i++;
                }
+               // Initial point is part of the first segment.
+               jvo["paths"][j][0][3] = jvo["paths"][j][1][3];
+               jvo["paths"][j][0][4] = jvo["paths"][j][1][4];
+               // Goal point is part of the last segment.
+               jvo["paths"][j][i - 1][3] = jvo["paths"][j][i - 2][3];
+               jvo["paths"][j][i - 1][4] = jvo["paths"][j][i - 2][4];
+               // --
                jvo["costs"][j] = path.back().cc();
                j++;
        }
@@ -469,11 +480,21 @@ RRTS::json(void) const
                jvo["path"][i][2] = n->h();
                jvo["path"][i][3] = n->sp();
                jvo["path"][i][4] = n->st();
-               jvo["path"][i][5] = n->p_is_cusp();
+               jvo["path"][i][5] = false;
+               if (n->p_is_cusp()) {
+                       assert(i > 0);
+                       jvo["path"][i - 1][5] = true;
+               }
                i++;
        }
+       // Initial point is part of the first segment.
+       jvo["path"][0][3] = jvo["path"][1][3];
+       jvo["path"][0][4] = jvo["path"][1][4];
+       // Goal point is part of the last segment.
+       jvo["path"][i - 1][3] = jvo["path"][i - 2][3];
+       jvo["path"][i - 1][4] = jvo["path"][i - 2][4];
+       // --
        jvo["costs"][j] = this->_path.back()->cc();
-       j++;
        jvo["goal_cc"] = this->_goal.cc(); // TODO remove, use the following
        jvo["cost"] = this->path_cost();
        jvo["time"] = this->scnt();