WestlakeLEARN
FTC · Java

FIRST Tech Challenge

FTC · Java

  • Driver Control
  • Field-Centric Driving
  • Driver Ergonomics and Safe TeleOp
  • Write a Full Command-Based TeleOp

Driver Control

Turn gamepad input into predictable mecanum movement.

Module 5: TeleOp and Driver ControlCore

In this lesson, you will:

  1. 01Read joystick axes correctly.
  2. 02Combine drive, strafe, and turn values.
  3. 03Normalize motor powers before writing to hardware.

Driver code should feel boring

A driver should not need to understand your math during a match. Good TeleOp code makes common movement predictable and keeps surprises out of competition.

Normalize before sending power

Mecanum formulas can produce values above 1.0. Normalizing keeps the ratio between wheels while staying inside the legal motor power range.

Why the mecanum signs work

Every wheel gets the drive value because forward needs all four wheels. Strafe is added on one diagonal and subtracted on the other, which makes the rollers push sideways. Turn is added on the left side and subtracted on the right. If one movement misbehaves, check the sign pattern for that one input instead of rewriting all four lines.

Deadband prevents joystick drift

A joystick rarely rests at exactly zero. Treat small input values as zero before mixing the axes so the robot stays still when the driver releases the sticks.

Robot code habit

Show joystick inputs and calculated wheel powers together in telemetry when validating the sign pattern.

On-robot safety

Verify released-stick zero and wheel direction on blocks before testing combined motion on the floor.

MecanumTeleOp.javaJava

double drive = -gamepad1.left_stick_y;
double strafe = gamepad1.left_stick_x;
double turn = gamepad1.right_stick_x;

drive = Math.abs(drive) < 0.05 ? 0.0 : drive;
strafe = Math.abs(strafe) < 0.05 ? 0.0 : strafe;
turn = Math.abs(turn) < 0.05 ? 0.0 : turn;

double fl = drive + strafe + turn;
double fr = drive - strafe - turn;
double bl = drive - strafe + turn;
double br = drive + strafe - turn;

double max = Math.max(1.0, Math.max(
  Math.max(Math.abs(fl), Math.abs(fr)),
  Math.max(Math.abs(bl), Math.abs(br))
));

frontLeft.setPower(fl / max);
frontRight.setPower(fr / max);
backLeft.setPower(bl / max);
backRight.setPower(br / max);

Practice

With the robot on blocks first, verify that released sticks command zero. Then test forward, strafe, turn, and diagonal movement one input at a time before combining them on the floor.

Checks

  • Released sticks command zero power on all four motors.
  • Forward on the stick moves the robot forward.
  • A strafe command moves sideways without a strong unintended turn.
  • No motor receives power outside -1.0 to 1.0.

Lesson check

Check your understanding before moving on.

Why is gamepad1.left_stick_y negated in drive code?

What does dividing every wheel power by the max value accomplish?

0 of 2 answered

References

FTC DocsOfficial FTC SDK and robot programming documentation.Road Runner 1.0 DocsCurrent official setup guide. Confirm TeamCode's Gradle versions first; 1.0 is not compatible with 0.5.x examples.

Finished reading?

Mark this lesson complete — “Field-Centric Driving” is up next.

Voltage, Current Awareness, and Safe Test OpModesField-Centric Driving