]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/blob - incl/pslot.hh
Add steer in slot 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         Point border_[4];
21         Line entry_;
22         Line rear_;
23         Line curb_;
24         Line front_;
25 public:
26         /*! \brief Set parking slot.
27
28         \param p Point with `x`, `y` coordinates of entry side's corner.
29         \param h Direction of the entry side.
30         \param W The width of the slot.
31         \param L The length of the slot.
32         */
33         ParkingSlot(Point p, double h, double W, double L);
34         ParkingSlot(double lrx, double lry, double rrx, double rry, double rfx,
35                 double rfy, double lfx, double lfy);
36
37         /*! Get slot's length. */
38         double len() const;
39
40         /*! Get slot's width. */
41         double w() const;
42
43         /*! Get slot's left front x coordinate. */
44         double lfx() const;
45
46         /*! Get slot's left front y coordinate. */
47         double lfy() const;
48
49         /*! Get slot's left rear x coordinate. */
50         double lrx() const;
51
52         /*! Get slot's left rear y coordinate. */
53         double lry() const;
54
55         /*! Get slot's right rear x coordinate. */
56         double rrx() const;
57
58         /*! Get slot's right rear y coordinate. */
59         double rry() const;
60
61         /*! Get slot's right front x coordinate. */
62         double rfx() const;
63
64         /*! Get slot's right front y coordinate. */
65         double rfy() const;
66
67         /*! Return parking slot's orientation. */
68         double h() const;
69
70         /*! Return `true` for the parallel parking slot. */
71         bool parallel() const;
72
73         /*! Return `true` for the parking slot on the right side. */
74         bool right() const;
75
76         /*! Change side of the parking slot. */
77         void swap_side();
78
79         /*! Return `true` if car `c` is parking in slot `this`. */
80         bool parked(BicycleCar const& c) const;
81
82         /*! Return `true` if `c`'s car frame collide with `this` border. */
83         bool collide(BicycleCar const& c) const;
84
85         /*! \brief Drive car `c` into the parking slot `this`.
86          *
87          * \param c Starting bicycle car.
88          * \param max Maximum number of backward-forward direction changes.
89          */
90         std::vector<BicycleCar> drive_in_slot(BicycleCar c, unsigned int& max);
91
92         /*! \brief Steer car `c` into the parking slot `this`.
93          *
94          * `steer_in_slot` returns the complete path as the list of `Pose`s, not
95          * just cusp `BicycleCar`s as `drive_to_slot`.
96          *
97          * \param c Starting bicycle car.
98          */
99         std::vector<Pose> steer_in_slot(BicycleCar c);
100
101         /*! \brief Find entry.
102          *
103          * \param c For which `BicycleCar` should entry be found?
104          * \param max Maximum number of backward-forward direction changes.
105          */
106         PoseRange fe(BicycleCar c, unsigned int& max);
107
108         friend std::ostream& operator<<(std::ostream& o, ParkingSlot const& s);
109 };
110
111 } // namespace bcar
112 #endif /* BCAR_PSLOT_H */