Skip to content
Drive Team·Lesson 27 of 34

Driving Feels Wrong: Inversions, Drift, and Field-Relative Confusion

Fix the everyday control bugs - backwards axes, creeping robots, and field-relative heading that points the wrong way.

Sign in to track progress, earn XP, and save lessons.

Symptom A — everything is backwards. Push forward, the robot reverses; turn left, it turns right. Cause: Xbox sticks report +1 toward the driver, so forward needs a negative sign; one missing negation flips an axis. Fix: Negate getLeftY() for forward and verify each axis independently on blocks: push forward -> robot drives away from you; push left -> strafes left. Change one sign, retest, repeat. Don't flip three signs at once or you'll chase your own tail.

Symptom B — the robot creeps when the sticks are centered. Cause: joysticks don't return to exactly 0.0; residual drift commands motion. Fix: apply a deadband. MathUtil.applyDeadband(value, 0.1) zeros out small inputs. DifferentialDrive applies 0.02 by default, but swerve code should add its own (0.05–0.10). If a stick drifts past your deadband, the controller hardware is worn — swap it; don't crank the deadband so high the robot feels numb.

Symptom C — field-relative points the wrong way after a bump or reboot. Cause: the gyro heading reference is wrong. Field-relative drive rotates joystick inputs by the gyro angle, so if zero isn't "downfield," everything is rotated. Fix: bind a gyro-reset button (driver.start().onTrue(drive.runOnce(drive::zeroHeading))) and press it while the robot faces directly downfield at match start. If heading drifts over a match, your gyro may need calibration time at boot (keep the robot still during robotInit) or a better-mounted IMU.

Diagnostic discipline: treat each of these as a one-variable experiment. Reproduce the symptom on blocks, form a specific hypothesis ("the Y axis sign is wrong"), make exactly one change, and re-test the same motion. Driving bugs feel mysterious because three small bugs at once produce chaos — but isolated, each one is trivial.

Prevent it: Write a 90-second pre-practice control check the drivers run every session: forward/back, left/right strafe, rotate both ways, slow mode, gyro reset facing downfield. If any axis is off, you catch it in the pit, not in a qualification match. The best drive teams treat the control scheme as flight-critical software and pre-flight it every single time.

Key takeaways

  • Backwards driving is almost always a missing axis negation; fix one sign at a time and retest on blocks.
  • Center-stick creep is solved with MathUtil.applyDeadband (0.05-0.10 for swerve); persistent drift past the deadband means worn hardware.
  • Wrong field-relative direction is a gyro reference problem - bind a zero-heading button and press it facing downfield at match start.

Lesson quiz

Required

Answer all 3 questions correctly to complete this lesson.

1.Field-relative driving sends the robot the wrong direction relative to the field. What must be correct for field-relative control to work?

2.By default, how do WPILib gyro conventions differ from the math used for field-relative swerve, and what's the common fix?

3.A swerve robot drifts sideways when translating and rotating at the same time, even with well-tuned modules. What addresses this?

Answer every question to submit.