MecanumDrive
3 Mecanum Drive
A mecanum drivetrain uses four mecanum wheels to combine forward movement, sideways movement, and rotation. Translation can change direction without requiring the robot to turn first. Rotation remains a separate input that changes the robot heading.
Creating a mecanum drive
Provide four initialized EasyMotor objects in this order: frontLeft, frontRight, backLeft, backRight. The order matters because each position receives a different mixture of strafe and turn.
import dev.easyfamily.easystack.drivebase.MecanumDrive;
MecanumDrive drive = new MecanumDrive(
frontLeft, frontRight, backLeft, backRight
);
drive.setMaxOutput(0.75);Right side inversion
The constructor above enables automatic right side inversion. The explicit equivalent starts with true. To disable it, put false before the four motors.
MecanumDrive drive = new MecanumDrive(
false, frontLeft, frontRight, backLeft, backRight
);
drive.setRightSideInverted(true);
boolean inverted = drive.isRightSideInverted();The inversion multiplier is applied to the front right and back right outputs after wheel mixing. Configure it together with the motor directions, rather than assuming that the default matches every mounting arrangement.
setMaxOutput() returns the MecanumDrive instance, so it can be chained with setRightSideInverted(). The default maximum output inherited from RobotDrive is 1.0.
Mecanum robot centric control
Robot centric movement is relative to the robot. A forward request follows the direction the robot currently faces. A strafe request moves along the robot’s sideways axis, regardless of its orientation on the field.
Supplying driver inputs
driveRobotCentric() takes strafe, forward, and turn, in that order. A common FTC mapping uses left stick X for strafe, negative left stick Y for forward, and right stick X for rotation.
drive.driveRobotCentric(
gamepad1.left_stick_x,
-gamepad1.left_stick_y,
gamepad1.right_stick_x
);Each axis is clipped to −1 through 1 before mixing. The implementation uses the translation vector’s angle and magnitude to construct wheel commands, adds rotation, and then normalizes if a command exceeds magnitude 1. maxOutput and right side inversion are applied afterward.
Squared inputs
The optional fourth argument enables signed squaring for all three movement inputs. Small joystick movements produce smaller commands, which can make precise positioning easier.
drive.driveRobotCentric(
gamepad1.left_stick_x,
-gamepad1.left_stick_y,
gamepad1.right_stick_x,
true
);This is input shaping, not a deadband or a speed controller. The wheel commands remain power requests, and no measured wheel velocity is used by this class.
When using drive(new DrivePowers(...)), remember that the object constructor takes forward first. The adapter rearranges its values correctly and calls robot centric driving without squared inputs.
Direct wheel commands
driveWithMotorPowers(frontLeft, frontRight, backLeft, backRight) applies four direct inputs in constructor order. It still uses maxOutput and right side inversion, but does not clip or normalize those inputs. For example, four values of 0.2 request equal wheel commands before right side inversion.
stop() sets all four motor powers to zero. Call it when control ends, even if your final joystick request was already zero.
Mecanum field centric control
Field centric control interprets translation relative to a field reference. The drivebase rotates the requested translation by the negative of the supplied robot heading before calculating wheel powers. Rotation input is handled separately.
Providing the heading
driveFieldCentric() takes strafe, forward, turn, and heading. Heading must be in radians. The drivebase does not read or initialize an IMU, so your program must provide a current heading with the correct sign and zero reference.
double headingRadians = Math.toRadians(headingDegrees);
drive.driveFieldCentric(
gamepad1.left_stick_x,
-gamepad1.left_stick_y,
gamepad1.right_stick_x,
headingRadians
);If your sensor already returns radians, pass that value directly. Do not convert it a second time. A heading of zero gives the same coordinate transformation as robot centric driving.
Squaring the movement inputs
drive.driveFieldCentric(
gamepad1.left_stick_x,
-gamepad1.left_stick_y,
gamepad1.right_stick_x,
headingRadians,
true
);The boolean squares strafe, forward, and turn; it does not square heading. For predictable driver control, define heading zero while the robot is aligned with your chosen field reference. A reversed sensor sign or an incorrect zero makes the translation rotate in an unexpected direction.
This method transforms a driver request. It does not estimate field position, drive to a pose, or follow a path by itself.
Mecanum control example
This reusable helper chooses robot centric or field centric control while keeping the same stick mapping. Pass an existing MecanumDrive, call update() each active loop, and supply a fresh heading when field centric control is enabled.
import com.qualcomm.robotcore.hardware.Gamepad;
import dev.easyfamily.easystack.drivebase.MecanumDrive;
public class MecanumControls {
private final MecanumDrive drive;
public MecanumControls(MecanumDrive drive) {
this.drive = drive;
drive.setMaxOutput(0.75);
}
public void update(Gamepad pad, double headingRadians,
boolean fieldCentric) {
double strafe = pad.left_stick_x;
double forward = -pad.left_stick_y;
double turn = pad.right_stick_x;
if (fieldCentric) {
drive.driveFieldCentric(strafe, forward,
turn, headingRadians, true); } else {
drive.driveRobotCentric(strafe, forward,
turn, true);
}
}
public void stop() {
drive.stop();
}
}Mecanum setup checks
If strafe behaves like forward, check the input order: driveRobotCentric() takes strafe first, while DrivePowers takes forward first. Also verify the four motor positions and right side inversion.
If field centric translation rotates incorrectly, check heading units, sign, zero reference, and freshness. Heading must be supplied in radians.
Last updated 2026-11-16