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