How do you Tune the PID Values?

For teleop, just do this:

SmartDashboard.putData("PID Controller",controller);

controller can be replaced by subsystem.getPIDController().

Also, in terms of actual tuning techniques, here’s the procedure I use:

  • Raise the P constant until your controller oscillates. If the oscillations are too big, lower the constant a little bit.
  • Raise the D constant to damp the oscillation, causing it to converge. D also slows down the controller’s approach to the setpoint, so striking a balance between P and D can take some tweaking.
  • If you have P and D tuned, and it oscillates & converges, but not to the correct setpoint, increase I. This is called “steady-state error” and a positive, non-zero integral constant will cause the controller to correct for it.

In general, P makes approach faster, but can cause larger oscillations; D causes oscillations to converge, but slows approach; and I can correct for steady-state error and causes faster approach, but can lead to intense oscillations if set too high (search “integral windup” for more details).

2 Likes