]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/blob - incl/pslot.hh
655eb5e7e01c52feedec5d9664530710eb586803
[hubacji1/bcar.git] / incl / pslot.hh
1 /*! \file */
2 #ifndef BCAR_PSLOT_H
3 #define BCAR_PSLOT_H
4
5 #include <ostream>
6 #include <vector>
7 #include "bcar.hh"
8
9 namespace bcar {
10
11 /*! \brief Parking slot basic class.
12  *
13  * This class contains some geometrical computations of parking slot. Parking
14  * slot consists of 4 cartesian coordinates `border` representing the border of
15  * the parking slot.
16  */
17 class ParkingSlot {
18 private:
19         double offset_ = 0.001; // to avoid collision during init
20         double parking_speed_ = -0.1;
21         unsigned int max_cusp_ = 10;
22         double delta_angle_to_slot_ = 0.001;
23         Point border_[4];
24         Line entry_;
25         Line rear_;
26         Line curb_;
27         Line front_;
28 public:
29         /*! \brief Set parking slot.
30
31         \param p Point with `x`, `y` coordinates of entry side's corner.
32         \param h Direction of the entry side.
33         \param W The width of the slot.
34         \param L The length of the slot.
35         */
36         ParkingSlot(Point p, double h, double W, double L);
37         ParkingSlot(double lrx, double lry, double rrx, double rry, double rfx,
38                 double rfy, double lfx, double lfy);
39
40         /*! Get slot's length. */
41         double len() const;
42
43         /*! Get slot's width. */
44         double w() const;
45
46         /*! Get slot's left front x coordinate. */
47         double lfx() const;
48
49         /*! Get slot's left front y coordinate. */
50         double lfy() const;
51
52         /*! Get slot's left rear x coordinate. */
53         double lrx() const;
54
55         /*! Get slot's left rear y coordinate. */
56         double lry() const;
57
58         /*! Get slot's right rear x coordinate. */
59         double rrx() const;
60
61         /*! Get slot's right rear y coordinate. */
62         double rry() const;
63
64         /*! Get slot's right front x coordinate. */
65         double rfx() const;
66
67         /*! Get slot's right front y coordinate. */
68         double rfy() const;
69
70         /*! Return parking slot's orientation. */
71         double h() const;
72
73         /*! Get parking slot's left front point. */
74         Point lf() const;
75
76         /*! Get parking slot's left rear point. */
77         Point lr() const;
78
79         /*! Get parking slot's right rear point. */
80         Point rr() const;
81
82         /*! Get parking slot's right front point. */
83         Point rf() const;
84
85         /*! Get parking slot's entry side. */
86         Line entry() const;
87
88         /*! Get parking slot's rear side. */
89         Line rear() const;
90
91         /*! Get parking slot's curb side. */
92         Line curb() const;
93
94         /*! Get parking slot's front side. */
95         Line front() const;
96
97         /*! Car's next iteration distance. (Negative for backward.) */
98         void set_parking_speed(double s);
99
100         /*! Maximum allowed number of cusp inside the parking slot. */
101         void set_max_cusp(unsigned int m);
102
103         /*! Angle's increment when creating start positions. */
104         void set_delta_angle_to_slot(double d);
105
106         /*! Return `true` for the parallel parking slot. */
107         bool parallel() const;
108
109         /*! Return `true` for the parking slot on the right side. */
110         bool right() const;
111
112         /*! Change side of the parking slot. */
113         void swap_side();
114
115         /*! Return `true` if car `c` is parking in slot `this`. */
116         bool parked(BicycleCar const& c) const;
117
118         /*! Return `true` if `c`'s car frame collide with `this` border. */
119         bool collide(BicycleCar const& c) const;
120
121         /*! \brief Drive car `c` into the parking slot `this`.
122          *
123          * \param c Starting bicycle car.
124          */
125         std::vector<BicycleCar> drive_in_slot(BicycleCar c);
126
127         /*! \brief Steer car `c` into the parking slot `this`.
128          *
129          * `steer_in_slot` returns the complete path as the list of `Pose`s, not
130          * just cusp `BicycleCar`s as `drive_to_slot`.
131          *
132          * \param c Starting bicycle car.
133          */
134         std::vector<Pose> steer_in_slot(BicycleCar c);
135
136         /*! \brief Find entry.
137          *
138          * \param c For which `BicycleCar` should entry be found?
139          */
140         PoseRange fe(BicycleCar c);
141
142         /*! \brief Recompute zero slot's `PoseRange` entry for `this`.
143          *
144          * The _zero_ slot is the `ParkingSlot(Point(0.0, 0.0), 0.0, W, L);`.
145          *
146          * \param p Computed `PoseRange` entry.
147          */
148         PoseRange recompute_entry(PoseRange p);
149
150         friend std::ostream& operator<<(std::ostream& o, ParkingSlot const& s);
151 };
152
153 } // namespace bcar
154 #endif /* BCAR_PSLOT_H */