std::swap(q, empty);
}
+void ParallelSlot::fipf(
+ std::vector<CircleObstacle>& co,
+ std::vector<SegmentObstacle>& so
+)
+{
+ this->setAll();
+ std::vector<RRTNode *> tmpc;
+ BicycleCar *tmpf = this->getFPf();
+ BicycleCar *tmpb = this->getISPPf(tmpf);
+ RRTNode *cc;
+ if (this->slotSide() == LEFT)
+ cc = tmpb->ccl();
+ else
+ cc = tmpb->ccr();
+ if (this->slotSide() == LEFT)
+ this->DH(-1 * 0.5 / tmpb->out_radi());
+ else
+ this->DH(1 * 0.5 / tmpb->out_radi());
+ BicycleCar *p;
+ int i = 1;
+ p = tmpb->move(cc, i * this->DH());
+ while (
+ !this->slot().collide(p->frame())
+ && ((
+ this->slotSide() == LEFT
+ && p->h() > this->slotHeading()
+ ) || (
+ this->slotSide() == RIGHT
+ && p->h() < this->slotHeading()
+ ))
+ ) {
+ bool end = false;
+ std::vector<RRTEdge *> eds = p->frame();
+ for (auto o: co)
+ if (o.collide(eds))
+ end = true;
+ for (auto o: so)
+ if (o.collide(eds))
+ end = true;
+ for (auto e: eds)
+ delete e;
+ if (end)
+ break;
+ this->goals_.push_back(p);
+ tmpc.push_back(p);
+ i += 1;
+ p = tmpb->move(cc, i * this->DH());
+ }
+ if (tmpc.size() > 0)
+ this->cusp().push_back(tmpc);
+ return;
+}
+
BicycleCar *ParallelSlot::flnc(
BicycleCar *B,
std::vector<CircleObstacle>& co,
return new BicycleCar(x0, B->y(), B->h());
}
+BicycleCar *ParallelSlot::getFPf()
+{
+ this->setAll();
+ float x = this->slot().bnodes().front()->x();
+ float y = this->slot().bnodes().front()->y();
+ float h = this->slotHeading();
+ float nx;
+ float ny;
+ if (this->slotSide() == LEFT) {
+ h += M_PI / 2;
+ nx = x + (BCAR_LENGTH - BCAR_WHEEL_BASE) / 2
+ * cos(h);
+ ny = y + (BCAR_LENGTH - BCAR_WHEEL_BASE) / 2
+ * sin(h);
+ x = nx + (BCAR_DIAG_RRADI) * cos(h - M_PI / 2);
+ y = ny + (BCAR_DIAG_RRADI) * sin(h - M_PI / 2);
+ } else {
+ h -= M_PI / 2;
+ nx = x + (BCAR_LENGTH - BCAR_WHEEL_BASE) / 2
+ * cos(h);
+ ny = y + (BCAR_LENGTH - BCAR_WHEEL_BASE) / 2
+ * sin(h);
+ x = nx + (BCAR_DIAG_RRADI) * cos(h + M_PI / 2);
+ y = ny + (BCAR_DIAG_RRADI) * sin(h + M_PI / 2);
+ }
+ return new BicycleCar(x, y, h);
+}
+
+BicycleCar *ParallelSlot::getISPPf(BicycleCar *B)
+{
+ float x = this->slot().bnodes().front()->x();
+ float y = this->slot().bnodes().front()->y();
+ float y0;
+ if (this->slotSide() == LEFT)
+ y0 = B->ccl()->y();
+ else
+ y0 = B->ccr()->y();
+ float IR = BCAR_IN_RADI;
+ float a = 1;
+ float b = -2 * x;
+ float c = pow(x, 2) + pow(y - y0, 2) - pow(IR, 2);
+ float D = pow(b, 2) - 4 * a * c;
+ float x0;
+ if (this->slotSide() == LEFT)
+ x0 = -b - sqrt(D);
+ else
+ x0 = -b + sqrt(D);
+ x0 /= 2 * a;
+ float x0_1 = x0;
+ // left front
+ x = this->slot().bnodes().back()->x();
+ y = this->slot().bnodes().back()->y();
+ IR = BCAR_OUT_RADI;
+ a = 1;
+ b = -2 * x;
+ c = pow(x, 2) + pow(y - y0, 2) - pow(IR, 2);
+ D = pow(b, 2) - 4 * a * c;
+ if (this->slotSide() == LEFT)
+ x0 = -b + sqrt(D);
+ else
+ x0 = -b - sqrt(D);
+ x0 /= 2 * a;
+ float x0_2 = x0;
+ if (this->slotSide() == LEFT)
+ x0 = std::max(x0_1, x0_2);
+ else
+ x0 = std::min(x0_1, x0_2);
+ return new BicycleCar(x0, B->y(), B->h());
+}
+
bool ParallelSlot::isInside(BicycleCar *c)
{
bool inside = true;
std::vector<CircleObstacle>& co,
std::vector<SegmentObstacle>& so
);
+ void fipf(
+ std::vector<CircleObstacle>& co,
+ std::vector<SegmentObstacle>& so
+ ); // perpendicular forward parking
/** _Find Last Not Colliding_ BicycleCar pose
@param B Find from?
BicycleCar *getEPC();
/** Return start pose for fipr method */
BicycleCar *getFP();
+ BicycleCar *getFPf(); // parked forward, only for perpendicular
/** In slot perpendicular pose getter
This method returns a pose of perpendicular parking slot from
@param B The pose to start from.
*/
BicycleCar *getISPP(BicycleCar *B);
+ BicycleCar *getISPPf(BicycleCar *B); // perp. forward parking
/** Return true if car is inside slot */
bool isInside(BicycleCar *c);
/** Return values to set sampling function of RRT */