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).
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.
Keep going
Take the quiz · +10 XP with an accountMore in Closed-Loop Control: PID, Feedforward, and SysId
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: Feedforward Control in WPILibdocs.wpilib.org
- WPILib: Combining Feedforward and PIDdocs.wpilib.org
Read next
Articles on this, for competition day
The lesson covers how it works. These cover what to do when it breaks.
- 16 min read
FRC Elevator and Arm Design: Staging, Rigging, Motors, Gravity, and Safety
A primary-source FRC guide to designing elevators and arms: cascade vs continuous rigging, staging, motor and gear-ratio sizing, gravity math, and safe holding.
Read - 7 min read
FRC Motion Profiling Explained: TrapezoidProfile and ProfiledPIDController
How WPILib's TrapezoidProfile and ProfiledPIDController smooth mechanism motion, how to pick velocity and acceleration constraints, and when a profile beats plain PID.
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.What does the kV (velocity) feedforward gain represent?
02.What does the kS feedforward gain account for?
03.How 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 & Sensors
- Not started:Mini-Project: A Closed-Loop Elevator with Motion Magic
- Not started:Mini-Project: A Velocity-Controlled Shooter on REVLib
- Not started:Mini-Project: A Teleop Swerve Drive Subsystem
- Not started:Mini-Project: An Autonomous Routine with PathPlanner
- Not started:Mini-Project: Vision-Aligned Scoring with Limelight
- Not started:State-Space Control and Kalman Filtering
- Not started:Log Replay Architecture with AdvantageKit
- Not started:Advanced Pose Estimation: Multi-Tag Fusion and Standard Deviations
- Not started:Robot Coordination, Alerts, and Operator Feedback
- Not started:Case Study: Hardening Software Before an Event