File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ #ifndef __KINEMATICS_H__
2
+ #define __KINEMATICS_H__
3
+
4
+ #include " Arduino.h"
5
+
6
+ class Kinematics {
7
+ private:
8
+ float left_velocity;
9
+ float right_velocity;
10
+ float linear_velocity;
11
+ float angular_velocity;
12
+ float wheel_track;
13
+ float wheel_diameter;
14
+ float wheel_radius;
15
+
16
+
17
+ public:
18
+ Kinematics (const float _wheel_track, const float _wheel_diameter){
19
+ left_velocity=0.0 ;
20
+ right_velocity=0.0 ;
21
+ linear_velocity=0.0 ;
22
+ angular_velocity=0.0 ;
23
+ wheel_track=_wheel_track;
24
+ wheel_diameter=_wheel_diameter;
25
+ wheel_radius=wheel_diameter/2.0 ;
26
+ }
27
+
28
+ void forward (const float linear, const float angular){
29
+ left_velocity=(2 *linear_velocity-angular_velocity*wheel_track)/(wheel_diameter);
30
+ right_velocity=(2 *linear_velocity+angular_velocity*wheel_track)/(wheel_diameter);
31
+ }
32
+
33
+ void inverse (const float left_velocity, const float right_velocity){
34
+ linear_velocity=(left_velocity+right_velocity)*wheel_radius/2.0 ;
35
+ angular_velocity=(-left_velocity+right_velocity)*wheel_radius/wheel_track;
36
+ }
37
+
38
+ float getLeftVelocity (){
39
+ return left_velocity;
40
+ }
41
+
42
+ float getRightVelocity (){
43
+ return right_velocity;
44
+ }
45
+
46
+ float getLinearVelocity (){
47
+ return linear_velocity;
48
+ }
49
+
50
+ float getAngularVelocity (){
51
+ return angular_velocity;
52
+ }
53
+
54
+
55
+ };
56
+
57
+
58
+
59
+ #endif
You can’t perform that action at this time.
0 commit comments