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