]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blob - incl/slotplanner.h
Update is inside slot check
[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 SlotSide {
31         LEFT,
32         RIGHT
33 };
34
35 enum SlotType {
36         PARALLEL,
37         PERPENDICULAR
38 };
39
40 struct SamplingInfo {
41         float x;
42         float y;
43         float r;
44         float h;
45 };
46
47 class ParallelSlot {
48         private:
49                 float DH_ = 0.01;
50                 std::vector<std::vector<RRTNode *>> cusp_;
51                 PolygonObstacle slot_;
52                 SlotSide slotSide_;
53                 SlotType slotType_;
54         public:
55                 ParallelSlot();
56
57                 // getter
58                 std::vector<std::vector<RRTNode *>> &cusp();
59                 float DH() const;
60                 PolygonObstacle &slot();
61                 float slotHeading();
62                 SlotSide slotSide();
63                 SlotType slotType();
64
65                 // setter
66                 void DH(float dh);
67
68                 // other
69                 /** BFS to _Find Init Pose_. */
70                 void fip();
71                 /** _Find Init Pose by Reverse_ approach, see Vorobieva2015
72
73                 @param B Last pose of vehicle when it is parked.
74                 */
75                 void fipr(BicycleCar *B);
76                 /** _Find Last Not Colliding for Reverse_ BicycleCar pose
77
78                 @param B Find from?
79                 */
80                 BicycleCar *flncr(BicycleCar *B);
81                 /** _Find Last Not Colliding_ BicycleCar pose
82
83                 @param B Find from?
84                 */
85                 BicycleCar *flnc(BicycleCar *B);
86                 RRTNode *fposecenter();
87                 /** Recursive function to find out the moves */
88                 bool flast(
89                         RRTNode *P,
90                         bool right,
91                         int il,
92                         std::vector<RRTNode *> &cusp
93                 );
94                 /** Test possible init poses */
95                 void fpose();
96                 /** Return true if car is inside slot */
97                 bool isInside(BicycleCar *c);
98                 /** Return values to set sampling function of RRT */
99                 struct SamplingInfo getSamplingInfo();
100 };
101
102 #endif