X-Git-Url: http://rtime.felk.cvut.cz/gitweb/hubacji1/iamcar.git/blobdiff_plain/06fbfee74df36f879398a63949781126253cca51..8689fd2366da2ad65e16ed071f82eefe06577842:/base/rrtbase.cc diff --git a/base/rrtbase.cc b/base/rrtbase.cc index ed41b91..9600bb4 100644 --- a/base/rrtbase.cc +++ b/base/rrtbase.cc @@ -990,28 +990,19 @@ std::vector RRTBase::findt(RRTNode *n) } // RRT Framework +void RRTBase::setSamplingInfo(SamplingInfo si) +{ + this->ndx_ = std::normal_distribution(si.x0, si.x); + this->ndy_ = std::normal_distribution(si.y0, si.y); + this->ndh_ = std::normal_distribution(si.h0, si.h); +} + RRTNode *RRTBase::sample() { - if (this->useSamplingInfo_ && this->nodes().size() % 2 == 0) { - float x = static_cast(rand()); - x /= static_cast(RAND_MAX / this->samplingInfo_.x); - x -= this->samplingInfo_.x / 2; - x += this->samplingInfo_.x0; - float y = static_cast(rand()); - y /= static_cast(RAND_MAX / this->samplingInfo_.y); - y -= this->samplingInfo_.y / 2; - y += this->samplingInfo_.y0; - float h = static_cast(rand()); - h /= static_cast(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)