Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: OmniMove.cpp
- Revision:
- 7:9b9d488ebcfd
- Parent:
- 6:fac3dcaebe83
- Child:
- 8:fb082466cfec
--- a/OmniMove.cpp Mon Mar 29 09:13:27 2021 +0000
+++ b/OmniMove.cpp Mon Apr 12 10:38:12 2021 +0000
@@ -11,46 +11,38 @@
}
}
-void OmniMove::input_polar(float r,float theta,float Vroll,float roll_ratio){
+void OmniMove::input_polar(float r,float theta,float Vroll){
r = limit(0,1,r);
Vroll = limit(-1,1,Vroll);
- roll_ratio = limit(0,1,roll_ratio);
- Vx = r * cos( conv_rad( theta ) ) * ( 1 - roll_ratio );
- Vy = r * sin( conv_rad( theta ) ) * ( 1 - roll_ratio );
- Vroll = Vroll * roll_ratio;
+ Vx = r * cos( conv_rad( theta ) ) * ( 1 - fabs(Vroll) );
+ Vy = r * sin( conv_rad( theta ) ) * ( 1 - fabs(Vroll) );
}
-void OmniMove::input_polar(float r,float theta,float Vroll,float roll_ratio,float MachineAng){
+void OmniMove::input_polar(float r,float theta,float Vroll,float MachineAng){
r = limit(0,1,r);
Vroll = limit(-1,1,Vroll);
- roll_ratio = limit(0,1,roll_ratio);
- Vx = r * cos( conv_rad( theta - MachineAng ) ) * ( 1 - roll_ratio );
- Vy = r * sin( conv_rad( theta - MachineAng ) ) * ( 1 - roll_ratio );
- Vroll = Vroll * roll_ratio;
+ Vx = r * cos( conv_rad( theta - MachineAng ) ) * ( 1 - fabs(Vroll) );
+ Vy = r * sin( conv_rad( theta - MachineAng ) ) * ( 1 - fabs(Vroll) );
}
-void OmniMove::input_cartesian(float x,float y,float Vroll,float roll_ratio){
+void OmniMove::input_cartesian(float x,float y,float Vroll){
x = limit(-1,1,x);
y = limit(-1,1,y);
Vroll = limit(-1,1,Vroll);
- roll_ratio = limit(0,1,roll_ratio);
r = limit(0,1,hypotf(x,y));
theta = conv_deg(atan2(y,x));
- Vx = r * cos( conv_rad( theta ) ) * ( 1 - roll_ratio );
- Vy = r * sin( conv_rad( theta ) ) * ( 1 - roll_ratio );
- Vroll = Vroll * roll_ratio;
+ Vx = r * cos( conv_rad( theta ) ) * ( 1 - fabs(Vroll) );
+ Vy = r * sin( conv_rad( theta ) ) * ( 1 - fabs(Vroll) );
}
-void OmniMove::input_cartesian(float x,float y,float Vroll,float roll_ratio,float MachineAng){
+void OmniMove::input_cartesian(float x,float y,float Vroll,float MachineAng){
x = limit(-1,1,x);
y = limit(-1,1,y);
Vroll = limit(-1,1,Vroll);
- roll_ratio = limit(0,1,roll_ratio);
r = limit(0,1,hypotf(x,y));
theta = conv_deg(atan2(y,x));
- Vx = r * cos( conv_rad( theta - MachineAng ) ) * ( 1 - roll_ratio );
- Vy = r * sin( conv_rad( theta - MachineAng ) ) * ( 1 - roll_ratio );
- Vroll = Vroll * roll_ratio;
+ Vx = r * cos( conv_rad( theta - MachineAng ) ) * ( 1 - fabs(Vroll) );
+ Vy = r * sin( conv_rad( theta - MachineAng ) ) * ( 1 - fabs(Vroll) );
}
float OmniMove::output_(int n){