bool T3::next()
{
+ RRTNode *ron = nullptr;
+ RRTNode *gon = nullptr;
bool ret = false;
ret = this->p_root_.next();
ret &= this->p_goal_.next();
- for (auto rn: this->p_root_.nodes()) {
- if (rn->parent() == nullptr)
- continue;
- for (auto gn: this->p_goal_.nodes()) {
- if (gn->parent() == nullptr)
- continue;
- if (IS_NEAR(rn, gn)) {
- if (this->connecttrees(rn, gn))
- this->goal_found(true);
- this->tlog(this->findt());
- return true;
- }
- }
+ if (this->overlaptrees(&ron, &gon)) {
+ if (this->connecttrees(ron, gon))
+ this->goal_found(true);
+ this->tlog(this->findt());
+ ret &= true;
}
return ret;
}
rn->add_child(this->goal(), this->p_root_.cost(rn, this->goal()));
return true;
}
+
+bool T3::overlaptrees(RRTNode **ron, RRTNode **gon)
+{
+ for (auto rn: this->p_root_.nodes()) {
+ if (rn->parent() == nullptr)
+ continue;
+ for (auto gn: this->p_goal_.nodes()) {
+ if (gn->parent() == nullptr)
+ continue;
+ if (IS_NEAR(rn, gn)) {
+ *ron = rn;
+ *gon = gn;
+ return true;
+ }
+ }
+ }
+ return false;
+}
std::vector<CircleObstacle> *cobstacles,
std::vector<SegmentObstacle> *sobstacles);
bool connecttrees(RRTNode *rn, RRTNode *gn);
+ bool overlaptrees(RRTNode **ron, RRTNode **gon);
};
#endif