]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blob - incl/slotplanner.h
2704519f08473d7863e002f77bfe973d24888b07
[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 "aux.h"
23 #include "bcar.h"
24 #include "obstacle.h"
25
26 enum SlotSide {
27         LEFT,
28         RIGHT
29 };
30
31 enum SlotType {
32         PARALLEL,
33         PERPENDICULAR
34 };
35
36 struct SamplingInfo {
37         float x0;
38         float y0;
39         float h0;
40         float x;
41         float y;
42         float h;
43 };
44
45 class ParallelSlot {
46         private:
47                 float DH_ = 0.01;
48                 std::vector<std::vector<RRTNode *>> cusp_;
49                 std::vector<RRTNode *> goals_;
50                 PolygonObstacle slot_;
51                 float slotHeading_;
52                 SlotSide slotSide_;
53                 SlotType slotType_;
54         public:
55                 ParallelSlot();
56
57                 // getter
58                 /** Get slot entry point */
59                 std::vector<RRTNode *> &goals();
60                 RRTNode *getMidd();
61                 std::vector<std::vector<RRTNode *>> &cusp();
62                 float DH() const;
63                 PolygonObstacle &slot();
64                 float slotHeading();
65                 SlotSide slotSide();
66                 SlotType slotType();
67
68                 // setter
69                 void DH(float dh);
70                 void setAll();
71
72                 // other
73                 /** BFS to _Find Init Pose_. */
74                 void fip(
75                         std::vector<CircleObstacle>& co,
76                         std::vector<SegmentObstacle>& so
77                 );
78                 /** _Find Last Not Colliding_ BicycleCar pose
79
80                 @param B Find from?
81                 */
82                 BicycleCar *flnc(
83                         BicycleCar *B,
84                         std::vector<CircleObstacle>& co,
85                         std::vector<SegmentObstacle>& so
86                 );
87                 /** _Find Init Pose by Reverse_ approach, see Vorobieva2015
88
89                 @param B Last pose of vehicle when it is parked.
90                 */
91                 void fipr(RRTNode *n);
92                 void fipr(BicycleCar *B);
93                 /** _Find Last Not Colliding for Reverse_ BicycleCar pose
94
95                 @param B Find from?
96                 */
97                 BicycleCar *flncr(BicycleCar *B);
98                 RRTNode *fposecenter();
99                 /** Recursive function to find out the moves */
100                 bool flast(
101                         RRTNode *P,
102                         bool right,
103                         int il,
104                         std::vector<RRTNode *> &cusp
105                 );
106                 /** Test possible init poses */
107                 void fpose();
108                 /** Return start pose for fip method */
109                 BicycleCar *getEP();
110                 /** Return center of rotation for start pose for fip method */
111                 BicycleCar *getEPC();
112                 /** Return start pose for fipr method */
113                 BicycleCar *getFP();
114                 /** In slot perpendicular pose getter
115
116                 This method returns a pose of perpendicular parking slot from
117                 where it is possible to get out of the slot with full steer to
118                 farther corner side (i.e. right corner for the RIGHT side).
119
120                 @param B The pose to start from.
121                 */
122                 BicycleCar *getISPP(BicycleCar *B);
123                 /** Return true if car is inside slot */
124                 bool isInside(BicycleCar *c);
125                 /** Return values to set sampling function of RRT */
126                 struct SamplingInfo getSamplingInfo();
127 };
128
129 #endif