]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/blob - incl/bcar.h
Add length, wheelbase, width getters to bcar
[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 MAXSTEER(wb, tr) ((wb) / (tr))
25
26 class BicycleCar: public RRTNode {
27         private:
28                 // see https://en.wikipedia.org/wiki/Fiat_Punto
29                 const float height_ = 1.450;
30                 const float length_ = 3.760;
31                 const float safety_dist_ = 0;
32                 const float turning_radius_ = 10.82;
33                 const float wheel_base_ = 2.450;
34                 const float width_ = 1.625;
35
36                 float speed_ = 0;
37                 float steer_ = 0;
38         public:
39                 using RRTNode::RRTNode;
40
41                 // getter
42                 float length();
43                 float wheelbase();
44                 float width();
45
46                 float dr();
47                 float df();
48
49                 float lfx();
50                 float lrx();
51                 float rrx();
52                 float rfx();
53                 float lfy();
54                 float lry();
55                 float rry();
56                 float rfy();
57
58                 float lwbx();
59                 float lwby();
60                 float rwbx();
61                 float rwby();
62
63                 /** Return circle center on the left side of the car */
64                 RRTNode *ccl();
65                 /** Return circle center on the right side of the car */
66                 RRTNode *ccr();
67
68                 float speed();
69                 float steer();
70
71                 // setter
72                 bool speed(float s);
73                 bool steer(float s);
74
75                 // other
76                 std::vector<RRTEdge *> frame();
77                 bool next();
78                 bool next(float speed, float steer);
79
80                 /** Return distance from wheelbase center to top corner */
81                 float diag_radi();
82                 /** Outer radius of the farthest point */
83                 float out_radi();
84                 /** Angle between wheelbase line and outer radius */
85                 float alfa();
86                 /** Return true if `n` not inside of `ccl`, `ccr` */
87                 bool drivable(RRTNode *n);
88                 /** Return node rotated by `dh` around `c` */
89                 BicycleCar *move(RRTNode *c, float dh);
90 };
91
92 #endif