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>> _entries;
36 /*! \brief Set parking slot.
38 \param p Point with `x`, `y` coordinates of entry side's corner.
39 \param h Direction of the entry side.
40 \param W The width of the slot.
41 \param L The length of the slot.
43 ParkingSlot(Point p, double h, double W, double L);
44 ParkingSlot(double lrx, double lry, double rrx, double rry, double rfx,
45 double rfy, double lfx, double lfy);
47 /*! Get slot's length. */
50 /*! Get slot's width. */
53 /*! Get slot's left front x coordinate. */
56 /*! Get slot's left front y coordinate. */
59 /*! Get slot's left rear x coordinate. */
62 /*! Get slot's left rear y coordinate. */
65 /*! Get slot's right rear x coordinate. */
68 /*! Get slot's right rear y coordinate. */
71 /*! Get slot's right front x coordinate. */
74 /*! Get slot's right front y coordinate. */
77 /*! Return parking slot's orientation. */
80 /*! Get parking slot's left front point. */
83 /*! Get parking slot's left rear point. */
86 /*! Get parking slot's right rear point. */
89 /*! Get parking slot's right front point. */
92 /*! Get parking slot's entry side. */
95 /*! Get parking slot's rear side. */
98 /*! Get parking slot's curb side. */
101 /*! Get parking slot's front side. */
104 /*! Car's next iteration distance. (Negative for backward.) */
105 void set_parking_speed(double s);
107 /*! Maximum allowed number of cusp inside the parking slot. */
108 unsigned int get_max_cusp() const;
109 void set_max_cusp(unsigned int m);
111 /*! Angle's increment when creating start positions. */
112 void set_delta_angle_to_slot(double d);
114 /*! Return `true` for the parallel parking slot. */
115 bool parallel() const;
117 /*! Return `true` for the parking slot on the right side. */
120 /*! Change side of the parking slot. */
123 /*! Return `true` if car `c` is parking in slot `this`. */
124 bool parked(BicycleCar const& c) const;
126 /*! Return `true` if `c`'s car frame collide with `this` border. */
127 bool collide(BicycleCar const& c) const;
129 /*! \brief Drive car `c` into the parking slot `this`.
131 * \param c Starting bicycle car.
133 std::vector<BicycleCar> drive_in_slot(BicycleCar c);
135 /*! \brief Drive car `c` from slot.
137 * \param c Starting bicycle car.
139 std::vector<BicycleCar> drive_of_slot(BicycleCar c);
141 /*! \brief Steer car `c` into the parking slot `this`.
143 * `steer_in_slot` returns the complete path as the list of `Pose`s, not
144 * just cusp `BicycleCar`s as `drive_to_slot`.
146 * \param c Starting bicycle car.
148 std::vector<Pose> steer_in_slot(BicycleCar c);
150 /*! \brief Find entry.
152 * \param c For which `BicycleCar` should entry be found?
154 PoseRange fe(BicycleCar c);
156 /*! \brief Recompute zero slot's `PoseRange` entry for `this`.
158 * The _zero slot_ is the `ParkingSlot(Point(0.0, 0.0), 0.0, W, L);`.
160 * \param p Computed `PoseRange` entry.
162 PoseRange recompute_entry(PoseRange p);
164 friend std::ostream& operator<<(std::ostream& o, ParkingSlot const& s);
168 #endif /* BCAR_PSLOT_H */