]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blob - incl/bcar.h
Merge branch 'feature/generalize-samplingInfo'
[hubacji1/iamcar.git] / incl / bcar.h
1 /*
2 This file is part of I am car.
3
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.
8
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.
13
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/>.
16 */
17
18 #ifndef BICYCLECAR_H
19 #define BICYCLECAR_H
20
21 #include <vector>
22 #include "rrtnode.h"
23
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
31 #define MAXSTEER(wb, tr) ((wb) / (tr))
32
33 class BicycleCar: public RRTNode {
34         private:
35                 // see https://en.wikipedia.org/wiki/Fiat_Punto
36                 const float height_ = BCAR_HEIGHT;
37                 const float length_ = BCAR_LENGTH;
38                 const float safety_dist_ = BCAR_SAFETY_DIST;
39                 const float turning_radius_ = BCAR_TURNING_RADIUS;
40                 const float wheel_base_ = BCAR_WHEEL_BASE;
41                 const float width_ = BCAR_WIDTH;
42
43                 float speed_ = 0;
44                 float steer_ = 0;
45
46                 BicycleCar *bcparent_;
47         public:
48                 using RRTNode::RRTNode;
49
50                 // getter
51                 float length();
52                 float wheelbase();
53                 float width();
54
55                 float dr();
56                 float df();
57
58                 float lfx();
59                 float lrx();
60                 float rrx();
61                 float rfx();
62                 float lfy();
63                 float lry();
64                 float rry();
65                 float rfy();
66
67                 float lwbx();
68                 float lwby();
69                 float rwbx();
70                 float rwby();
71
72                 /** Return circle center on the left side of the car */
73                 RRTNode *ccl();
74                 /** Return circle center on the right side of the car */
75                 RRTNode *ccr();
76
77                 float speed();
78                 float steer();
79
80                 BicycleCar *bcparent() const;
81
82                 // setter
83                 bool speed(float s);
84                 bool steer(float s);
85
86                 void bcparent(BicycleCar *bcp);
87
88                 // other
89                 std::vector<RRTEdge *> frame();
90                 bool next();
91                 bool next(float speed, float steer);
92
93                 /** Return distance from wheelbase center to top corner */
94                 float diag_radi();
95                 /** Outer radius of the farthest point */
96                 float out_radi();
97                 /** Angle between wheelbase line and outer radius */
98                 float alfa();
99                 /** Return true if `n` not inside of `ccl`, `ccr` */
100                 bool drivable(RRTNode *n);
101                 /** Return node rotated by `dh` around `c` */
102                 BicycleCar *move(RRTNode *c, float dh);
103 };
104
105 #endif