A control scheme is doing its job when the driver stops noticing it. They think "go there" and the robot goes there. The scheme below is WPILib command-based Java, written for an actual competition driver.
Start in RobotContainer with a CommandXboxController on port 0. WPILib gives you named factory methods for every button, so you bind declaratively instead of polling in a loop.
private final CommandXboxController driver = new CommandXboxController(0);
private final DriveSubsystem drive = new DriveSubsystem();
private void configureBindings() {
// Default command: field-relative joystick drive every loop
drive.setDefaultCommand(drive.run(() -> drive.driveFieldRelative(
-driver.getLeftY(), // forward (Y is inverted on Xbox sticks)
-driver.getLeftX(), // strafe
-driver.getRightX() // rotation
)));
// Reset field-relative heading to "away from driver station"
driver.start().onTrue(drive.runOnce(drive::zeroHeading));
// Hold left bumper for precision/slow mode
driver.leftBumper().whileTrue(drive.run(() -> drive.driveFieldRelative(
-driver.getLeftY() * 0.35,
-driver.getLeftX() * 0.35,
-driver.getRightX() * 0.35)));
}
Those minus signs matter. Xbox sticks report +1 when pulled toward the driver, so forward needs a negative sign, and forgetting it is the single most common day-one bug.
onTrue and whileTrue are the two binding methods you will use most. onTrue runs once on a rising edge, which is what a gyro reset needs. whileTrue runs while the button is held and cancels on release, which is what slow mode needs.
Slow mode here is a scale factor rather than a separate command tree. Multiplying the inputs by 0.35 gives about one-third speed for lining up on the HUB or playing careful defense, and you don't have to duplicate any logic.
Apply a deadband so a drifting stick doesn't creep the robot. MathUtil.applyDeadband(value, 0.1) is the idiomatic call. The DifferentialDrive class already applies 0.02 internally, but in swerve code you apply your own, and 0.05 to 0.10 is typical.
double x = MathUtil.applyDeadband(-driver.getLeftX(), 0.1);
Write the physical mapping down and tape it to the operator console: Left stick = translate, Right stick = rotate, Start = reset gyro, Left bumper = slow. Hand that card to a substitute driver and they should be able to drive a qualification match cold.
Test it on blocks first, then on the practice field. Drive a figure-eight around two cones. If the robot tracks where you point in field-relative mode no matter which way the bumper is facing, your gyro and inversions are correct.
Key takeaways
- Use CommandXboxController factory methods (start(), leftBumper()) with onTrue for one-shot actions and whileTrue for held actions.
- Invert Xbox Y axes for forward, and apply your own deadband (0.05-0.10) on swerve before scaling for slow mode.
- Document the physical button map on a card at the operator console so any driver can run a match.
Keep going
Take the quiz · +10 XP with an accountMore in Worked Examples & Mini-Projects
Sources & corrections
This lesson is AI-assisted: drafted from primary sources, then reviewed and edited by hand. Errors still get through. When one is reported we fix it and write down what changed — publicly, in the corrections log.
Sources and further reading
- WPILib: Binding Commands to Triggersdocs.wpilib.org
- WPILib: Joystick & Controller Inputdocs.wpilib.org
Read next
Articles on this, for competition day
The lesson covers how it works. These cover what to do when it breaks.
- 13 min read
FRC Code Structure Best Practices: Command-Based Project Architecture
How to structure an FRC command-based robot project the right way — subsystems, commands, RobotContainer, and Constants — verified against official WPILib docs.
Read - 20 min read
How to Program FRC Swerve Drive with WPILib
A practical guide to programming FRC swerve drive with WPILib: kinematics, SwerveModuleState, field-relative control, odometry, and where PathPlanner fits.
Read - 15 min read
FRC Odometry and Pose Estimation: Field-Centric Control with WPILib
How an FRC robot tracks its field position with WPILib: wheel odometry vs pose estimation, gyro heading, fusing AprilTag vision, and field-centric driving.
Read
Lesson quiz
RequiredAll 4 right completes the lesson. Miss one and only that question comes back — anything you already answered correctly stays banked.
0 of 4 answered
01.How is the gyro/heading reset typically wired to the controller in an FRC driver control scheme?
02.Why does a production driver-control scheme apply a joystick deadband?
03.How is precision/slow mode typically implemented when the left bumper is held?
04.Why is the Xbox controller's Y axis negated when commanding forward drive?
Answer every question to submit.
All 34 lessons in Drive Team
- Not started:Project 1: A Production-Ready Driver Control Scheme
- Not started:Project 2: A Drivetrain That Survives a Whole Match
- Not started:Project 3: Build a Paper + Spreadsheet Scouting System
- Not started:Project 4: Pull Live OPR & EPA Data with Python
- Not started:Project 5: The One-Page Pre-Match Strategy Brief