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