std::vector<RRTNode *> RRTBase::findt()
{
- return this->findt(this->goal_);
+ RRTNode *goal = this->goal_;
+ for (auto g: this->goals()) {
+ if (goal->parent() == nullptr || g->ccost() < g->ccost())
+ goal = g;
+ }
+ if (goal->parent() == nullptr)
+ this->goal_found(false);
+ return this->findt(goal);
}
std::vector<RRTNode *> RRTBase::findt(RRTNode *n)
}
// RRT Framework
+void RRTBase::defaultSamplingInfo()
+{
+ float hcenter = (this->HMAX - this->HMIN) / 2 + this->HMIN;
+ float hrange = (this->HMAX - this->HMIN) / 2;
+ float vcenter = (this->VMAX - this->VMIN) / 2 + this->VMIN;
+ float vrange = (this->VMAX - this->VMIN) / 2;
+ this->ndx_ = std::normal_distribution<float>(hcenter, hrange);
+ this->ndy_ = std::normal_distribution<float>(vcenter, vrange);
+ this->ndh_ = std::normal_distribution<float>(0, 2 * M_PI);
+}
+
void RRTBase::setSamplingInfo(SamplingInfo si)
{
this->ndx_ = std::normal_distribution<float>(si.x0, si.x);