]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blob - incl/slotplanner.h
Add pose heading method to SlotPlanner
[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                 float poseHeading_;
55         public:
56                 ParallelSlot();
57
58                 // getter
59                 /** Get slot entry point */
60                 std::vector<RRTNode *> &goals();
61                 RRTNode *getMidd();
62                 std::vector<std::vector<RRTNode *>> &cusp();
63                 float DH() const;
64                 PolygonObstacle &slot();
65                 float slotHeading();
66                 SlotSide slotSide();
67                 SlotType slotType();
68                 float poseHeading();
69
70                 // setter
71                 void DH(float dh);
72                 void setAll();
73
74                 // other
75                 /** BFS to _Find Init Pose_. */
76                 void fip(
77                         std::vector<CircleObstacle>& co,
78                         std::vector<SegmentObstacle>& so
79                 );
80                 void fipf(
81                         std::vector<CircleObstacle>& co,
82                         std::vector<SegmentObstacle>& so
83                 ); // perpendicular forward parking
84                 /** _Find Last Not Colliding_ BicycleCar pose
85
86                 @param B Find from?
87                 */
88                 BicycleCar *flnc(
89                         BicycleCar *B,
90                         std::vector<CircleObstacle>& co,
91                         std::vector<SegmentObstacle>& so
92                 );
93                 /** _Find Init Pose by Reverse_ approach, see Vorobieva2015
94
95                 @param B Last pose of vehicle when it is parked.
96                 */
97                 void fipr(RRTNode *n);
98                 void fipr(BicycleCar *B);
99                 /** _Find Last Not Colliding for Reverse_ BicycleCar pose
100
101                 @param B Find from?
102                 */
103                 BicycleCar *flncr(BicycleCar *B);
104                 RRTNode *fposecenter();
105                 /** Recursive function to find out the moves */
106                 bool flast(
107                         RRTNode *P,
108                         bool right,
109                         int il,
110                         std::vector<RRTNode *> &cusp
111                 );
112                 /** Test possible init poses */
113                 void fpose();
114                 /** Return start pose for fip method */
115                 BicycleCar *getEP();
116                 /** Return center of rotation for start pose for fip method */
117                 BicycleCar *getEPC();
118                 /** Return start pose for fipr method */
119                 BicycleCar *getFP();
120                 BicycleCar *getFPf(); // parked forward, only for perpendicular
121                 /** In slot perpendicular pose getter
122
123                 This method returns a pose of perpendicular parking slot from
124                 where it is possible to get out of the slot with full steer to
125                 farther corner side (i.e. right corner for the RIGHT side).
126
127                 @param B The pose to start from.
128                 */
129                 BicycleCar *getISPP(BicycleCar *B);
130                 BicycleCar *getISPPf(BicycleCar *B); // perp. forward parking
131                 /** Return true if car is inside slot */
132                 bool isInside(BicycleCar *c);
133                 /** Return values to set sampling function of RRT */
134                 struct SamplingInfo getSamplingInfo();
135 };
136
137 #endif