|
Valkyrie 2026
|
#include <valkyrie/controllers/ProfiledPIDController.h>
Public Types | |
| using | ErrorDerivative = units::unit_t<units::compound_unit<INPUT, units::inverse<units::second>>> |
Public Member Functions | |
| constexpr | ProfiledPIDController (const PIDF< INPUT, OUTPUT > &pidf, units::second_t period=20_ms) |
| constexpr void | SetPID (const PIDF< INPUT, OUTPUT > &pidf) |
| constexpr void | SetIZone (PIDF< INPUT, OUTPUT >::Output_t iZone) |
| PIDF< INPUT, OUTPUT > | GetPID () const |
| constexpr PIDF< INPUT, OUTPUT >::Output_t | GetIZone () const |
| constexpr units::second_t | GetPeriod () const |
| constexpr PIDF< INPUT, OUTPUT >::Input_t | GetPositionTolerance () const |
| constexpr ErrorDerivative | GetVelocityTolerance () const |
| constexpr PIDF< INPUT, OUTPUT >::Input_t | GetAccumulatedError () const |
| constexpr void | SetGoal (frc::TrapezoidProfile< INPUT >::State goal) |
| constexpr frc::TrapezoidProfile< INPUT >::State | GetGoal () const |
| constexpr bool | AtGoal () const |
| constexpr frc::TrapezoidProfile< INPUT >::State | GetSetpoint () const |
| constexpr bool | AtSetpoint () const |
| constexpr void | EnableContinuousInput (PIDF< INPUT, OUTPUT >::Input_t minimumInput, PIDF< INPUT, OUTPUT >::Input_t maximumInput) |
| constexpr void | DisableContinuousInput () |
| constexpr void | SetIntegratorRange (PIDF< INPUT, OUTPUT >::Output_t minimumIntegral, PIDF< INPUT, OUTPUT >::Output_t maximumIntegral) |
| constexpr void | SetTolerance (PIDF< INPUT, OUTPUT >::Input_t positionTolerance, ErrorDerivative velocityTolerance=ErrorDerivative{std::numeric_limits< double >::infinity()}) |
| constexpr PIDF< INPUT, OUTPUT >::Input_t | GetPositionError () const |
| constexpr ErrorDerivative | GetVelocityError () const |
| constexpr PIDF< INPUT, OUTPUT >::Output_t | Calculate (PIDF< INPUT, OUTPUT >::Input_t measurement) |
| constexpr void | Reset (const frc::TrapezoidProfile< INPUT >::State &measurement) |
Implements a PID control loop whose setpoint is constrained by a trapezoid profile.
|
inlineconstexpr |
Allocates a ProfiledPIDController with the given constants for Kp, Ki, and Kd. Users should call reset() when they first start running the controller to avoid unwanted behavior.
| pidf | The PIDF gains |
| constraints | Velocity and acceleration constraints for goal. |
| period | The period between controller updates in seconds. The default is 20 milliseconds. Must be positive. |
|
inlineconstexpr |
Returns true if the error is within the tolerance of the error.
This will return false until at least one input value has been computed.
|
inlineconstexpr |
Returns true if the error is within the tolerance of the error.
Currently this just reports on target as the actual value passes through the setpoint. Ideally it should be based on being within the tolerance for some period of time.
This will return false until at least one input value has been computed.
|
inlineconstexpr |
Returns the next output of the PID controller.
| measurement | The current measurement of the process variable. |
|
inlineconstexpr |
Disables continuous input.
|
inlineconstexpr |
Enables continuous input.
Rather then using the max and min input range as constraints, it considers them to be the same point and automatically calculates the shortest route to the setpoint.
| minimumInput | The minimum value expected from the input. |
| maximumInput | The maximum value expected from the input. |
|
inlineconstexpr |
Gets the accumulated error used in the integral calculation of this controller.
|
inlineconstexpr |
Gets the goal for the ProfiledPIDController.
|
inlineconstexpr |
Get the IZone range.
|
inlineconstexpr |
Gets the period of this controller.
|
inline |
Gets the proportional coefficient.
|
inlineconstexpr |
Returns the difference between the setpoint and the measurement.
|
inlineconstexpr |
Gets the position tolerance of this controller.
|
inlineconstexpr |
Returns the current setpoint of the ProfiledPIDController.
|
inlineconstexpr |
Returns the change in error per second.
|
inlineconstexpr |
Gets the velocity tolerance of this controller.
|
inlineconstexpr |
Reset the previous error and the integral term.
| measurement | The current measured State of the system. |
|
inlineconstexpr |
Sets the goal for the ProfiledPIDController.
| goal | The desired unprofiled setpoint. |
|
inlineconstexpr |
Sets the minimum and maximum contributions of the integral term.
The internal integrator is clamped so that the integral term's contribution to the output stays between minimumIntegral and maximumIntegral. This prevents integral windup.
| minimumIntegral | The minimum contribution of the integral term. |
| maximumIntegral | The maximum contribution of the integral term. |
|
inlineconstexpr |
Sets the IZone range. When the absolute value of the position error is greater than IZone, the total accumulated error will reset to zero, disabling integral gain until the absolute value of the position error is less than IZone. This is used to prevent integral windup. Must be non-negative. Passing a value of zero will effectively disable integral gain. Passing a value of infinity disables IZone functionality.
| iZone | Maximum magnitude of error to allow integral control. Must be >= 0. |
|
inlineconstexpr |
Sets the PID Controller gain parameters.
Sets the proportional, integral, and differential coefficients.
| pidf | The PIDF gains |
|
inlineconstexpr |
Sets the error which is considered tolerable for use with AtSetpoint().
| positionTolerance | Position error which is tolerable. |
| velocityTolerance | Velocity error which is tolerable. |