WPILib 2012
WPILibRoboticsLibraryforFRC
|
#include <PIDController.h>
Public Member Functions | |
PIDController (float p, float i, float d, PIDSource *source, PIDOutput *output, float period=0.05) | |
virtual | ~PIDController () |
virtual float | Get () |
virtual void | SetContinuous (bool continuous=true) |
virtual void | SetInputRange (float minimumInput, float maximumInput) |
virtual void | SetOutputRange (float mimimumOutput, float maximumOutput) |
virtual void | SetPID (float p, float i, float d) |
virtual float | GetP () |
virtual float | GetI () |
virtual float | GetD () |
virtual void | SetSetpoint (float setpoint) |
virtual float | GetSetpoint () |
virtual float | GetError () |
virtual void | SetTolerance (float percent) |
virtual bool | OnTarget () |
virtual void | Enable () |
virtual void | Disable () |
virtual bool | IsEnabled () |
virtual void | Reset () |
Class implements a PID Control Loop.
Creates a separate thread which reads the given PIDSource and takes care of the integral calculations, as well as writing the given PIDOutput
PIDController::PIDController | ( | float | Kp, |
float | Ki, | ||
float | Kd, | ||
PIDSource * | source, | ||
PIDOutput * | output, | ||
float | period = 0.05 |
||
) |
Allocate a PID object with the given constants for P, I, D
Kp | the proportional coefficient |
Ki | the integral coefficient |
Kd | the derivative coefficient |
source | The PIDSource object that is used to get values |
output | The PIDOutput object that is set to the output value |
period | the loop time for doing calculations. This particularly effects calculations of the integral and differental terms. The default is 50ms. |
PIDController::~PIDController | ( | ) | [virtual] |
Free the PID object
void PIDController::Disable | ( | ) | [virtual] |
Stop running the PIDController, this sets the output to zero before stopping.
Reimplemented in SendablePIDController.
void PIDController::Enable | ( | ) | [virtual] |
Begin running the PIDController
Reimplemented in SendablePIDController.
float PIDController::Get | ( | ) | [virtual] |
Return the current PID result This is always centered on zero and constrained the the max and min outs
float PIDController::GetD | ( | ) | [virtual] |
Get the Differential coefficient
float PIDController::GetError | ( | ) | [virtual] |
Retruns the current difference of the input from the setpoint
float PIDController::GetI | ( | ) | [virtual] |
Get the Integral coefficient
float PIDController::GetP | ( | ) | [virtual] |
Get the Proportional coefficient
float PIDController::GetSetpoint | ( | ) | [virtual] |
Returns the current setpoint of the PIDController
bool PIDController::IsEnabled | ( | ) | [virtual] |
Return true if PIDController is enabled.
void PIDController::Reset | ( | ) | [virtual] |
Reset the previous error,, the integral term, and disable the controller.
void PIDController::SetContinuous | ( | bool | continuous = true | ) | [virtual] |
Set the PID controller to consider the input to be continuous, Rather then using the max and min in as constraints, it considers them to be the same point and automatically calculates the shortest route to the setpoint.
continuous | Set to true turns on continuous, false turns off continuous |
void PIDController::SetInputRange | ( | float | minimumInput, |
float | maximumInput | ||
) | [virtual] |
Sets the maximum and minimum values expected from the input.
minimumInput | the minimum value expected from the input |
maximumInput | the maximum value expected from the output |
void PIDController::SetOutputRange | ( | float | minimumOutput, |
float | maximumOutput | ||
) | [virtual] |
Sets the minimum and maximum values to write.
minimumOutput | the minimum value to write to the output |
maximumOutput | the maximum value to write to the output |
void PIDController::SetPID | ( | float | p, |
float | i, | ||
float | d | ||
) | [virtual] |
Set the PID Controller gain parameters. Set the proportional, integral, and differential coefficients.
p | Proportional coefficient |
i | Integral coefficient |
d | Differential coefficient |
void PIDController::SetSetpoint | ( | float | setpoint | ) | [virtual] |
Set the setpoint for the PIDController
setpoint | the desired setpoint |
Reimplemented in SendablePIDController.