Feedforward uses a model of your mechanism to predict the motor voltage needed for a desired motion, rather than waiting for error like PID. Feedforward does most of the work; PID corrects the rest. This is the single biggest upgrade most teams can make to their control quality.
The constants#
Feedforward voltage is built from terms, each a physical effect:
- kS (static friction): the constant voltage needed just to overcome friction and start moving. Applied in the direction of motion.
- kV (velocity): volts needed per unit of velocity. Because a DC motor's back-EMF rises with speed, holding a steady velocity needs voltage proportional to that velocity. kV is usually the dominant term.
- kA (acceleration): volts needed per unit of acceleration, accounting for inertia. Often small; can be left at zero for simple mechanisms.
- kG (gravity): volts needed to counteract gravity. This term differs by mechanism type.
WPILib feedforward classes#
WPILib provides three, matching common mechanisms:
SimpleMotorFeedforward(flywheels, drivetrains):volts = kS*sign(v) + kV*v + kA*a. No gravity term, since these mechanisms have no significant gravitational load.ElevatorFeedforward(elevators): adds a constantkGbecause gravity pulls the elevator down the same amount at every height:volts = kS*sign(v) + kG + kV*v + kA*a.ArmFeedforward(arms/pivots):kGis multiplied by cos(angle) because gravity's torque on an arm depends on its angle — maximum when horizontal, zero when vertical:volts = kS*sign(v) + kG*cos(theta) + kV*v + kA*a(theta measured from horizontal).
SimpleMotorFeedforward ff = new SimpleMotorFeedforward(kS, kV, kA);
double ffVolts = ff.calculate(targetVelocity);
double pidVolts = pid.calculate(encoder.getRate(), targetVelocity);
motor.setVoltage(ffVolts + pidVolts);
Why feedforward beats more integral#
WPILib explicitly recommends a steady-state feedforward over relying on integral control. A good kV/kG predicts the holding voltage exactly, so PID has almost no error to integrate — giving faster, more stable, more repeatable motion, especially across the changing battery voltage of a match (which is why you command volts, not raw duty cycle).
the part worth keeping
Key takeaways
- Feedforward predicts the needed voltage from a model; PID only cleans up the small leftover error.
- kS = friction, kV = volts per velocity (usually dominant), kA = volts per acceleration, kG = gravity.
- Use ArmFeedforward (kG*cos(angle)) for arms, ElevatorFeedforward (constant kG) for elevators, SimpleMotorFeedforward (no kG) for flywheels/drives.
Programming, Controls & SensorsClosed-Loop Control: PID, Feedforward, and SysIdlesson 3 of 4
Keep going
Take the quiz+10 XP with an accountMore in Closed-Loop Control: PID, Feedforward, and SysId
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.orgWPILib: Feedforward Control in WPILib
- docs.wpilib.orgWPILib: Combining Feedforward and PID
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.
- 16 min readFRC Elevator and Arm Design: Staging, Rigging, Motors, Gravity, and SafetyA primary-source FRC guide to designing elevators and arms: cascade vs continuous rigging, staging, motor and gear-ratio sizing, gravity math, and safe holding./blogread it
- 7 min readFRC Motion Profiling Explained: TrapezoidProfile and ProfiledPIDControllerHow WPILib's TrapezoidProfile and ProfiledPIDController smooth mechanism motion, how to pick velocity and acceleration constraints, and when a profile beats plain PID./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
01What does the kV (velocity) feedforward gain represent?
02What does the kS feedforward gain account for?
03How is the gravity gain kG applied differently for an elevator versus a single-jointed arm?
Answer every question to submit.
All 51 lessons in Programming, Controls & Sensorsopenclose
01 / prerequisites
02 / foundations-tools-and-first-program
03 / robot-program-and-command-based
04 / motors-and-control
05 / autonomous-trajectories-simulation
06 / sensing-fundamentals
07 / encoders
08 / gyros-imus-orientation
09 / closed-loop-control
10 / vision-pose-estimation
11 / worked-examples-mini-projects
- Not read yet:Mini-Project: A Closed-Loop Elevator with Motion Magic
- Not read yet:Mini-Project: A Velocity-Controlled Shooter on REVLib
- Not read yet:Mini-Project: A Teleop Swerve Drive Subsystem
- Not read yet:Mini-Project: An Autonomous Routine with PathPlanner
- Not read yet:Mini-Project: Vision-Aligned Scoring with Limelight
12 / common-mistakes-troubleshooting
13 / advanced-techniques-case-studies
- Not read yet:State-Space Control and Kalman Filtering
- Not read yet:Log Replay Architecture with AdvantageKit
- Not read yet:Advanced Pose Estimation: Multi-Tag Fusion and Standard Deviations
- Not read yet:Robot Coordination, Alerts, and Operator Feedback
- Not read yet:Case Study: Hardening Software Before an Event