]> rtime.felk.cvut.cz Git - hubacji1/psp.git/blob - api/psp.h
2294a5b3f4175539062ebee59cd01b86ecc634f4
[hubacji1/psp.git] / api / psp.h
1 #ifndef PSP_H
2 #define PSP_H
3
4 #include <tuple>
5 #include <vector>
6
7 #include "bcar.h"
8 #include "pslot.h"
9
10 #define FORWARD_PARKING 1
11
12 /*! \brief Parking Slot Planner basic class.
13
14 \param cc Current bicycle car.
15 \param ps Parking slot.
16 \param gc Goal car.
17 */
18 class PSPlanner {
19         private:
20                 BicycleCar cc_;
21                 BicycleCar gc_;
22                 ParkingSlot ps_;
23
24                 unsigned int c_ = 0; // number of cusps
25                 std::vector<BicycleCar> cusps_;
26
27                 // find entry to slot
28                 void fe_parallel();
29                 void fe_perpendicular();
30                 // find entry to slot by reverse approach
31                 void fer_parallel();
32                 void fer_perpendicular();
33                 // set goal car
34                 void gc_to_4();
35         public:
36                 /*! \brief Return `true` if there is collision.
37
38                 If the parking slot `ps` collide with current car `cc`,
39                 return `true`.
40
41                 This method depends on `intersection` function that
42                 returns `true` or `false` if two line segments collide.
43                 Each line segment of current car `cc` (borders) is
44                 checked to each line segment of parking slot `ps`
45                 (parking slot lines).
46                 */
47                 bool collide();
48                 /*! \brief Return parking direction
49
50                 Return `true` if the direction of the parking in the
51                 slot is forward.
52                 */
53                 bool forward();
54                 /*! \brief Guess goal car
55
56                 Set the goal car guessed from the parking slot.
57                 */
58                 void guess_gc();
59                 /*! \brief Return last maneuver to the parking slot.
60
61                 Return path from entry point towards parking slot, such
62                 that ``cc`` is inside the parking slot at the end.
63                 */
64                 std::vector<BicycleCar> last_maneuver();
65                 /*! \brief Has current car `cc` left?
66
67                 Return `true` if the current car `cc` left the parking
68                 slot `ps`;
69                 */
70                 bool left();
71                 /*! \brief Is the goal car `gc` parked?
72
73                 Return `true` if the goal car `gc` is inside the
74                 parking slot `ps`.
75                 */
76                 bool parked();
77                 /*! \brief Return possible starts of parking maneuver
78
79                 When any `BicycleCar` of possible inits is reached, then
80                 parking maneuver is a peace of cake.
81
82                 \param cnt Number of inits.
83                 \param dist Distance between inits.
84                 */
85                 std::vector<BicycleCar> possible_goals(
86                         unsigned int cnt,
87                         double dist
88                 );
89                 std::vector<BicycleCar> possible_goals()
90                 {
91                         return this->possible_goals(10, 0.5);
92                 }
93
94                 // find entry
95                 /*! \brief Find entry to the parking slot.
96                 */
97                 void fe();
98                 /*! \brief Find entry to slot by reverse approach.
99
100                 See `Vorobieva2015` for more information.
101                 */
102                 void fer();
103
104                 // getters, setters
105                 BicycleCar &cc() { return this->cc_; }
106                 BicycleCar &gc() { return this->gc_; }
107                 ParkingSlot &ps() { return this->ps_; }
108
109                 unsigned int c() const { return this->c_; }
110                 std::vector<BicycleCar> &cusps() { return this->cusps_; }
111
112                 PSPlanner();
113 };
114
115 #endif /* PSP_H */