8 /*! \brief Bicycle car basic class.
10 This class contains some geometrical computations of bicycle car.
12 \param x Horizontal coordinate of rear axle center.
13 \param y Vertical coordinate of rear axle center.
14 \param h Heading of the car.
15 \param mtr Minimum turning radius.
17 \param w The width of the car.
18 \param l The length of the car.
19 \param he The height of the car.
20 \param sd The safety distance.
21 \param df Distance from rear axle center to the front of the car.
22 \param dr Distance from rear axle center to the back of the car.
23 \param sp Speed of the car.
24 \param st Steering of the car.
32 // kinematic constraints
46 // kinematic constraints
47 /*! \brief Return `false` if `bc` is not achievable.
49 When `true` is returned the `bc` may still be not
50 achievable because in the current implementation,
51 heading is not considered.
53 \param[in] bc The bicycle car to achieve.
55 bool drivable(const BicycleCar &bc) const;
56 /*! \brief Return inner radius.
58 The inner radius is the distance from minimum turning
59 radius circle center to the nearest point on the car. In
60 this case, the nearest points on the car are rear axle
64 /*! \brief Return outer front radius.
66 The outer front radius is the distance from minimum
67 turning radius circle center to the farthest point on
68 the front (from the rear axle view) part of the car.
70 double ofradi() const;
71 /*! \brief Return outer rear radius.
73 The outer rear radius is the distance from minimum
74 turning radius circle center to the farthest point on
75 the rear (from the rear axle view) part of the car.
77 double orradi() const;
80 double lfx() const; double lfy() const;
81 double lrx() const; double lry() const;
82 double rrx() const; double rry() const;
83 double rfx() const; double rfy() const;
85 double ralx() const; double raly() const;
86 double rarx() const; double rary() const;
88 /*! \brief Min. turning radius circle center on left.
90 Important are coordinates `x` and `y`. The heading `h`
91 is set as the heading of `this->h()`.
93 BicycleCar ccl() const;
94 /*! \brief Min. turning radius circle center on rigth.
96 Important are coordinates `x` and `y`. The heading `h`
97 is set as the heading of `this->h()`.
99 BicycleCar ccr() const;
102 /*! \brief Next car position based on `sp` and `st`.
104 Where `sp` is speed and `st` is steering of the car.
109 double x() const { return this->x_; }
110 void x(double x) { this->x_ = x; }
112 double y() const { return this->y_; }
113 void y(double y) { this->y_ = y; }
115 double h() const { return this->h_; }
116 void h(double h) { this->h_ = h; }
118 double mtr() const { return this->mtr_; }
119 void mtr(double mtr) { this->mtr_ = mtr; }
121 double wb() const { return this->wb_; }
122 void wb(double wb) { this->wb_ = wb; }
124 double w() const { return this->w_; }
125 void w(double w) { this->w_ = w; }
127 double l() const { return this->l_; }
128 void l(double l) { this->l_ = l; }
130 double he() const { return this->he_; }
131 void he(double he) { this->he_ = he; }
133 double sd() const { return this->sd_; }
134 void sd(double sd) { this->sd_ = sd; }
136 double df() const { return this->df_; }
137 void df(double df) { this->df_ = df; }
139 double dr() const { return this->dr_; }
140 void dr(double dr) { this->dr_ = dr; }
142 double sp() const { return this->sp_; }
143 void sp(double sp) { this->sp_ = sp; }
145 double st() const { return this->st_; }
146 void st(double st) { this->st_ = st; }
149 friend std::ostream &operator<<(
154 out << "[" << bc.x();
155 out << "," << bc.y();
156 out << "," << bc.h();
162 /*! \brief Is `x, y` coordinate in polynom `poly`?
164 Return `true` if `x, y` coordinate is inside of polynom `poly`.
166 \see https://en.wikipedia.org/wiki/Even%E2%80%93odd_rule
168 \param x Horizontal coordinate.
169 \param y Vertical coordinate.
170 \param poly The vector of coordinates.
172 bool inside(double x, double y, std::vector<std::tuple<double, double>> poly);
174 /*! \brief Return intersection of two line segments.
176 The output is tuple `std::tuple<bool, double, double>`, where the first
177 value is true when there is an intersection and false otherwise. The
178 second and third parameters in the return tuple are coordinates of the
181 \see https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
183 \param x1 First line segment first `x` coordinate.
184 \param y1 First line segment first `y` coordinate.
185 \param x2 First line segment second `x` coordinate.
186 \param y2 First line segment second `y` coordinate.
187 \param x3 Second line segment first `x` coordinate.
188 \param y3 Second line segment first `y` coordinate.
189 \param x4 Second line segment second `x` coordinate.
190 \param y4 Second line segment second `y` coordinate.
192 std::tuple<bool, double, double> intersect(
193 double x1, double y1,
194 double x2, double y2,
195 double x3, double y3,