]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/commitdiff
Fix searching for cusps points
authorJiri Hubacek <hubacji1@fel.cvut.cz>
Sat, 6 Oct 2018 10:57:22 +0000 (12:57 +0200)
committerJiri Hubacek <hubacji1@fel.cvut.cz>
Sat, 6 Oct 2018 12:27:28 +0000 (14:27 +0200)
decision_control/rrtplanner.cc

index b39e2d55b37a08e900fcbe018600ef60e20f1810..744a662484eac47636312de41fec58732ad3aaba 100644 (file)
@@ -634,21 +634,22 @@ bool T2::opt_path()
         float oc = this->tlog().back().front()->ccost();
         std::vector<RRTNode *> tmp_cusps;
         for (auto n: this->tlog().back()) {
-                if (n->parent() && sgn(n->s()) != sgn(n->parent()->s())) {
-                                tmp_cusps.push_back(n);
-                                tmp_cusps.push_back(n->parent());
+                if (sgn(n->s()) == 0) {
+                        tmp_cusps.push_back(n);
+                } else if (n->parent() &&
+                                sgn(n->s()) != sgn(n->parent()->s())) {
+                        tmp_cusps.push_back(n);
+                        tmp_cusps.push_back(n->parent());
                 }
         }
-        if (tmp_cusps.size() == 0)
+        if (tmp_cusps.size() < 2)
                 return false;
         std::vector<RRTNode *> cusps;
         for (unsigned int i = 0; i < tmp_cusps.size() - 1; i++) {
                 if (tmp_cusps[i] != tmp_cusps[i + 1])
                         cusps.push_back(tmp_cusps[i]);
         }
-        cusps.push_back(this->root());
         std::reverse(cusps.begin(), cusps.end());
-        cusps.push_back(this->tlog().back().front());
         // Begin of Dijkstra
         std::vector<RRTNodeDijkstra> dnodes;
         for (unsigned int i = 0; i < cusps.size(); i++)