Skip to main content

Mecanum

What are mecanum wheels?

GM0

Mecanum drivetrains consist of four mecanum wheels which are powered independently by one motor. This configuration angles the velocity of each wheel, allowing the robot to strafe.

The primary advantage to mecanum drive is the maneuverability it affords, especially because the robot can strafe instead of turn and drive. The rollers on mecanum wheels form a 45 degree angle with the wheel’s axis of rotation, which means that mecanum drivetrains can’t strafe as fast as they can drive forward.

How do I use mecanum wheels with FTC Layer?

Easy!

First you must include FTC Layer's Mecanum class

At the top of your file, add the following line.

import org.ftc17191.ftclayer.drivetrain.mecanum.Mecanum;

Then we have to make a variable that controls the mecanum wheels. We will use the ids we set to our drive motors when making this variable.

Mecanum mecanum = new Mecanum(hardwareMap, "front_right", "front_left", "back_right", "back_left");

Use this reference image to see which motors need to be set to which.

Reference

Don't know how to set a configuration? Click Here.

Now to drive the robot!

In your code, there is a place where it will loop constantly.

It may be inside your while statement:

waitForStart();

while(opModeIsActive())
{
// Here!
}

Or inside a loop function:

@Override
void loop()
{
// Here!

}

Inside whichever your code uses you need to place the line:

                //  Forward                Strafe                 Turn
mecanum.powerDrive(gamepad1.left_stick_y, gamepad1.left_stick_x, gamepad1.right_stick_x);

What if a control reversed?

Due to how your mecanum train may be built, some controls may be reversed, if something is reversed, then add a subtraction sign before what control is reversed.

Like so:

// This example shows if forward is reversed, since forward is reversed, i will add a - before the forward control

// Forward Strafe Turn
mecanum.powerDrive(-gamepad1.left_stick_y, gamepad1.left_stick_x, gamepad1.right_stick_x);

Full example

This example uses all code above, and a basic op-mode.

package org.firstinspires.ftc.teamcode.driverop;

import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import org.ftc17191.ftclayer.drivetrain.mecanum.Mecanum;

public class CodeExample extends LinearOpMode
{
Mecanum mecanum;

@Override
public void runOpMode(){

waitForStart();
mecanum = new Mecanum(hardwareMap,
"front_right",
"front_left",
"back_right",
"back_left");
while (opModeIsActive())
{
mecanum.powerDrive(gamepad1.left_stick_y,
gamepad1.left_stick_x,
gamepad1.right_stick_x);
}
}
}