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 /*! \brief Set parking slot.
39 \param p Point with `x`, `y` coordinates of entry side's corner.
40 \param h Direction of the entry side.
41 \param W The width of the slot.
42 \param L The length of the slot.
44 ParkingSlot(Point p, double h, double W, double L);
45 ParkingSlot(double lrx, double lry, double rrx, double rry, double rfx,
46 double rfy, double lfx, double lfy);
48 /*! Get slot's length. */
51 /*! Get slot's width. */
54 /*! Get slot's left front x coordinate. */
57 /*! Get slot's left front y coordinate. */
60 /*! Get slot's left rear x coordinate. */
63 /*! Get slot's left rear y coordinate. */
66 /*! Get slot's right rear x coordinate. */
69 /*! Get slot's right rear y coordinate. */
72 /*! Get slot's right front x coordinate. */
75 /*! Get slot's right front y coordinate. */
78 /*! Return parking slot's orientation. */
81 /*! Get parking slot's left front point. */
84 /*! Get parking slot's left rear point. */
87 /*! Get parking slot's right rear point. */
90 /*! Get parking slot's right front point. */
93 /*! Get parking slot's entry side. */
96 /*! Get parking slot's rear side. */
99 /*! Get parking slot's curb side. */
102 /*! Get parking slot's front side. */
105 /*! Car's next iteration distance. (Negative for backward.) */
106 void set_parking_speed(double s);
108 /*! Maximum allowed number of cusp inside the parking slot. */
109 unsigned int get_max_cusp() const;
110 void set_max_cusp(unsigned int m);
112 /*! Angle's increment when creating start positions. */
113 void set_delta_angle_to_slot(double d);
115 /*! Return `true` for the parallel parking slot. */
116 bool parallel() const;
118 /*! Return `true` for the parking slot on the right side. */
121 /*! Change side of the parking slot. */
124 /*! Return `true` if car `c` is parking in slot `this`. */
125 bool parked(BicycleCar const& c) const;
127 /*! Return `true` if `c`'s car frame collide with `this` border. */
128 bool collide(BicycleCar const& c) const;
130 /*! \brief Set car `c` to the start position.
132 * \param c Bicycle car.
134 void set_to_start(BicycleCar& c);
136 /*! \brief Drive car `c` into the parking slot `this`.
138 * \param c Starting bicycle car.
140 std::vector<BicycleCar> drive_in_slot(BicycleCar c);
142 /*! \brief Drive car `c` from slot.
144 * \param c Starting bicycle car.
146 std::vector<BicycleCar> drive_of_slot(BicycleCar c);
148 /*! \brief Steer car `c` into the parking slot `this`.
150 * `steer_in_slot` returns the complete path as the list of `Pose`s, not
151 * just cusp `BicycleCar`s as `drive_to_slot`.
153 * \param c Starting bicycle car.
155 std::vector<Pose> steer_in_slot(BicycleCar c);
157 /*! \brief Find entry.
159 * \param c For which `BicycleCar` should entry be found?
161 PoseRange fe(BicycleCar c);
163 /*! \brief Compute entries from `this->_ispaths`.
165 * The problem with in-slot paths is that car can't leave the parking
166 * slot with full rate to the right (for right sided parking slot.)
168 * The idea is to move the first cars of in-slot paths (the one that is
169 * computed as entry to the parking slot) with the full rate to the left
170 * until they can leave the parking slot with full rate to the right.
172 * The computed cars are stored in `this->_entries`.
174 void compute_entries();
176 /*! \brief Recompute zero slot's `PoseRange` entry for `this`.
178 * The _zero slot_ is the `ParkingSlot(Point(0.0, 0.0), 0.0, W, L);`.
180 * \param p Computed `PoseRange` entry.
182 PoseRange recompute_entry(PoseRange p);
184 /*! Generate output for plotting with gnuplot. */
185 void gen_gnuplot_to(std::ostream& out);
187 friend std::ostream& operator<<(std::ostream& o, ParkingSlot const& s);
191 #endif /* BCAR_PSLOT_H */