In Project 4 you ran the launcher open-loop at 85%. The problem: after each ball, the wheel slows down and the next shot is weaker until it recovers. Closed-loop control fixes this by measuring the wheel's speed and correcting toward a target. For REBUILT's Hub scoring, shot consistency is what turns a good launcher into a ranking-point machine.
The two halves. WPILib's recommended approach combines feedforward and feedback:
- Feedforward predicts the voltage needed to hold a speed, using a physics model. For a flywheel:
voltage = kS + kV*velocity + kA*acceleration. TheSimpleMotorFeedforwardclass implements exactly this. - Feedback (PID) corrects the small remaining error.
PIDControllercomputes a correction from the difference between the target and the measured velocity.
You add their outputs together — feedforward does the heavy lifting, PID cleans up.
Getting the gains with SysId. Do not guess kS/kV/kA. WPILib's SysId tool does this rigorously: you add a characterization routine that drives the mechanism through quasi-static and dynamic tests while logging voltage and velocity. After the run, you load the log into the SysId app, which fits a model and outputs kS, kV, kA, plus suggested PID gains. (For a drivetrain, SysId needs clear travel space; a flywheel needs none.)
private final SimpleMotorFeedforward m_ff =
new SimpleMotorFeedforward(kS, kV, kA); // from SysId
private final PIDController m_pid =
new PIDController(kP, 0, 0); // from SysId
public void runFlywheel(double targetRPS) {
double measured = m_encoder.getVelocity(); // rotations/sec
double ff = m_ff.calculate(targetRPS);
// PIDController.calculate(measurement, setpoint): measured first
double fb = m_pid.calculate(measured, targetRPS);
m_motor.setVoltage(ff + fb);
}
Note the argument order: PIDController.calculate(measurement, setpoint) takes the measured value first and the setpoint second — getting these backwards is a common bug.
Tuning intuition. With good feedforward, the wheel reaches and holds target with very little PID effort. Raise kP until the wheel recovers quickly after a shot without oscillating. If it oscillates, lower kP. The WPILib flywheel-tuning guide walks through this exact loop. Velocity control like this is forgiving — flywheels are nearly the textbook case for feedforward.
The payoff: a characterized launcher returns to target RPM quickly between shots, so every Fuel leaves at the same speed and lands in the Hub. That repeatability is what lets a team chain enough scores to reach the Energized (100 Fuel) and Supercharged (360 Fuel) ranking-point thresholds reliably instead of hoping.
Key takeaways
- Combine SimpleMotorFeedforward (kS+kV*v+kA*a) with a PIDController and add their outputs — feedforward leads, PID corrects
- PIDController.calculate takes (measurement, setpoint) — measured first; use SysId to measure kS/kV/kA instead of guessing
- A characterized flywheel recovers to target RPM between shots, giving the shot consistency needed for the Energized/Supercharged RPs
Keep going
Take the quiz · +10 XP with an accountMore in Advanced Techniques & Case Studies
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
- Combining Feedforward and PID (WPILib)docs.wpilib.org
- Tuning a Flywheel Velocity Controller (WPILib)docs.wpilib.org
- Introduction to System Identification / SysId (WPILib)docs.wpilib.org
Read next
Articles on this, for competition day
The lesson covers how it works. These cover what to do when it breaks.
- 17 min read
FRC Flywheel Shooter Design: Compression, Speed, Backspin, and Hooding
How to design an FRC flywheel shooter: exit velocity, compression, flywheel inertia and RPM recovery, single vs dual wheels, backspin, hooding, motors, and tuning.
Read - 4 min read
PID Control in FRC, Explained Simply
A beginner-friendly guide to PID control in FRC: what kP, kI, and kD actually do, how to tune them, and why most teams skip the I term.
Read - 8 min read
How to Tune PID on an FRC Robot: A Practical Guide
A hands-on guide to tuning PID and feedforward on FRC mechanisms: a safe tuning order, fixing oscillation and steady-state error, and using WPILib SysId.
Read
Lesson quiz
RequiredAll 3 right completes the lesson. Miss one and only that question comes back — anything you already answered correctly stays banked.
0 of 3 answered
01.In WPILib's SimpleMotorFeedforward, what does the kV (velocity) gain primarily account for?
02.Per WPILib, what is the correct way to combine a feedforward controller with a PID feedback controller for a flywheel?
03.Why is a flywheel shooter considered an ideal candidate for feedforward control?
Answer every question to submit.
All 28 lessons in Getting Started with FRC
- Not started:Project 1 — Make a NEO Spin with the REV Hardware Client
- Not started:Project 2 — Deploy a Real Arcade-Drive Program
- Not started:Project 3 — Refactor into a Command-Based Drive Subsystem
- Not started:Project 4 — Build a Fuel Launcher for REBUILT
- Not started:Project 5 — A One-Button Autonomous Routine
- Not started:The Connection Chain: When the Driver Station Won't Connect
- Not started:Brownouts: Why the Robot Goes Limp Mid-Match
- Not started:CAN Bus Gremlins: Missing and Conflicting Devices
- Not started:Software Gotchas: Inverted Drives, Scheduler Stalls, and Reading the RioLog
- Not started:Inspection-Day Failures: Bumpers, Size, and Weight
- Not started:Closed-Loop Control: PID + Feedforward for a Consistent Shot
- Not started:Swerve Drive: Omnidirectional Movement with YAGSL
- Not started:AprilTag Vision: Knowing Where You Are with PhotonVision
- Not started:Data-Driven Strategy: Scouting, EPA/OPR, and Alliance Selection
- Not started:Choosing Your Hardware Ecosystem: REV vs CTRE