2 * SPDX-FileCopyrightText: 2021 Jiri Vlasak <jiri.vlasak.2@cvut.cz>
4 * SPDX-License-Identifier: GPL-3.0-only
17 /*! \brief Parking slot basic class.
19 * This class contains some geometrical computations of parking slot. Parking
20 * slot consists of 4 cartesian coordinates `border` representing the border of
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;
35 std::vector<std::vector<BicycleCar>> _ispaths;
36 std::vector<BicycleCar> _entries;
37 std::vector<BicycleCar> _starts;
38 /*! \brief Set parking slot.
40 \param p Point with `x`, `y` coordinates of entry side's corner.
41 \param h Direction of the entry side.
42 \param W The width of the slot.
43 \param L The length of the slot.
45 ParkingSlot(Point p, double h, double W, double L);
46 ParkingSlot(double lrx, double lry, double rrx, double rry, double rfx,
47 double rfy, double lfx, double lfy);
49 /*! Get slot's length. */
52 /*! Get slot's width. */
55 /*! Get slot's left front x coordinate. */
58 /*! Get slot's left front y coordinate. */
61 /*! Get slot's left rear x coordinate. */
64 /*! Get slot's left rear y coordinate. */
67 /*! Get slot's right rear x coordinate. */
70 /*! Get slot's right rear y coordinate. */
73 /*! Get slot's right front x coordinate. */
76 /*! Get slot's right front y coordinate. */
79 /*! Return parking slot's orientation. */
82 /*! Get parking slot's left front point. */
85 /*! Get parking slot's left rear point. */
88 /*! Get parking slot's right rear point. */
91 /*! Get parking slot's right front point. */
94 /*! Get parking slot's entry side. */
97 /*! Get parking slot's rear side. */
100 /*! Get parking slot's curb side. */
103 /*! Get parking slot's front side. */
106 /*! Car's next iteration distance. (Negative for backward.) */
107 void set_parking_speed(double s);
109 /*! Maximum allowed number of cusp inside the parking slot. */
110 unsigned int get_max_cusp() const;
111 void set_max_cusp(unsigned int m);
113 /*! Angle's increment when creating start positions. */
114 void set_delta_angle_to_slot(double d);
116 /*! Return `true` for the parallel parking slot. */
117 bool parallel() const;
119 /*! Return `true` for the parking slot on the right side. */
122 /*! Change side of the parking slot. */
125 /*! Return `true` if car `c` is parking in slot `this`. */
126 bool parked(BicycleCar const& c) const;
128 /*! Return `true` if `c`'s car frame collide with `this` border. */
129 bool collide(BicycleCar const& c) const;
131 /*! \brief Set car `c` to the start position.
133 * \param c Bicycle car.
135 void set_to_start(BicycleCar& c);
137 /*! \brief Drive car `c` into the parking slot `this`.
139 * \param c Starting bicycle car.
141 std::vector<BicycleCar> drive_in_slot(BicycleCar c);
143 /*! \brief Drive car `c` from slot.
145 * \param c Starting bicycle car.
147 std::vector<BicycleCar> drive_of_slot(BicycleCar c);
149 /*! \brief Steer car `c` into the parking slot `this`.
151 * `steer_in_slot` returns the complete path as the list of `Pose`s, not
152 * just cusp `BicycleCar`s as `drive_to_slot`.
154 * \param c Starting bicycle car.
156 std::vector<Pose> steer_in_slot(BicycleCar c);
158 /*! \brief Find entry.
160 * \param c For which `BicycleCar` should entry be found?
162 PoseRange fe(BicycleCar c);
164 /*! \brief Compute entries from `this->_ispaths`.
166 * The problem with in-slot paths is that car can't leave the parking
167 * slot with full rate to the right (for right sided parking slot.)
169 * The idea is to move the first cars of in-slot paths (the one that is
170 * computed as entry to the parking slot) with the full rate to the left
171 * until they can leave the parking slot with full rate to the right.
173 * The computed cars are stored in `this->_entries`.
175 void compute_entries();
177 /*! \brief Recompute zero slot's `PoseRange` entry for `this`.
179 * The _zero slot_ is the `ParkingSlot(Point(0.0, 0.0), 0.0, W, L);`.
181 * \param p Computed `PoseRange` entry.
183 PoseRange recompute_entry(PoseRange p);
185 /*! Generate output for plotting with gnuplot. */
186 void gen_gnuplot_to(std::ostream& out);
188 friend std::ostream& operator<<(std::ostream& o, ParkingSlot const& s);
192 #endif /* BCAR_PSLOT_H */