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