]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blob - incl/slotplanner.h
6703e944a5459f80a3f9a8aac19dc932fc37cd96
[hubacji1/iamcar.git] / incl / slotplanner.h
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 #ifndef SLOTPLANNER_H
19 #define SLOTPLANNER_H
20
21 #include <vector>
22 #include "bcar.h"
23 #include "obstacle.h"
24
25 #define EDIST(a, b) ({ __typeof__ (a) _a = (a); \
26                 __typeof__ (b) _b = (b); \
27                 pow(pow((_b)->x() - (_a)->x(), 2) + \
28                                 pow((_b)->y() - (_a)->y(), 2), 0.5); })
29
30 enum SlotType {
31         NONE,
32         PARALLEL,
33         PERPENDICULAR
34 };
35
36 class ParallelSlot {
37         private:
38                 float DH_ = 0.01;
39                 std::vector<std::vector<RRTNode *>> cusp_;
40                 PolygonObstacle slot_;
41                 SlotType slotType_;
42         public:
43                 ParallelSlot();
44
45                 // getter
46                 std::vector<std::vector<RRTNode *>> &cusp();
47                 float DH() const;
48                 PolygonObstacle &slot();
49                 SlotType slotType();
50
51                 // setter
52                 void DH(float dh);
53
54                 // other
55                 /** BFS to _Find Init Pose_. */
56                 void fip();
57                 /** _Find Last Not Colliding_ BicycleCar pose
58
59                 B -- Find from?
60                 */
61                 BicycleCar *flnc(BicycleCar *B);
62                 RRTNode *fposecenter();
63                 /** Recursive function to find out the moves */
64                 bool flast(
65                         RRTNode *P,
66                         bool right,
67                         int il,
68                         std::vector<RRTNode *> &cusp
69                 );
70                 /** Test possible init poses */
71                 void fpose();
72 };
73
74 #endif