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.
the part worth keeping
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
Getting Started with FRCAdvanced Techniques & Case Studieslesson 1 of 5
Keep going
Take the quiz+10 XP with an accountMore in Advanced Techniques & Case Studies
where this came from
Sources and 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, in public, in the corrections log.
sources and further reading
- docs.wpilib.orgCombining Feedforward and PID (WPILib)
- docs.wpilib.orgTuning a Flywheel Velocity Controller (WPILib)
- docs.wpilib.orgIntroduction to System Identification / SysId (WPILib)
clipped to this lesson
Articles that go further on this
The lesson gets you through the topic. These go wider on it, and they read in one sitting.
- 17 min readFRC Flywheel Shooter Design: Compression, Speed, Backspin, and HoodingHow to design an FRC flywheel shooter: exit velocity, compression, flywheel inertia and RPM recovery, single vs dual wheels, backspin, hooding, motors, and tuning./blogread it
- 4 min readPID Control in FRC, Explained SimplyA 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./blogread it
- 8 min readHow to Tune PID on an FRC Robot: A Practical GuideA 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./blogread it
answer sheet
Lesson quiz
All 3 right completes the lesson. Miss one and only that question comes back, anything you already answered correctly stays banked.
0 of 3 answered
01In WPILib's SimpleMotorFeedforward, what does the kV (velocity) gain primarily account for?
02Per WPILib, what is the correct way to combine a feedforward controller with a PID feedback controller for a flywheel?
03Why is a flywheel shooter considered an ideal candidate for feedforward control?
Answer every question to submit.
All 28 lessons in Getting Started with FRCopenclose
01 / what-first-and-frc-are
02 / the-season-and-the-game
03 / culture-teams-and-roles
04 / getting-started-your-first-steps
05 / worked-examples-mini-projects
- Not read yet:Project 1 — Make a NEO Spin with the REV Hardware Client
- Not read yet:Project 2 — Deploy a Real Arcade-Drive Program
- Not read yet:Project 3 — Refactor into a Command-Based Drive Subsystem
- Not read yet:Project 4 — Build a Fuel Launcher for REBUILT
- Not read yet:Project 5 — A One-Button Autonomous Routine
06 / common-mistakes-troubleshooting
- Not read yet:The Connection Chain: When the Driver Station Won't Connect
- Not read yet:Brownouts: Why the Robot Goes Limp Mid-Match
- Not read yet:CAN Bus Gremlins: Missing and Conflicting Devices
- Not read yet:Software Gotchas: Inverted Drives, Scheduler Stalls, and Reading the RioLog
- Not read yet:Inspection-Day Failures: Bumpers, Size, and Weight
07 / advanced-techniques-case-studies
- Not read yet:Closed-Loop Control: PID + Feedforward for a Consistent Shot
- Not read yet:Swerve Drive: Omnidirectional Movement with YAGSL
- Not read yet:AprilTag Vision: Knowing Where You Are with PhotonVision
- Not read yet:Data-Driven Strategy: Scouting, EPA/OPR, and Alliance Selection
- Not read yet:Choosing Your Hardware Ecosystem: REV vs CTRE