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