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