03 / TeleOp and Mecanum
Field-Centric Driving
Rotate joystick input by robot heading so controls stay aligned to the field.
03 / TeleOp and Mecanum
Rotate joystick input by robot heading so controls stay aligned to the field.
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.
In robot-centric drive, forward means the front of the robot. In field-centric drive, forward means away from the driver station or another field reference. This can make TeleOp easier when the robot is turned around.
The joystick x/y vector is rotated by the negative robot heading before mecanum powers are calculated. If heading is wrong, the entire drive will feel rotated.
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.
FieldCentricSnippet.java · Java
if (gamepad1.options) {
robot.imu.resetYaw();
}
double y = -gamepad1.left_stick_y;
double x = gamepad1.left_stick_x;
double rx = gamepad1.right_stick_x;
double heading = robot.imu.getRobotYawPitchRollAngles().getYaw(AngleUnit.RADIANS);
double rotX = x * Math.cos(-heading) - y * Math.sin(-heading);
double rotY = x * Math.sin(-heading) + y * Math.cos(-heading);
double denominator = Math.max(Math.abs(rotY) + Math.abs(rotX) + Math.abs(rx), 1.0);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 input is required for field-centric drive?
0 of 1 answered
References
Finished reading?
You'll move on to “Driver Ergonomics and Safe TeleOp” next.