From 0a9ae78ae86a0a0e9d7f0af0145445689bd40725 Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Wed, 14 Feb 2024 18:38:43 -0500 Subject: [PATCH] e --- .../robotics-framework/mecanum-teleop.mdx | 60 +++++++++++++------ 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/pages/programming/robotics-framework/mecanum-teleop.mdx b/pages/programming/robotics-framework/mecanum-teleop.mdx index 9f99fc0..b6c63f1 100644 --- a/pages/programming/robotics-framework/mecanum-teleop.mdx +++ b/pages/programming/robotics-framework/mecanum-teleop.mdx @@ -11,15 +11,14 @@ ## Mecanum Wheel Control -
+
+ $$ y = \text{forward velocity} \\ x = \text{strafe velocity} \times f \\ r = \text{rotational velocity} $$ -
-
$$ \text{denominator} = \max(\lvert y \rvert + \lvert x \rvert + \lvert r \rvert, 1) \\ \text{frontLeftMotor} = \frac{y + x + r}{\text{denominator}} \\ @@ -27,62 +26,89 @@ $$ \text{frontRightMotor} = \frac{y - x - r}{\text{denominator}} \\ \text{backRightMotor} = \frac{y + x - r}{\text{denominator}} $$ +
## Deriving Mecanum Wheel Control Let break the down to understand it -
$$ Motors = y $$
+
+ +$$ Motors = y $$ + +
![Image](/assets/forward_backward.png) -Forward/Back movement is obvious, however, there are still a few things to note.\ -Remember that joysticks have an interval of `-1 to 1`.\ -Motors moves counterclockwise so you want to reverse the y direction:\ -`double y = -gamepad1.left_stick_y;` +Forward/Back movement is obvious, however, there are still a few things to note. Remember that joysticks have an interval of `-1 to 1`. Motors moves counterclockwise so you want to reverse the y direction: `double y = -gamepad1.left_stick_y;` + +
+ +$$ +\text{leftMotors} = y + r \\ +\text{rightMotors} = y - r +$$ -
- $$ \text{leftMotors} = y + r \\ \text{rightMotors} = y - r $$
Now in our current form, we have a differential drive/tank drive, enabling differential steering. ![Image](/assets/rotation.png) -If both sticks are pushed at the same time, it will cause the robot to move in a curve\ +If both sticks are pushed at the same time, it will cause the robot to move in a curve + +
-
$$ \text{leftMotors} = 1 + 1 = 2 \, (\text{Clipped to } 1) \\ \text{rightMotors} = 1 - 1 = 0 $$ +
![Image](/assets/curve.png) We add the final x value to enable omnidirectional movement based on the direction of the vector forces for each wheel. -
$$ \text{frontLeftMotor} = y + x + r $$
+
+ +$$ \text{frontLeftMotor} = y + x + r $$ + +
![Image](/assets/FL.png) -
$$ \text{backLeftMotor} = y - x + r $$
+
+ +$$ \text{backLeftMotor} = y - x + r $$ + +
![Image](/assets/BL.png) -
$$ \text{frontRightMotor} = y - x - r $$
+
+ +$$ \text{frontRightMotor} = y - x - r $$ + +
![Image](/assets/FR.png) -
$$ \text{backRightMotor} = y + x - r $$
+
+ +$$ \text{backRightMotor} = y + x - r $$ + +
![Image](/assets/BR.png) -
+
+ $$ f = \text{strafe adjustment factor} = \frac{\text{track length}}{\text{track width}} $$ +
The strafe adjustment factor counteracts imperfect strafing caused by the difference between tracklength and trackwidth.