{
RRTNode *xn = nullptr;
RRTNode *rs;
+ int ret = 0;
#if GOALFIRST > 0
if (this->samples().size() == 0)
rs = this->goal();
// std::cerr << "- xn: nullptr" << std::endl;
// }
this->swap();
- this->connectstar(xn);
+ ret = this->connectstar(xn);
} else {
this->swap();
}
+ if (ret == 1) {
+ this->tlog(this->findt());
+ return true;
+ }
return this->goal_found();
}
} else {
// rewire
this->rewire(nvs, ns);
- if (this->goal_found(ns, this->cost)) {
- this->tlog(this->findt());
- ret = 1;
- }
}
for (auto n: steered) {
if (n != steered[1])
// rewire
this->rewire(nvs, ns);
pn = ns;
- if (this->goal_found(pn, this->cost)) {
- this->tlog(this->findt());
- en_add = false;
- ret = 1;
- }
+if (IS_NEAR(pn, rs)) { // GOAL FOUND !
+ RRTNode *tmp;
+ if (this->orig_root_ == this->root()) { // rs is in G tree
+ // add all rs parents to pn
+ tmp = rs->parent();
+ } else { // rs is in R tree
+ tmp = pn->parent();
+ pn = rs;
+ this->swap();
+ }
+ while (tmp != this->goal()) {
+ this->nodes().push_back(new RRTNode(
+ tmp->x(),
+ tmp->y(),
+ tmp->h()));
+ this->nodes().back()->s(tmp->s());
+ this->nodes().back()->tree('R');
+ pn->add_child(
+ this->nodes().back(),
+ this->cost(pn, this->nodes().back()));
+ pn = this->nodes().back();
+ tmp = tmp->parent();
+ }
+ pn->add_child(tmp, this->cost(pn, tmp)); // add goal()
+ en_add = false;
+ ret = 1;
+}
}
}
}