Class PidConfig

java.lang.Object
frc.robot.shared.config.AbstractConfig
frc.robot.shared.config.PidConfig

public class PidConfig extends AbstractConfig
Configuration bundle for PID controller gains.

Embed an instance of this class in any motor subsystem config that uses a PID controller. All three gains are surfaced to SmartDashboard so they can be tuned live without redeploying.

  • Field Details

    • kP

      public double kP
      Proportional gain for the controller.
    • kI

      public double kI
      Integral gain for the controller.
    • kD

      public double kD
      Derivative gain for the controller.
    • iZone

      public double iZone
      Maximum error (in process-variable units) at which the integral term accumulates.

      When the absolute error exceeds this value, the integral accumulator is reset to zero. This prevents the integral term from winding up during large transients (such as spin-up) where integral action would cause overshoot. Set to zero to disable IZone (the integral accumulates at all error magnitudes). The value is in the same units as the PID measurement — radians per second for velocity loops, radians for position loops.

    • integratorRangeMax

      public double integratorRangeMax
      Maximum absolute value of the integral term's output contribution in volts.

      The WPILib PIDController clamps the integral accumulator so that kI * accumulator never exceeds this range. This prevents integral windup from producing large voltage spikes after sustained error. Set to zero to use the WPILib default range of ±1.0.

  • Constructor Details

    • PidConfig

      public PidConfig()
  • Method Details

    • getkP

      public double getkP()
      Returns the proportional gain, tuned via SmartDashboard.
      Returns:
      kP
    • getkI

      public double getkI()
      Returns the integral gain, tuned via SmartDashboard.
      Returns:
      kI
    • getkD

      public double getkD()
      Returns the derivative gain, tuned via SmartDashboard.
      Returns:
      kD
    • getIZone

      public double getIZone()
      Returns the IZone threshold, tuned via SmartDashboard.

      A value of zero means IZone is disabled and the integral accumulates at all error magnitudes.

      Returns:
      IZone threshold in process-variable units (rad/s for velocity, rad for position), or zero to disable
    • getIntegratorRangeMax

      public double getIntegratorRangeMax()
      Returns the maximum integrator output range, tuned via SmartDashboard.

      A value of zero means the WPILib default range of ±1.0 is used.

      Returns:
      maximum absolute integrator output in volts, or zero for the default