2 This file is part of I am car.
4 I am car is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 I am car is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with I am car. If not, see <http://www.gnu.org/licenses/>.
24 #define BCAR_HEIGHT 1.450
25 #define BCAR_LENGTH 3.760
26 #define BCAR_SAFETY_DIST 0
27 #define BCAR_TURNING_RADIUS 10.820
28 #define BCAR_WHEEL_BASE 2.450
29 #define BCAR_WIDTH 1.625
30 #define BCAR_DIST_REAR ((BCAR_LENGTH - BCAR_WHEEL_BASE) / 2)
31 #define BCAR_DIST_FRONT (BCAR_LENGTH - BCAR_DIST_REAR)
32 #define BCAR_DIAG_RADI pow(pow(BCAR_DIST_FRONT, 2) + pow(BCAR_WIDTH/2, 2), 0.5)
33 #define BCAR_DIAG_RRADI pow(pow(BCAR_DIST_REAR, 2) + pow(BCAR_WIDTH/2, 2), 0.5)
34 #define BCAR_OUT_RADI pow( \
35 pow(BCAR_TURNING_RADIUS + BCAR_WIDTH/2, 2) + \
36 pow(BCAR_DIST_FRONT, 2), 0.5)
38 #define MAXSTEER(wb, tr) ((wb) / (tr))
40 class BicycleCar: public RRTNode {
42 // see https://en.wikipedia.org/wiki/Fiat_Punto
43 const float height_ = BCAR_HEIGHT;
44 const float length_ = BCAR_LENGTH;
45 const float safety_dist_ = BCAR_SAFETY_DIST;
46 const float turning_radius_ = BCAR_TURNING_RADIUS;
47 const float wheel_base_ = BCAR_WHEEL_BASE;
48 const float width_ = BCAR_WIDTH;
53 BicycleCar *bcparent_;
55 using RRTNode::RRTNode;
79 /** Return circle center on the left side of the car */
81 /** Return circle center on the right side of the car */
87 BicycleCar *bcparent() const;
93 void bcparent(BicycleCar *bcp);
96 std::vector<RRTEdge *> frame();
98 bool next(float speed, float steer);
100 /** Return distance from wheelbase center to top corner */
102 /** Return distance from wheelbase center to rear corner */
104 /** Outer radius of the farthest point */
106 /** Angle between wheelbase line and outer radius */
108 /** Return true if `n` not inside of `ccl`, `ccr` */
109 bool drivable(RRTNode *n);
110 /** Return node rotated by `dh` around `c` */
111 BicycleCar *move(RRTNode *c, float dh);