]> rtime.felk.cvut.cz Git - hubacji1/psp.git/blob - api/psp.h
Merge branch 'fix/perpendicular-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                 // find entry to slot by reverse approach
23                 void fe_parallel();
24                 void fe_perpendicular();
25                 void fer_parallel();
26                 void fer_perpendicular();
27         public:
28                 /*! \brief Return `true` if there is collision.
29
30                 If the parking slot `ps` collide with current car `cc`,
31                 return `true`.
32
33                 This method depends on `intersection` function that
34                 returns `true` or `false` if two line segments collide.
35                 Each line segment of current car `cc` (borders) is
36                 checked to each line segment of parking slot `ps`
37                 (parking slot lines).
38                 */
39                 bool collide();
40                 /*! \brief Return parking direction
41
42                 Return `true` if the direction of the parking in the
43                 slot is forward.
44                 */
45                 bool forward();
46                 /*! \brief Guess goal car
47
48                 Set the goal car guessed from the parking slot.
49                 */
50                 void guess_gc();
51                 /*! \brief Has current car `cc` left?
52
53                 Return `true` if the current car `cc` left the parking
54                 slot `ps`;
55                 */
56                 bool left();
57                 /*! \brief Is the goal car `gc` parked?
58
59                 Return `true` if the goal car `gc` is inside the
60                 parking slot `ps`.
61                 */
62                 bool parked();
63                 /*! \brief Return possible starts of parking maneuver
64
65                 When any `BicycleCar` of possible inits is reached, then
66                 parking maneuver is a peace of cake.
67
68                 \param cnt Number of inits.
69                 \param dist Distance between inits.
70                 */
71                 std::vector<BicycleCar> possible_inits(
72                         unsigned int cnt,
73                         double dist
74                 );
75                 std::vector<BicycleCar> possible_inits()
76                 {
77                         return this->possible_inits(10, 1);
78                 }
79
80                 // find entry
81                 /*! \brief Find entry to the parking slot.
82                 */
83                 void fe();
84                 /*! \brief Find entry to slot by reverse approach.
85
86                 See `Vorobieva2015` for more information.
87                 */
88                 void fer();
89
90                 // getters, setters
91                 BicycleCar &cc() { return this->cc_; }
92                 BicycleCar &gc() { return this->gc_; }
93                 ParkingSlot &ps() { return this->ps_; }
94
95                 PSPlanner();
96 };
97
98 #endif /* PSP_H */