// RRT Framework
RRTNode *RRTBase::sample()
{
+ float x = this->samplingInfo_.x;
+ float y = this->samplingInfo_.y;
std::normal_distribution<float> xdist(
0,
BCAR_WIDTH / 3
);
- float x = this->samplingInfo_.x
- + BCAR_WIDTH / 2
- + std::abs(xdist(this->gen_));
+ x += this->samplingInfo_.dx
+ * (BCAR_WIDTH / 2 + std::abs(xdist(this->gen_)))
+ * cos(this->samplingInfo_.sh + M_PI / 2);
+ y += this->samplingInfo_.dx
+ * (BCAR_WIDTH / 2 + std::abs(xdist(this->gen_)))
+ * sin(this->samplingInfo_.sh + M_PI / 2);
std::normal_distribution<float> ydist(
0,
BCAR_LENGTH / 3
);
- float y = this->samplingInfo_.y + ydist(this->gen_);
+ x += ydist(this->gen_) * cos(this->samplingInfo_.sh);
+ y += ydist(this->gen_) * sin(this->samplingInfo_.sh);
std::normal_distribution<float> hdist(
0,
this->samplingInfo_.h / 3
);
float h = std::abs(hdist(this->gen_));
- return new RRTNode(x, y, M_PI / 2 - h);
+ return new RRTNode(
+ x,
+ y,
+ this->samplingInfo_.sh + this->samplingInfo_.dh * h
+ );
}
float RRTBase::cost(RRTNode *init, RRTNode *goal)