Programming Mecanum - Simplified
Configuration
Before getting started with programming we needed to create a configuration file. Below is an overview of how the robot is configured for the TeleOp code to function as expected:
Motor
0
REV Robotics Ultraplanetary HD Hex Motor
frontLeft
Motor
1
REV Robotics Ultraplanetary HD Hex Motor
frontRight
Motor
2
REV Robotics Ultraplanetary HD Hex Motor
backLeft
Motor
3
REV Robotics Ultraplanetary HD Hex Motor
backRight
Example Program:
Gamepad Layout:
Left Joystick - Left/Right on X-Axis
Strafe Left/Right
Left Joystick - Forward/Backward on Y-Axis
Forward/Backward
Right Joystick - Left/Right on X-Axis
Turn Counter-Clockwise/Clockwise
Programming Teleop - Blocks
Initialization:
For this program, we'll set the motors to RUN_WITHOUT_ENCODER along with their direction

Moving Forward and Backwards:
For a mecanum drivetrain all 4 motors will be given a command to follow when the left joystick is moved along the Y-axis of the joystick. For moving forward and back all wheels must turn the same direction.
Recall that the Y-axis on the gamepad must be inverted.

Strafing:
For this example, strafing is controlled by the left stick's X-axis allowing the robot to slide left and right. In order to achieve this movement, the motors move in diagonal pairs, so frontLeft and backRight will move the opposit direction of backLeft and frontRight, similar to the X shape the wheels make.

Turning:
Lastly, we have turning set by itself on the right joystick's X-axis. To turn our left and right pairs of wheels will spin in opposite directions.

Last updated
Was this helpful?