A PID controller (Proportional, Integral, Derivative) is a fundamental feedback control algorithm in robotics. Given a desired setpoint and a measured physical process variable , the controller computes an output that drives the tracking error to zero.
u(t) = kP · e(t) + kI · ∫ e(τ) dτ + kD · (de(t)/dt)Experiment with live controller feedback in our PID & Feedforward Simulator to visualize how each term alters the closed-loop transient response.
The Three Terms Explained
Section titled “The Three Terms Explained”1. Proportional ()
Section titled “1. Proportional (kPkPkP)”The proportional term applies corrective output in direct proportion to the current error:
u_P(t) = kP · e(t)
- Physical Analogy: Behaves like a mechanical spring attached to the setpoint. The further the mechanism is from the target, the harder the controller pulls.
- Limitation: Proportional control alone cannot eliminate steady-state error in the presence of opposing forces like gravity or static friction ().
2. Derivative ()
Section titled “2. Derivative (kDkDkD)”The derivative term applies corrective output in proportion to the rate of change of error:
u_D(t) = kD · (de/dt) = -kD · (dy/dt)
- Physical Analogy: Behaves like a shock absorber or viscous damper. It resists rapid movement and prevents excessive overshoot.
- Limitation: Sensitive to sensor measurement noise. High-frequency encoder noise can be amplified by numerical differentiation.
3. Integral ()
Section titled “3. Integral (kIkIkI)”The integral term sums historical error over time:
u_I(t) = kI · ∫ e(τ) dτ
- Purpose: Eliminates persistent steady-state offsets that cannot overcome alone.
- Danger: Integral Windup: If a mechanism is stalled or moving toward a distant setpoint, the accumulated integral sum can grow excessively, causing overshoot and oscillation when arriving at the setpoint.
If an elevator or arm stops short of its target, do not increase or rely on . Add a gravity feedforward term () instead. Feedforward supplies continuous holding voltage, so only handles dynamic error correction.
Experiment with step responses, steady-state droop, and integral windup in the Interactive PID & Feedforward Simulator.
Tuning Heuristics
Section titled “Tuning Heuristics”When tuning mechanisms in Phoenix Tuner X or WPILib:
- Set Feedforward First: Tune (friction) and (velocity) or (gravity) with .
- Increase : Increase until the mechanism rapidly tracks step changes without violent oscillation.
- Add : Increase to dampen any overshoot or ringing at the arrival point.
- Avoid unless strictly necessary: For most FRC mechanisms (arms, elevators, swerve steering, flywheels), a calibrated feedforward model eliminates the need for integral gain, keeping for stable behavior.
Verified Sources & Standards
- WPILib PID Control in Modern Roboticsdocs.wpilib.orgWPILib Standard
- Controls Engineering in FRC (Tyler Veness)file.tavsys.netCommunity Reference