Class PidConfig
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class frc.robot.shared.config.AbstractConfig
AbstractConfig.ComponentPoseConfig -
Field Summary
FieldsModifier and TypeFieldDescriptiondoubleMaximum absolute value of the integral term's output contribution in volts.doubleMaximum error (in process-variable units) at which the integral term accumulates.doubleDerivative gain for the controller.doubleIntegral gain for the controller.doubleProportional gain for the controller. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the maximum integrator output range, tuned via SmartDashboard.doublegetIZone()Returns the IZone threshold, tuned via SmartDashboard.doublegetkD()Returns the derivative gain, tuned via SmartDashboard.doublegetkI()Returns the integral gain, tuned via SmartDashboard.doublegetkP()Returns the proportional gain, tuned via SmartDashboard.Methods inherited from class frc.robot.shared.config.AbstractConfig
getDashboardPrefix, initializeNestedDashboardPrefixes, readTunableBoolean, readTunableDegrees, readTunableDegreesAsRadians, readTunableNumber, readTunableString, setDashboardPrefix
-
Field Details
-
kP
public double kPProportional gain for the controller. -
kI
public double kIIntegral gain for the controller. -
kD
public double kDDerivative gain for the controller. -
iZone
public double iZoneMaximum 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 integratorRangeMaxMaximum absolute value of the integral term's output contribution in volts.The WPILib PIDController clamps the integral accumulator so that
kI * accumulatornever 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
-