std::queue<BicycleCar *, std::list<BicycleCar *>> q;
std::queue<BicycleCar *, std::list<BicycleCar *>> empty;
int di = -1;
- // new pose for parallel parking to right slot
- float tnx;
- float tny;
- float nx;
- float ny;
- // temporary tnx is angle
- tnx = this->slotHeading() + M_PI;
- if (this->slotSide() == RIGHT)
- tnx -= M_PI / 4;
- else
- tnx += M_PI / 4;
- nx = this->fposecenter()->x() + 0.01 * cos(tnx);
- ny = this->fposecenter()->y() + 0.01 * sin(tnx);
- BicycleCar *CC = new BicycleCar(nx, ny, this->slotHeading());
- // move left by car width / 2
- tnx = CC->x() + CC->width() / 2 * cos(CC->h() + M_PI / 2);
- tny = CC->y() + CC->width() / 2 * sin(CC->h() + M_PI / 2);
- if (this->slotSide() == LEFT) {
+ if (this->slotSide() == LEFT)
di = 1;
- // move right by car width / 2
- tnx = CC->x() + CC->width() / 2 * cos(CC->h() - M_PI / 2);
- tny = CC->y() + CC->width() / 2 * sin(CC->h() - M_PI / 2);
- }
- // move down
- nx = tnx - (CC->length() + CC->wheelbase()) / 2 * cos(CC->h());
- ny = tny - (CC->length() + CC->wheelbase()) / 2 * sin(CC->h());
- BicycleCar *B = new BicycleCar(nx, ny, CC->h());
+ BicycleCar *CC = this->getEPC();
+ BicycleCar *B = this->getEP();
this->DH(di * 0.01 / CC->out_radi());
BicycleCar *c;
int i = 0;
}
}
+BicycleCar *ParallelSlot::getEP()
+{
+ // new pose for parallel parking to right slot
+ float tnx;
+ float tny;
+ float nx;
+ float ny;
+ BicycleCar *CC = this->getEPC();
+ // move left by car width / 2
+ tnx = CC->x() + CC->width() / 2 * cos(CC->h() + M_PI / 2);
+ tny = CC->y() + CC->width() / 2 * sin(CC->h() + M_PI / 2);
+ if (this->slotSide() == LEFT) {
+ // move right by car width / 2
+ tnx = CC->x() + CC->width() / 2 * cos(CC->h() - M_PI / 2);
+ tny = CC->y() + CC->width() / 2 * sin(CC->h() - M_PI / 2);
+ }
+ // move down
+ nx = tnx - (CC->length() + CC->wheelbase()) / 2 * cos(CC->h());
+ ny = tny - (CC->length() + CC->wheelbase()) / 2 * sin(CC->h());
+ return new BicycleCar(nx, ny, CC->h());
+}
+
+BicycleCar *ParallelSlot::getEPC()
+{
+ // new pose for parallel parking to right slot
+ float ta;
+ float nx;
+ float ny;
+ ta = this->slotHeading() + M_PI;
+ if (this->slotSide() == RIGHT)
+ ta -= M_PI / 4;
+ else
+ ta += M_PI / 4;
+ nx = this->fposecenter()->x() + 0.01 * cos(ta);
+ ny = this->fposecenter()->y() + 0.01 * sin(ta);
+ return new BicycleCar(nx, ny, this->slotHeading());
+}
+
BicycleCar *ParallelSlot::getFP()
{
float x = this->slot().bnodes()[3]->x();