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)
37 #define BCAR_OUT_RRADI pow( \
38 pow(BCAR_TURNING_RADIUS + BCAR_WIDTH/2, 2) + \
39 pow(BCAR_DIST_REAR, 2), 0.5)
40 #define BCAR_IN_RADI (BCAR_TURNING_RADIUS - BCAR_WIDTH/2)
42 #define MAXSTEER(wb, tr) ((wb) / (tr))
44 class BicycleCar: public RRTNode {
46 // see https://en.wikipedia.org/wiki/Fiat_Punto
47 const float height_ = BCAR_HEIGHT;
48 const float length_ = BCAR_LENGTH;
49 const float safety_dist_ = BCAR_SAFETY_DIST;
50 const float turning_radius_ = BCAR_TURNING_RADIUS;
51 const float wheel_base_ = BCAR_WHEEL_BASE;
52 const float width_ = BCAR_WIDTH;
57 BicycleCar *bcparent_;
59 using RRTNode::RRTNode;
83 /** Return circle center on the left side of the car */
85 /** Return circle center on the right side of the car */
91 BicycleCar *bcparent() const;
97 void bcparent(BicycleCar *bcp);
100 std::vector<RRTEdge *> frame();
102 bool next(float speed, float steer);
104 /** Return distance from wheelbase center to top corner */
106 /** Return distance from wheelbase center to rear corner */
108 /** Outer radius of the farthest point */
110 /** Angle between wheelbase line and outer radius */
112 /** Return true if `n` not inside of `ccl`, `ccr` */
113 bool drivable(RRTNode *n);
114 /** Return node rotated by `dh` around `c` */
115 BicycleCar *move(RRTNode *c, float dh);