-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3107e7
commit 6a884a2
Showing
11 changed files
with
44 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"index": "JellyDocs", | ||
"api-reference": "API Reference", | ||
"programming": "Programming", | ||
"resources": "Resources" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"linearopmode": "LinearOpMode", | ||
"hardwaremap": "HardwareMap", | ||
"gamepad": "Gamepad", | ||
"motors": "Motors", | ||
"servo": "Servos", | ||
"crservo": "CRServos" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 34 additions & 83 deletions
117
pages/programming/robotics-framework/mecanum-teleop.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,65 @@ | ||
# Mecanum TeleOp | ||
|
||
## Understanding Mecanum Wheels | ||
|
||
#### 1. Design and Structure: | ||
## Mecanum Wheels | ||
|
||
- **Unique Configuration**: Mecanum wheels have unique rollers positioned at a 45-degree angle around the wheel. | ||
|
||
#### 2. Movement Mechanics: | ||
|
||
- **Holonomic Movement**: These wheels enable a robot to move in any horizontal direction without changing the wheels' or robot's orientation. | ||
- **Vector Force**: Rotating Mecanum wheels generate a 45-degree force vector, combining to move the robot. | ||
|
||
#### 3. Wheel Arrangement: | ||
|
||
- **X Configuration**: The wheels are mounted to form an 'X' pattern when viewed from above, crucial for omnidirectional movement. | ||
|
||
 | ||
|
||
### Mecanum Wheel Coding | ||
|
||
Understanding Mecanum wheel control involves translating gamepad inputs into motor movements for omnidirectional mobility. | ||
|
||
#### Basic Tank Drive Control | ||
|
||
1. **Forward/Backward Movement**: | ||
|
||
- **Gamepad Y Axis**: Controls forward and backward movement. | ||
- **Motor Power Assignment**: Motor power is set based on the Y-axis value. | ||
- **Reversing Y-Axis**: The Y-axis is often reversed in control systems. | ||
|
||
```java | ||
// Basic Forward/Backward Movement Control | ||
double speed = -gamepad1.left_stick_y; // Inverting Y-axis value | ||
## Mecanum Wheel Control | ||
|
||
// Setting motor powers for forward/backward motion | ||
leftMotor.setPower(speed); | ||
rightMotor.setPower(speed); | ||
``` | ||
y = forward velocity (forward/backward) | ||
x = strafe velocity (left/right) | ||
r = rotational velocity | ||
|
||
2. **Adding Rotation (Pivot Turning)**: | ||
frontLeftMotor = y + x + r | ||
backLeftMotor = y - x + r | ||
frontRightMotor = y - x - r | ||
backRightMotor = y + x - r | ||
|
||
- **Gamepad X Axis**: Controls rotation. | ||
- **Power Adjustment for Rotation**: Differential power adjustments cause the robot to turn. | ||
## Deriving Mecanum Wheel Control | ||
|
||
```java | ||
// Adding Rotation (Pivot Turning) Control | ||
double speed = -gamepad1.left_stick_y; // Inverting Y-axis value | ||
double rotate = gamepad1.right_stick_x; // Right stick X-axis for rotation | ||
Let break the down to understand it | ||
|
||
// Adjusting motor powers for rotation | ||
leftMotor.setPower(speed + rotate); | ||
rightMotor.setPower(speed - rotate); | ||
``` | ||
Motors = y | ||
|
||
#### Mecanum Wheel Control | ||
 | ||
|
||
1. **Omnidirectional Movement**: | ||
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;` | ||
|
||
- **Left Stick X Axis for Strafing**: Controls sideways movement. | ||
- **Wheel Power Calculation**: Combines speed, strafe, and rotation values. | ||
- **Diagonal Wheel Coordination**: Determines the direction of strafing. | ||
leftMotors = y+r | ||
rightMotors = y-r | ||
|
||
```java | ||
// Mecanum Wheel Omnidirectional Movement Control | ||
double speed = -gamepad1.left_stick_y; // Forward/Backward (Y-axis) | ||
double strafe = gamepad1.left_stick_x; // Strafing (X-axis) | ||
double rotate = gamepad1.right_stick_x; // Rotation (right stick X-axis) | ||
Now in our current form, we have a differential drive/tank drive, enabling differential steering. | ||
|
||
// Calculating motor powers for omnidirectional movement | ||
frontLeftMotor.setPower(speed + strafe + rotate); | ||
backLeftMotor.setPower(speed - strafe + rotate); | ||
frontRightMotor.setPower(speed - strafe - rotate); | ||
backRightMotor.setPower(speed + strafe - rotate); | ||
``` | ||
 | ||
|
||
2. **Control Equations**: | ||
If both sticks are pushed at the same time, it will cause the robot to move in a curve | ||
leftMotors = 1+1 = 2 (Clipped to 1) | ||
rightMotors = 1-1 = 0 | ||
|
||
- **Direction and Speed**: `speed` controls forward/backward, `strafe` controls sideways movement, and `rotate` adds rotation. | ||
 | ||
|
||
3. **Motor Spin Direction**: | ||
We add the final x value to enable omnidirectional movement based on the direction of the vector forces for each wheel. | ||
|
||
- **Default Spin**: FTC motors typically spin counterclockwise with positive power. | ||
- **Gear Configuration**: Gears can change the effective direction of motor rotation. | ||
frontLeftMotor = y + x + r | ||
|
||
4. **Code Improvements**: | ||
 | ||
|
||
- **Strafing Accuracy**: Multiplying `strafe` by a factor like 1.1. | ||
- **Power Scaling**: Ensuring motor power values stay within -1 to 1 range. | ||
backLeftMotor = y - x + r | ||
|
||
```java | ||
// Code Improvements for Strafing Accuracy and Power Scaling | ||
double speed = -gamepad1.left_stick_y; // Forward/Backward (Y-axis) | ||
double strafe = gamepad1.left_stick_x * 1.1; // Improved strafing (X-axis, scaled) | ||
double rotate = gamepad1.right_stick_x; // Rotation (right stick X-axis) | ||
 | ||
|
||
// Scaling motor powers to maintain ratio and limit within [-1, 1] | ||
double denominator = Math.max(Math.abs(speed) + Math.abs(strafe) + Math.abs(rotate), 1); | ||
double frontLeftPower = (speed + strafe + rotate) / denominator; | ||
double backLeftPower = (speed - strafe + rotate) / denominator; | ||
double frontRightPower = (speed - strafe - rotate) / denominator; | ||
double backRight | ||
frontRightMotor = y - x - r | ||
|
||
Power = (speed + strafe - rotate) / denominator; | ||
// Setting the scaled motor powers | ||
frontLeftMotor.setPower(frontLeftPower); | ||
backLeftMotor.setPower(backLeftPower); | ||
frontRightMotor.setPower(frontRightPower); | ||
backRightMotor.setPower(backRightPower); | ||
``` | ||
 | ||
|
||
``` | ||
backRightMotor = y + x - r | ||
|
||
``` | ||
 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.