12 / Driver Control
Driver Control
Turn gamepad input into predictable mecanum movement.
12 / Driver Control
Turn gamepad input into predictable mecanum movement.
You will
This lesson is about the interface between drivers and robot behavior. Good TeleOp code is not just mathematically correct; it is predictable under pressure, easy to recover, and readable enough that the drive team can describe what the robot is supposed to do.
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.
Mecanum formulas can produce values above 1.0. Normalizing keeps the ratio between wheels while staying inside the legal motor power range.
Test driver code in movement primitives and mechanism primitives instead of full-match chaos. Add deadbands, slow modes, edge detection, and safe states only after students can explain the raw input and final output for each control.
For this specific lesson, students should first restate the goal in robot terms, then identify the value or behavior they expect to observe, then run the smallest test that proves the idea. The lesson should feel like a guided lab: predict, run, observe, explain, and only then extend.
MecanumTeleOp.java · Java
double drive = -gamepad1.left_stick_y; double strafe = gamepad1.left_stick_x; double turn = gamepad1.right_stick_x; 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);
When TeleOp feels wrong, translate driver feedback into small tests: forward, strafe, rotate, precision mode, button press, held button, and safe recovery. Print raw inputs and final commands so the team can separate driver feel from wiring, math, and mechanism bugs.
Check your understanding
What should you check first when robot code does not behave as expected?
0 of 1 answered
References
Finished reading?
You'll move on to “Simple Autonomous” next.