2 This file is part of I am car.
4 I am car is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 I am car is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with I am car. If not, see <http://www.gnu.org/licenses/>.
20 #include "slotplanner.h"
22 ParallelSlot::ParallelSlot()
26 std::vector<std::vector<RRTNode *>> &ParallelSlot::cusp()
31 float ParallelSlot::DH() const
36 PolygonObstacle &ParallelSlot::slot()
42 void ParallelSlot::DH(float dh)
48 RRTNode *ParallelSlot::fposecenter()
50 if (this->slot().bnodes().front()->y() >
51 this->slot().bnodes().back()->y())
52 return this->slot().bnodes().front();
54 return this->slot().bnodes().back();
57 bool ParallelSlot::flast(
61 std::vector<RRTNode *> &cusp
64 BicycleCar *B = new BicycleCar(P->x(), P->y(), P->h());
67 cc = BicycleCar(B->x(), B->y(), B->h()).ccr();
69 cc = BicycleCar(B->x(), B->y(), B->h()).ccl();
72 p = B->move(cc, i * this->DH());
73 while (!this->slot().collide(p->frame()) && p->x() <= 0) {
74 if (p->rfx() <= 0 && p->rrx() <= 0) {
80 p = B->move(cc, i * this->DH());
83 p = B->move(cc, (i - 1) * this->DH());
84 if (p->rfx() <= 0 && p->rrx() <= 0) {
89 return this->flast(p, !right, il + 1, cusp);
94 void ParallelSlot::fpose()
96 BicycleCar *CC = new BicycleCar(
97 this->fposecenter()->x(),
98 this->fposecenter()->y() - 0.01,
101 BicycleCar *B = new BicycleCar(
102 CC->x() + CC->width() / 2,
103 CC->y() - (CC->length() + CC->wheelbase()) / 2,
106 this->DH(0.01 / CC->out_radi());
109 p = B->move(CC, -i * 0.01 / CC->diag_radi());
110 while (!this->slot().collide(p->frame())) {
111 std::vector<RRTNode *> tmpcusp;
112 tmpcusp.push_back(new BicycleCar(p->x(), p->y(), p->h()));
113 if (this->flast(p, true, 0, tmpcusp)) {
114 this->cusp().push_back(tmpcusp);
118 p = B->move(CC, -i * 0.01 / CC->diag_radi());