]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blob - decision_control/slotplanner.cc
Add init pose for forward perpendicular parking
[hubacji1/iamcar.git] / decision_control / slotplanner.cc
1 /*
2 This file is part of I am car.
3
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.
8
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.
13
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/>.
16 */
17
18 #include <algorithm>
19 #include <cmath>
20 #include <list>
21 #include <queue>
22 #include "slotplanner.h"
23
24 ParallelSlot::ParallelSlot()
25 {}
26
27 // getter
28 std::vector<RRTNode *> &ParallelSlot::goals()
29 {
30         return this->goals_;
31 }
32
33 RRTNode *ParallelSlot::getMidd()
34 {
35         if (this->cusp().size() > 0)
36                 return this->cusp().front().front();
37         else
38                 return nullptr;
39 }
40
41 std::vector<std::vector<RRTNode *>> &ParallelSlot::cusp()
42 {
43         return this->cusp_;
44 }
45
46 float ParallelSlot::DH() const
47 {
48         return this->DH_;
49 }
50
51 PolygonObstacle &ParallelSlot::slot()
52 {
53         return this->slot_;
54 }
55
56 float ParallelSlot::slotHeading()
57 {
58         return this->slotHeading_;
59 }
60
61 SlotSide ParallelSlot::slotSide()
62 {
63         return this->slotSide_;
64 }
65
66 SlotType ParallelSlot::slotType()
67 {
68         return this->slotType_;
69 }
70
71 // setter
72 void ParallelSlot::DH(float dh)
73 {
74         this->DH_ = dh;
75 }
76
77 void ParallelSlot::setAll()
78 {
79         // slot heading
80         float y0 = this->slot().bnodes()[0]->y();
81         float x0 = this->slot().bnodes()[0]->x();
82         float y3 = this->slot().bnodes()[3]->y();
83         float x3 = this->slot().bnodes()[3]->x();
84         float dy = y3 - y0;
85         float dx = x3 - x0;
86         this->slotHeading_ = atan2(dy, dx);
87         // slot side
88         float y1 = this->slot().bnodes()[1]->y();
89         float x1 = this->slot().bnodes()[1]->x();
90         if (sgn((x1 - x0) * (y3 - y0) - (y1 - y0) * (x3 - x0)) < 0)
91                 this->slotSide_ = LEFT;
92         else
93                 this->slotSide_ = RIGHT;
94         // slot type
95         float d1 = EDIST(
96                 this->slot().bnodes()[0],
97                 this->slot().bnodes()[1]
98         );
99         float d2 = EDIST(
100                 this->slot().bnodes()[1],
101                 this->slot().bnodes()[2]
102         );
103         if (d1 > d2)
104                 this->slotType_ = PERPENDICULAR;
105         else
106                 this->slotType_ = PARALLEL;
107 }
108
109 // other
110 void ParallelSlot::fip(
111         std::vector<CircleObstacle>& co,
112         std::vector<SegmentObstacle>& so
113 )
114 {
115         this->setAll();
116         if (this->slotType() == PERPENDICULAR) {
117                 std::vector<RRTNode *> tmpc;
118                 BicycleCar *tmpf = this->getFP();
119                 BicycleCar *tmpb = this->getISPP(tmpf);
120                 RRTNode *cc;
121                 if (this->slotSide() == LEFT)
122                         cc = tmpb->ccl();
123                 else
124                         cc = tmpb->ccr();
125                 if (this->slotSide() == LEFT)
126                         this->DH(1 * 0.5 / tmpb->out_radi());
127                 else
128                         this->DH(-1 * 0.5 / tmpb->out_radi());
129                 BicycleCar *p;
130                 int i = 1;
131                 p = tmpb->move(cc, i * this->DH());
132                 while (
133                         !this->slot().collide(p->frame())
134                         && ((
135                                 this->slotSide() == LEFT
136                                 && p->h() < this->slotHeading()
137                         ) || (
138                                 this->slotSide() == RIGHT
139                                 && p->h() > this->slotHeading()
140                         ))
141                 ) {
142                         bool end = false;
143                         std::vector<RRTEdge *> eds = p->frame();
144                         for (auto o: co)
145                                 if (o.collide(eds))
146                                         end = true;
147                         for (auto o: so)
148                                 if (o.collide(eds))
149                                         end = true;
150                         for (auto e: eds)
151                                 delete e;
152                         if (end)
153                                 break;
154                         this->goals_.push_back(p);
155                         tmpc.push_back(p);
156                         i += 1;
157                         p = tmpb->move(cc, i * this->DH());
158                 }
159                 if (tmpc.size() > 0)
160                         this->cusp().push_back(tmpc);
161                 return;
162         }
163         // see https://courses.cs.washington.edu/courses/cse326/03su/homework/hw3/bfs.html
164         // RRTNode.s() works as iteration level
165         std::queue<BicycleCar *, std::list<BicycleCar *>> q;
166         std::queue<BicycleCar *, std::list<BicycleCar *>> empty;
167         int di = -1;
168         if (this->slotSide() == LEFT)
169                 di = 1;
170         BicycleCar *CC = this->getEPC();
171         BicycleCar *B = this->getEP();
172         this->DH(di * 0.01 / CC->out_radi());
173         BicycleCar *c;
174         int i = 0;
175         c = B->move(CC, -i * di * 0.01 / CC->diag_radi());
176         while (!this->slot().collide(c->frame())) {
177                 bool end = false;
178                 std::vector<RRTEdge *> eds = c->frame();
179                 for (auto o: co)
180                         if (o.collide(eds))
181                                 end = true;
182                 for (auto o: so)
183                         if (o.collide(eds))
184                                 end = true;
185                 for (auto e: eds)
186                         delete e;
187                 if (!end)
188                         q.push(c);
189                 c = B->move(CC, -i * di * 0.01 / CC->diag_radi());
190                 i += 1;
191         }
192         delete c; // not in q and collide
193         while (!q.empty()) {
194                 c = q.front();
195                 q.pop();
196                 if (this->isInside(c)) {
197                         goto createcuspandfinish;
198                 } else if (c->s() < 9) {
199                         BicycleCar *cc = this->flnc(c, co, so);
200                         cc->s(c->s() + 1);
201                         cc->bcparent(c);
202                         q.push(cc);
203                 } else {
204                         delete c; // not in q and collide
205                 }
206         }
207         std::swap(q, empty);
208         return;
209 createcuspandfinish:
210         std::vector<RRTNode *> cusp;
211         while (c) {
212                 cusp.push_back(new RRTNode(c->x(), c->y(), c->h()));
213                 c = c->bcparent();
214         }
215         std::reverse(cusp.begin(), cusp.end());
216         this->cusp().push_back(cusp);
217         std::swap(q, empty);
218 }
219
220 BicycleCar *ParallelSlot::flnc(
221         BicycleCar *B,
222         std::vector<CircleObstacle>& co,
223         std::vector<SegmentObstacle>& so
224 )
225 {
226         RRTNode *cc;
227         if (this->slotSide() == LEFT) {
228                 if (int(B->s()) % 2 == 0)
229                         cc = BicycleCar(B->x(), B->y(), B->h()).ccr();
230                 else
231                         cc = BicycleCar(B->x(), B->y(), B->h()).ccl();
232         } else {
233                 if (int(B->s()) % 2 == 0)
234                         cc = BicycleCar(B->x(), B->y(), B->h()).ccl();
235                 else
236                         cc = BicycleCar(B->x(), B->y(), B->h()).ccr();
237         }
238         BicycleCar *p;
239         int i = 1;
240         p = B->move(cc, i * this->DH());
241         while (
242                 !this->slot().collide(p->frame())
243                 && std::abs(this->slotHeading() - p->h()) < M_PI / 2
244         ) {
245                 delete p;
246                 i += 10;
247                 p = B->move(cc, i * this->DH());
248                 bool end = false;
249                 std::vector<RRTEdge *> eds = p->frame();
250                 for (auto o: co)
251                         if (o.collide(eds))
252                                 end = true;
253                 for (auto o: so)
254                         if (o.collide(eds))
255                                 end = true;
256                 for (auto e: eds)
257                         delete e;
258                 if (end)
259                         break;
260         }
261         i -= 10;
262         p = B->move(cc, i * this->DH());
263         while (
264                 !this->slot().collide(p->frame())
265                 && std::abs(this->slotHeading() - p->h()) < M_PI / 2
266         ) {
267                 if (this->isInside(p)) {
268                         i += 1;
269                         break;
270                 }
271                 delete p;
272                 i += 1;
273                 p = B->move(cc, i * this->DH());
274                 bool end = false;
275                 std::vector<RRTEdge *> eds = p->frame();
276                 for (auto o: co)
277                         if (o.collide(eds))
278                                 end = true;
279                 for (auto o: so)
280                         if (o.collide(eds))
281                                 end = true;
282                 for (auto e: eds)
283                         delete e;
284                 if (end)
285                         break;
286         }
287         delete p;
288         return B->move(cc, (i - 1) * this->DH());
289 }
290
291 void ParallelSlot::fipr(RRTNode *n)
292 {
293         return this->fipr(new BicycleCar(n->x(), n->y(), n->h()));
294 }
295
296 void ParallelSlot::fipr(BicycleCar *B)
297 {
298         std::vector<RRTNode *> cusp;
299         cusp.push_back(new RRTNode(B->x(), B->y(), B->h()));
300         int di = 1;
301         if (this->slotSide() == LEFT)
302                 di = -1;
303         if (this->slotType() == PERPENDICULAR) {
304                 this->DH(di * 0.01 / B->out_radi()); // TODO car in slot h()
305                 RRTNode *cc;
306                 if (this->slotSide() == LEFT)
307                         cc = BicycleCar(B->x(), B->y(), B->h()).ccl();
308                 else
309                         cc = BicycleCar(B->x(), B->y(), B->h()).ccr();
310                 BicycleCar *p;
311                 int i = 1;
312                 p = B->move(cc, i * this->DH());
313                 while (
314                         !this->slot().collide(p->frame())
315                         && this->slot().collide(p)
316                 ) {
317                         delete p;
318                         i += 10;
319                         p = B->move(cc, i * this->DH());
320                 }
321                 i -= 10;
322                 p = B->move(cc, i * this->DH());
323                 while (
324                         !this->slot().collide(p->frame())
325                         && this->slot().collide(p)
326                 ) {
327                         delete p;
328                         i += 1;
329                         p = B->move(cc, i * this->DH());
330                 }
331                 i -= 1;
332                 p = B->move(cc, i * this->DH());
333                 cusp.push_back(new RRTNode(p->x(), p->y(), p->h()));
334                 std::reverse(cusp.begin(), cusp.end());
335                 this->cusp().push_back(cusp);
336                 return;
337         }
338         this->DH(di * 0.01 / B->out_radi());
339         BicycleCar *c;
340         c = this->flncr(B);
341         c->s(B->s() + 1);
342         while ((
343                 this->slotSide() == LEFT
344                 && this->slot().collide(new RRTNode(c->lfx(), c->lfy(), 0))
345         ) || (
346                 this->slotSide() == RIGHT
347                 && this->slot().collide(new RRTNode(c->rfx(), c->rfy(), 0))
348         )) {
349                 cusp.push_back(new RRTNode(c->x(), c->y(), c->h()));
350                 BicycleCar *cc = this->flncr(c);
351                 cc->s(c->s() + 1);
352                 delete c;
353                 c = cc;
354         }
355         cusp.push_back(new RRTNode(c->x(), c->y(), c->h()));
356         std::reverse(cusp.begin(), cusp.end());
357         this->cusp().push_back(cusp);
358 }
359
360 BicycleCar *ParallelSlot::flncr(BicycleCar *B)
361 {
362         RRTNode *cc;
363         if (this->slotSide() == LEFT) {
364                 if (int(B->s()) % 2 == 0)
365                         cc = BicycleCar(B->x(), B->y(), B->h()).ccr();
366                 else
367                         cc = BicycleCar(B->x(), B->y(), B->h()).ccl();
368         } else {
369                 if (int(B->s()) % 2 == 0)
370                         cc = BicycleCar(B->x(), B->y(), B->h()).ccl();
371                 else
372                         cc = BicycleCar(B->x(), B->y(), B->h()).ccr();
373         }
374         BicycleCar *p;
375         int i = 1;
376         p = B->move(cc, i * this->DH());
377         while (
378                 !this->slot().collide(p->frame())
379                 && ((
380                         this->slotSide() == LEFT
381                         && this->slot().collide(new RRTNode(
382                                 p->lfx(),
383                                 p->lfy(),
384                                 0
385                         ))
386                 ) || (
387                         this->slotSide() == RIGHT
388                         && this->slot().collide(new RRTNode(
389                                 p->rfx(),
390                                 p->rfy(),
391                                 0
392                         ))
393                 ))
394         ) {
395                 delete p;
396                 i += 10;
397                 p = B->move(cc, i * this->DH());
398         }
399         i -= 10;
400         p = B->move(cc, i * this->DH());
401         while (!this->slot().collide(p->frame())) {
402                 if(
403                         this->slotSide() == LEFT
404                         && !this->slot().collide(new RRTNode(
405                                 p->lfx(),
406                                 p->lfy(),
407                                 0
408                         ))
409                 ) {
410                         i += 1;
411                         break;
412                 }
413                 if(
414                         this->slotSide() == RIGHT
415                         && !this->slot().collide(new RRTNode(
416                                 p->rfx(),
417                                 p->rfy(),
418                                 0
419                         ))
420                 ) {
421                         i += 1;
422                         break;
423                 }
424                 i += 1;
425                 p = B->move(cc, i * this->DH());
426         }
427         delete p;
428         return B->move(cc, (i - 1) * this->DH());
429 }
430
431 RRTNode *ParallelSlot::fposecenter()
432 {
433         return this->slot().bnodes().back();
434 }
435
436 bool ParallelSlot::flast(
437         RRTNode *P,
438         bool right,
439         int il,
440         std::vector<RRTNode *> &cusp
441 )
442 {
443         BicycleCar *B = new BicycleCar(P->x(), P->y(), P->h());
444         RRTNode *cc;
445         if (right)
446                 cc = BicycleCar(B->x(), B->y(), B->h()).ccr();
447         else
448                 cc = BicycleCar(B->x(), B->y(), B->h()).ccl();
449         BicycleCar *p;
450         int i = 1;
451         p = B->move(cc, i * this->DH());
452         while (!this->slot().collide(p->frame())
453                         && (
454                                 (this->DH() > 0 && p->x() <= 0)
455                                 || (this->DH() < 0 && p->x() >= 0)
456                         )) {
457                 delete p;
458                 i += 10;
459                 p = B->move(cc, i * this->DH());
460         }
461         i -= 10;
462         p = B->move(cc, i * this->DH());
463         while (!this->slot().collide(p->frame())
464                         && (
465                                 (this->DH() > 0 && p->x() <= 0)
466                                 || (this->DH() < 0 && p->x() >= 0)
467                         )) {
468                 if (this->DH() > 0 && p->rfx() <= 0 && p->rrx() <= 0) {
469                         i += 1;
470                         break;
471                 }
472                 if (this->DH() < 0 && p->lfx() >= 0 && p->lrx() >= 0) {
473                         i += 1;
474                         break;
475                 }
476                 delete p;
477                 i += 1;
478                 p = B->move(cc, i * this->DH());
479         }
480         delete p;
481         p = B->move(cc, (i - 1) * this->DH());
482         if (this->DH() > 0 && p->rfx() <= 0 && p->rrx() <= 0) {
483                 cusp.push_back(p);
484                 return true;
485         } else if (this->DH() < 0 && p->lfx() >= 0 && p->lrx() >= 0) {
486                 cusp.push_back(p);
487                 return true;
488         } else if (il < 8) {
489                 cusp.push_back(p);
490                 return this->flast(p, !right, il + 1, cusp);
491         }
492         return false;
493 }
494
495 void ParallelSlot::fpose()
496 {
497         bool left = false; // right parking slot
498         float di = -1;
499         BicycleCar *CC = new BicycleCar(
500                 this->fposecenter()->x(),
501                 this->fposecenter()->y() - 0.01,
502                 this->slotHeading()
503         );
504         BicycleCar *B = new BicycleCar(
505                 CC->x() - CC->width() / 2,
506                 CC->y() - (CC->length() + CC->wheelbase()) / 2,
507                 this->slotHeading()
508         );
509         if (this->slot().bnodes()[0]->x() > this->slot().bnodes()[1]->x()) {
510                 left = true;
511                 di = 1;
512                 delete B;
513                 B = new BicycleCar(
514                         CC->x() + CC->width() / 2,
515                         CC->y() - (CC->length() + CC->wheelbase()) / 2,
516                         this->slotHeading()
517                 );
518         }
519         this->DH(di * 0.01 / CC->out_radi());
520         BicycleCar *p;
521         int i = 0;
522         p = B->move(CC, -i * di * 0.01 / CC->diag_radi());
523         while (!this->slot().collide(p->frame())) {
524                 std::vector<RRTNode *> tmpcusp;
525                 tmpcusp.push_back(new BicycleCar(p->x(), p->y(), p->h()));
526                 if (this->flast(p, left, 0, tmpcusp)) {
527                         this->cusp().push_back(tmpcusp);
528                         return;
529                 }
530                 i += 1;
531                 delete p;
532                 p = B->move(CC, -i * di * 0.01 / CC->diag_radi());
533         }
534 }
535
536 BicycleCar *ParallelSlot::getEP()
537 {
538         // new pose for parallel parking to right slot
539         float tnx;
540         float tny;
541         float nx;
542         float ny;
543         BicycleCar *CC = this->getEPC();
544         // move left by car width / 2
545         tnx = CC->x() + CC->width() / 2 * cos(CC->h() + M_PI / 2);
546         tny = CC->y() + CC->width() / 2 * sin(CC->h() + M_PI / 2);
547         if (this->slotSide() == LEFT) {
548                 // move right by car width / 2
549                 tnx = CC->x() + CC->width() / 2 * cos(CC->h() - M_PI / 2);
550                 tny = CC->y() + CC->width() / 2 * sin(CC->h() - M_PI / 2);
551         }
552         if (this->slotType() == PARALLEL) {
553                 // move down
554                 nx = tnx - (CC->length() + CC->wheelbase()) / 2 * cos(CC->h());
555                 ny = tny - (CC->length() + CC->wheelbase()) / 2 * sin(CC->h());
556         } else {
557                 // move down
558                 nx = tnx + (CC->length() - CC->wheelbase()) / 2 * cos(CC->h());
559                 ny = tny + (CC->length() - CC->wheelbase()) / 2 * sin(CC->h());
560         }
561         return new BicycleCar(nx, ny, CC->h());
562 }
563
564 BicycleCar *ParallelSlot::getEPC()
565 {
566         // new pose for parallel parking to right slot
567         float ta;
568         float nx;
569         float ny;
570         ta = this->slotHeading() + M_PI;
571         if (this->slotSide() == RIGHT)
572                 ta -= M_PI / 4;
573         else
574                 ta += M_PI / 4;
575         nx = this->fposecenter()->x() + 0.01 * cos(ta);
576         ny = this->fposecenter()->y() + 0.01 * sin(ta);
577         return new BicycleCar(nx, ny, this->slotHeading());
578 }
579
580 BicycleCar *ParallelSlot::getFP()
581 {
582         this->setAll();
583         float x = this->slot().bnodes()[0]->x();
584         float y = this->slot().bnodes()[0]->y();
585         float h = this->slotHeading();
586         float nx;
587         float ny;
588         if (this->slotType() == PARALLEL) {
589                 if (this->slotSide() == LEFT) {
590                         nx = x + BCAR_WIDTH / 2 * cos(h + M_PI / 2);
591                         ny = y + BCAR_WIDTH / 2 * sin(h + M_PI / 2);
592                 } else {
593                         nx = x + BCAR_WIDTH / 2 * cos(h - M_PI / 2);
594                         ny = y + BCAR_WIDTH / 2 * sin(h - M_PI / 2);
595                 }
596                 x = nx + ((BCAR_LENGTH - BCAR_WHEEL_BASE) / 2 + 0.01) * cos(h);
597                 y = ny + ((BCAR_LENGTH - BCAR_WHEEL_BASE) / 2 + 0.01) * sin(h);
598         } else {
599                 if (this->slotSide() == LEFT) {
600                         h -= M_PI / 2;
601                         nx = x + (BCAR_LENGTH + BCAR_WHEEL_BASE) / 2
602                                 * cos(h + M_PI);
603                         ny = y + (BCAR_LENGTH + BCAR_WHEEL_BASE) / 2
604                                 * sin(h + M_PI);
605                         x = nx + (BCAR_DIAG_RRADI) * cos(h + M_PI / 2);
606                         y = ny + (BCAR_DIAG_RRADI) * sin(h + M_PI / 2);
607                 } else {
608                         h += M_PI / 2;
609                         nx = x + (BCAR_LENGTH + BCAR_WHEEL_BASE) / 2
610                                 * cos(h - M_PI);
611                         ny = y + (BCAR_LENGTH + BCAR_WHEEL_BASE) / 2
612                                 * sin(h - M_PI);
613                         x = nx + (BCAR_DIAG_RRADI) * cos(h - M_PI / 2);
614                         y = ny + (BCAR_DIAG_RRADI) * sin(h - M_PI / 2);
615                 }
616         }
617         return new BicycleCar(x, y, h);
618 }
619
620 BicycleCar *ParallelSlot::getISPP(BicycleCar *B)
621 {
622         float x = this->slot().bnodes().back()->x();
623         float y = this->slot().bnodes().back()->y();
624         float y0;
625         if (this->slotSide() == LEFT) // TODO only for backward parking now
626                 y0 = B->ccl()->y();
627         else
628                 y0 = B->ccr()->y();
629         float IR = BCAR_IN_RADI;
630         float a = 1;
631         float b = -2 * x;
632         float c = pow(x, 2) + pow(y - y0, 2) - pow(IR, 2);
633         float D = pow(b, 2) - 4 * a * c;
634         float x0;
635         if (this->slotSide() == LEFT)
636                 x0 = -b - sqrt(D);
637         else
638                 x0 = -b + sqrt(D);
639         x0 /= 2 * a;
640         return new BicycleCar(x0, B->y(), B->h());
641 }
642
643 BicycleCar *ParallelSlot::getFPf()
644 {
645         this->setAll();
646         float x = this->slot().bnodes().front()->x();
647         float y = this->slot().bnodes().front()->y();
648         float h = this->slotHeading();
649         float nx;
650         float ny;
651         if (this->slotSide() == LEFT) {
652                 h += M_PI / 2;
653                 nx = x + (BCAR_LENGTH - BCAR_WHEEL_BASE) / 2
654                         * cos(h);
655                 ny = y + (BCAR_LENGTH - BCAR_WHEEL_BASE) / 2
656                         * sin(h);
657                 x = nx + (BCAR_DIAG_RRADI) * cos(h - M_PI / 2);
658                 y = ny + (BCAR_DIAG_RRADI) * sin(h - M_PI / 2);
659         } else {
660                 h -= M_PI / 2;
661                 nx = x + (BCAR_LENGTH - BCAR_WHEEL_BASE) / 2
662                         * cos(h);
663                 ny = y + (BCAR_LENGTH - BCAR_WHEEL_BASE) / 2
664                         * sin(h);
665                 x = nx + (BCAR_DIAG_RRADI) * cos(h + M_PI / 2);
666                 y = ny + (BCAR_DIAG_RRADI) * sin(h + M_PI / 2);
667         }
668         return new BicycleCar(x, y, h);
669 }
670
671 bool ParallelSlot::isInside(BicycleCar *c)
672 {
673         bool inside = true;
674         RRTNode *tmpn;
675         tmpn = new RRTNode(c->lfx(), c->lfy(), 0);
676         if (!this->slot().collide(tmpn))
677                 inside = false;
678         delete tmpn;
679         tmpn = new RRTNode(c->lrx(), c->lry(), 0);
680         if (!this->slot().collide(tmpn))
681                 inside = false;
682         delete tmpn;
683         tmpn = new RRTNode(c->rrx(), c->rry(), 0);
684         if (!this->slot().collide(tmpn))
685                 inside = false;
686         delete tmpn;
687         tmpn = new RRTNode(c->rfx(), c->rfy(), 0);
688         if (!this->slot().collide(tmpn))
689                 inside = false;
690         delete tmpn;
691         return inside;
692 }
693
694 struct SamplingInfo ParallelSlot::getSamplingInfo()
695 {
696         struct SamplingInfo si;
697         RRTNode *n = this->getMidd();
698         if (this->slotType() == PARALLEL) {
699                 if (n != nullptr) {
700                         si.x0 = n->x() + 1.5 * BCAR_LENGTH * cos(n->h());
701                         si.y0 = n->y() + 1.5 * BCAR_LENGTH * sin(n->h());
702                         si.h0 = n->h();
703                 } else {
704                         si.x0 = this->slot().bnodes().front()->x();
705                         si.y0 = this->slot().bnodes().front()->y();
706                         si.h0 = this->slotHeading();
707                 }
708                 si.x = BCAR_WIDTH;
709                 si.y = BCAR_WIDTH;
710                 si.h = M_PI / 8;
711         } else {
712                 // TODO
713         }
714         return si;
715 }