RRTNode *node,
float (*cost)(RRTNode *, RRTNode* ))
{
- if (IS_NEAR(node, this->goal_)) {
+ if (GOAL_IS_NEAR(node, this->goal_)) {
if (this->goal_found_) {
if (node->ccost() + this->cost(node, this->goal_) <
this->goal_->ccost()) {
RRTNode *goal
)
{
- if (IS_NEAR(node, goal)) {
+ if (GOAL_IS_NEAR(node, goal)) {
if (this->goal_found_) {
if (
goal->ccost() != -1
}
// 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)