}
// RRT Framework
+void RRTBase::setSamplingInfo(SamplingInfo si)
+{
+ this->ndx_ = std::normal_distribution<float>(si.x0, si.x);
+ this->ndy_ = std::normal_distribution<float>(si.y0, si.y);
+ this->ndh_ = std::normal_distribution<float>(si.h0, si.h);
+}
+
RRTNode *RRTBase::sample()
{
- if (this->useSamplingInfo_ && this->nodes().size() % 2 == 0) {
- float x = static_cast<float>(rand());
- x /= static_cast<float>(RAND_MAX / this->samplingInfo_.x);
- x -= this->samplingInfo_.x / 2;
- x += this->samplingInfo_.x0;
- float y = static_cast<float>(rand());
- y /= static_cast<float>(RAND_MAX / this->samplingInfo_.y);
- y -= this->samplingInfo_.y / 2;
- y += this->samplingInfo_.y0;
- float h = static_cast<float>(rand());
- h /= static_cast<float>(RAND_MAX / this->samplingInfo_.h);
- h -= this->samplingInfo_.h / 2;
- h += this->samplingInfo_.h0;
- return new RRTNode(x, y, h);
- } else {
- float x = this->ndx_(this->gen_);
- float y = this->ndy_(this->gen_);
- float h = this->ndh_(this->gen_);
- return new RRTNode(x, y, h);
- }
+ float x = this->ndx_(this->gen_);
+ float y = this->ndy_(this->gen_);
+ float h = this->ndh_(this->gen_);
+ return new RRTNode(x, y, h);
}
float RRTBase::cost(RRTNode *init, RRTNode *goal)
std::vector<RRTNode *> findt(RRTNode *n);
// RRT Framework
- SamplingInfo samplingInfo_;
- bool useSamplingInfo_ = false;
+ void setSamplingInfo(SamplingInfo si);
RRTNode *sample();
float cost(RRTNode *init, RRTNode *goal);
RRTNode *nn(RRTNode *rs);