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 /*! \brief Set parking slot.
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.
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);
46 /*! Get slot's length. */
49 /*! Get slot's width. */
52 /*! Get slot's left front x coordinate. */
55 /*! Get slot's left front y coordinate. */
58 /*! Get slot's left rear x coordinate. */
61 /*! Get slot's left rear y coordinate. */
64 /*! Get slot's right rear x coordinate. */
67 /*! Get slot's right rear y coordinate. */
70 /*! Get slot's right front x coordinate. */
73 /*! Get slot's right front y coordinate. */
76 /*! Return parking slot's orientation. */
79 /*! Get parking slot's left front point. */
82 /*! Get parking slot's left rear point. */
85 /*! Get parking slot's right rear point. */
88 /*! Get parking slot's right front point. */
91 /*! Get parking slot's entry side. */
94 /*! Get parking slot's rear side. */
97 /*! Get parking slot's curb side. */
100 /*! Get parking slot's front side. */
103 /*! Car's next iteration distance. (Negative for backward.) */
104 void set_parking_speed(double s);
106 /*! Maximum allowed number of cusp inside the parking slot. */
107 unsigned int get_max_cusp() const;
108 void set_max_cusp(unsigned int m);
110 /*! Angle's increment when creating start positions. */
111 void set_delta_angle_to_slot(double d);
113 /*! Return `true` for the parallel parking slot. */
114 bool parallel() const;
116 /*! Return `true` for the parking slot on the right side. */
119 /*! Change side of the parking slot. */
122 /*! Return `true` if car `c` is parking in slot `this`. */
123 bool parked(BicycleCar const& c) const;
125 /*! Return `true` if `c`'s car frame collide with `this` border. */
126 bool collide(BicycleCar const& c) const;
128 /*! \brief Drive car `c` into the parking slot `this`.
130 * \param c Starting bicycle car.
132 std::vector<BicycleCar> drive_in_slot(BicycleCar c);
134 /*! \brief Drive car `c` from slot.
136 * \param c Starting bicycle car.
138 std::vector<BicycleCar> drive_of_slot(BicycleCar c);
140 /*! \brief Steer car `c` into the parking slot `this`.
142 * `steer_in_slot` returns the complete path as the list of `Pose`s, not
143 * just cusp `BicycleCar`s as `drive_to_slot`.
145 * \param c Starting bicycle car.
147 std::vector<Pose> steer_in_slot(BicycleCar c);
149 /*! \brief Find entry.
151 * \param c For which `BicycleCar` should entry be found?
153 PoseRange fe(BicycleCar c);
155 /*! \brief Recompute zero slot's `PoseRange` entry for `this`.
157 * The _zero_ slot is the `ParkingSlot(Point(0.0, 0.0), 0.0, W, L);`.
159 * \param p Computed `PoseRange` entry.
161 PoseRange recompute_entry(PoseRange p);
163 friend std::ostream& operator<<(std::ostream& o, ParkingSlot const& s);
167 #endif /* BCAR_PSLOT_H */