float alfa();
/** Return true if `n` not inside of `ccl`, `ccr` */
bool drivable(RRTNode *n);
+ /** Return ``RRTNode`` where ``BicycleCar`` may steer to.
+
+ When the node ``n`` is not drivable, use guess.
+
+ @param n The node to drive to.
+
+ */
+ RRTNode *drivableNode(RRTNode *n);
/** Return node rotated by `dh` around `c` */
BicycleCar *move(RRTNode *c, float dh);
};
return true;
}
+RRTNode *BicycleCar::drivableNode(RRTNode *n)
+{
+ bool drivable = true;
+ RRTNode *ccl = this->ccl();
+ if (
+ pow(ccl->x() - n->x(), 2) + pow(ccl->y() - n->y(), 2)
+ <= pow(this->turning_radius_, 2)
+ ) {
+ if (this->inFront(n))
+ return this->move(ccl, M_PI);
+ else
+ return this->move(ccl, -M_PI);
+ }
+ RRTNode *ccr = this->ccr();
+ if (
+ pow(ccr->x() - n->x(), 2) + pow(ccr->y() - n->y(), 2)
+ <= pow(this->turning_radius_, 2)
+ ) {
+ if (this->inFront(n))
+ return this->move(ccr, -M_PI);
+ else
+ return this->move(ccr, M_PI);
+ }
+ return n;
+}
+
BicycleCar *BicycleCar::move(RRTNode *c, float dh)
{
float zx = c->x();
std::vector<RRTNode *> st5(RRTNode *init, RRTNode *goal, float step, bool bw)
{
std::vector<RRTNode *> nodes;
+ BicycleCar *bc = new BicycleCar(init->x(), init->y(), init->h());
+ RRTNode *dg = bc->drivableNode(goal); // drivable goal
double q0[] = {init->x(), init->y(), init->h()};
- double q1[] = {goal->x(), goal->y(), goal->h()};
+ double q1[] = {dg->x(), dg->y(), dg->h()};
DubinsPath path;
if (bw)
dubins_shortest_path(&path, q1, q0, ST5TURNINGRADIUS);