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