]> rtime.felk.cvut.cz Git - hubacji1/psp.git/blob - api/psp.h
Add cusps array
[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 Has current car `cc` left?
58
59                 Return `true` if the current car `cc` left the parking
60                 slot `ps`;
61                 */
62                 bool left();
63                 /*! \brief Is the goal car `gc` parked?
64
65                 Return `true` if the goal car `gc` is inside the
66                 parking slot `ps`.
67                 */
68                 bool parked();
69                 /*! \brief Return possible starts of parking maneuver
70
71                 When any `BicycleCar` of possible inits is reached, then
72                 parking maneuver is a peace of cake.
73
74                 \param cnt Number of inits.
75                 \param dist Distance between inits.
76                 */
77                 std::vector<BicycleCar> possible_goals(
78                         unsigned int cnt,
79                         double dist
80                 );
81                 std::vector<BicycleCar> possible_goals()
82                 {
83                         return this->possible_goals(10, 1);
84                 }
85
86                 // find entry
87                 /*! \brief Find entry to the parking slot.
88                 */
89                 void fe();
90                 /*! \brief Find entry to slot by reverse approach.
91
92                 See `Vorobieva2015` for more information.
93                 */
94                 void fer();
95
96                 // getters, setters
97                 BicycleCar &cc() { return this->cc_; }
98                 BicycleCar &gc() { return this->gc_; }
99                 ParkingSlot &ps() { return this->ps_; }
100
101                 unsigned int c() const { return this->c_; }
102                 std::vector<BicycleCar> &cusps() { return this->cusps_; }
103
104                 PSPlanner();
105 };
106
107 #endif /* PSP_H */