Skip to content
learnFRC.org
resource

PID Playground & Simulators

Visualizing closed-loop feedback and feedforward control in real time using interactive simulators.

Understanding closed-loop control through equations alone can be difficult. Visual simulators provide real-time feedback on how controller gains affect setpoint tracking, disturbance rejection, and stability.

Experiment with feedforward and feedback gains below. Observe how changing kGkG (gravity), kVkV (velocity), kSkS (friction), kPkP (spring pull), and kDkD (damping) changes the response curve.

Closed-Loop PID & Feedforward Simulator

Live Response Graph (Target vs Actual)
Target Setpoint Mechanism Position / Velocity Motor Voltage (-12V to +12V)
Physical Mechanism Visualizer
Error: 0.00
Voltage: 0.00 V
Velocity: 0.00
Setpoint & Physics
Feedforward Gains
Feedforward predicts the voltage required by mechanism physics before error occurs.
PID Feedback Gains
Feedback corrects for error: kP drives toward setpoint; kD dampens oscillation.
  1. The Gravity Droop Test (“Untuned Elevator” Preset):
    • Select the Elevator: Pure P (Gravity Sag Error) preset.
    • Notice that with kP=0.15kP = 0.15 and zero feedforward (kG=0kG = 0), the elevator stalls significantly below the target setpoint.
    • Gradually increase Gravity Feedforward (kGkG) to 1.20 V. Watch the elevator rise to the target setpoint without modifying kPkP.
  2. The Integral Windup Demonstration (“High kI” Preset):
    • Select Elevator: High kI (Severe Integral Windup).
    • Notice how accumulated historical error creates a voltage spike that overshoots the target, resulting in sluggish, ringing oscillations.
  3. The Disturbance Rejection Test:
    • With the Elevator: Tuned PID + kG preset running, click Apply Disturbance Force (simulating game-piece contact or defense).
    • Observe how kPkP and kDkD catch the carriage and return it stably to the setpoint.
  4. Velocity Feedforward on Flywheels (“Tuned Flywheel” Preset):
    • Select the flywheel presets to see why kVkV provides instantaneous response at high rotational speeds without motor lag.

For additional multi-physics experiments, we also recommend PID Playground (pidexplained.com) as a companion resource.

  1. Proportional Gain (kPkP):
    • Start with kP=0kP = 0. Increase kPkP gradually until the mechanism responds toward the setpoint.
    • Observe the persistent steady-state error when friction or gravity opposes the system.
  2. Derivative Gain (kDkD):
    • Add kDkD to counteract oscillation and overshoot.
    • Notice how derivative gain acts like a virtual damper or shock absorber.
  3. Feedforward (kV,kGkV, kG):
    • Observe why adding feedforward eliminates steady-state error without needing aggressive integral gain (kIkI).
  4. Integral Windup (kIkI):
    • See how kIkI slowly accumulates error, and observe the overshoot when integral windup is not constrained.
Hands-On Practice

Before tuning an elevator or flywheel in Phoenix Tuner X, spend 10 minutes in the simulator tuning a system. Notice how adding feedforward dramatically reduces the required proportional gain.


WPILib includes built-in physics simulation for flywheels, elevators, single-jointed arms, and drivetrains:

  • Launch Command: In VS Code, press Ctrl + Shift + P and select WPILib: Simulate Robot Code on Desktop.
  • Keyboard & Gamepad Emulation: Connect an Xbox controller to your PC to test teleop driving and button triggers without needing physical robot hardware.
  • Mechanism2d Visualization: View 2D representations of moving elevators and rotating arms rendered in real time.