Skip to content

Commit b3c8cbe

Browse files
committed
conversions in kinematics
1 parent e54fb9e commit b3c8cbe

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/kinematics.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class Kinematics{
1212
float wheel_track;
1313
float wheel_diameter;
1414
float wheel_radius;
15+
float rads_to_rpm;
16+
float rpm_to_rads;
17+
float rads_to_degs;
18+
float degs_to_rads;
1519

1620

1721
public:
@@ -23,16 +27,23 @@ class Kinematics{
2327
wheel_track=_wheel_track;
2428
wheel_diameter=_wheel_diameter;
2529
wheel_radius=wheel_diameter/2.0;
30+
31+
rads_to_rpm=60.0/(2.0*PI);
32+
rpm_to_rads=2.0*PI/60.0;
33+
34+
rads_to_degs=180.0/PI;
35+
degs_to_rads=PI/180.0;
36+
2637
}
2738

2839
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);
40+
left_velocity=(2*linear-angular*wheel_track)/(wheel_diameter);
41+
right_velocity=(2*linear+angular*wheel_track)/(wheel_diameter);
3142
}
3243

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;
44+
void inverse(const float left_vel, const float right_vel){
45+
linear_velocity=(left_vel+right_vel)*wheel_radius/2.0;
46+
angular_velocity=(-left_vel+right_vel)*wheel_radius/wheel_track;
3647
}
3748

3849
float getLeftVelocity(){

0 commit comments

Comments
 (0)