Programming Mecanum - Simplified

This example is a simplified form of a mecanum drivetrain code intended to review the basics of mecanum movement and is not recommended for a FTC robot.

Check out Programming Mecanum - Refined for a competition ready example!

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:

Port TypePort NumberDevice TypeName

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:

Gamepad InputFunction

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:

Before diving into mecanum, double check the direction your motors and wheels are spinning. They may need to be reversed if you're experiencing jittering or inverted controls!

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.

This version of the mecanum program does not account for diagonal movements of the joystick. Check out Programing Mecanum - Refined to create a fully responsive mecanum drive!

Last updated