WPILibC++
2018.4.1-20180729124724-1140-gcbb62fb
|
Class implements a synchronous PID control loop. More...
#include <SynchronousPID.h>
Public Member Functions | |
SynchronousPID (double Kp, double Ki, double Kd, PIDSource &source, PIDOutput &output) | |
Allocate a PID object with the given constants for P, I, and D. More... | |
SynchronousPID (double Kp, double Ki, double Kd, double Kf, PIDSource &source, PIDOutput &output) | |
Allocate a PID object with the given constants for P, I, and D. More... | |
SynchronousPID (const SynchronousPID &)=delete | |
SynchronousPID & | operator= (const SynchronousPID)=delete |
void | Calculate () override |
Read the input, calculate the output accordingly, and write to the output. | |
![]() | |
PIDBase (double p, double i, double d, PIDSource &source, PIDOutput &output) | |
Allocate a PID object with the given constants for P, I, D. More... | |
PIDBase (double p, double i, double d, double f, PIDSource &source, PIDOutput &output) | |
Allocate a PID object with the given constants for P, I, D. More... | |
PIDBase (const PIDBase &)=delete | |
PIDBase & | operator= (const PIDBase)=delete |
virtual double | Get () const |
Return the current PID result. More... | |
virtual void | SetContinuous (bool continuous=true) |
Set the PID controller to consider the input to be continuous,. More... | |
virtual void | SetInputRange (double minimumInput, double maximumInput) |
Sets the maximum and minimum values expected from the input. More... | |
virtual void | SetOutputRange (double minimumOutput, double maximumOutput) |
Sets the minimum and maximum values to write. More... | |
void | SetPID (double p, double i, double d) override |
Set the PID Controller gain parameters. More... | |
virtual void | SetPID (double p, double i, double d, double f) |
Set the PID Controller gain parameters. More... | |
void | SetP (double p) |
Set the Proportional coefficient of the PID controller gain. More... | |
void | SetI (double i) |
Set the Integral coefficient of the PID controller gain. More... | |
void | SetD (double d) |
Set the Differential coefficient of the PID controller gain. More... | |
void | SetF (double f) |
Get the Feed forward coefficient of the PID controller gain. More... | |
double | GetP () const override |
Get the Proportional coefficient. More... | |
double | GetI () const override |
Get the Integral coefficient. More... | |
double | GetD () const override |
Get the Differential coefficient. More... | |
virtual double | GetF () const |
Get the Feed forward coefficient. More... | |
void | SetSetpoint (double setpoint) override |
Set the setpoint for the PIDBase. More... | |
double | GetSetpoint () const override |
Returns the current setpoint of the PIDBase. More... | |
double | GetDeltaSetpoint () const |
Returns the change in setpoint over time of the PIDBase. More... | |
virtual double | GetError () const |
Returns the current difference of the input from the setpoint. More... | |
virtual double | GetAvgError () const |
Returns the current average of the error over the past few iterations. More... | |
virtual void | SetPIDSourceType (PIDSourceType pidSource) |
Sets what type of input the PID controller will use. | |
virtual PIDSourceType | GetPIDSourceType () const |
Returns the type of input the PID controller is using. More... | |
virtual void | SetTolerance (double percent) |
Set the percentage error which is considered tolerable for use with OnTarget. More... | |
virtual void | SetAbsoluteTolerance (double absValue) |
Set the absolute error which is considered tolerable for use with OnTarget. More... | |
virtual void | SetPercentTolerance (double percentValue) |
Set the percentage error which is considered tolerable for use with OnTarget. More... | |
virtual void | SetToleranceBuffer (int buf=1) |
Set the number of previous error samples to average for tolerancing. More... | |
virtual bool | OnTarget () const |
Return true if the error is within the percentage of the total input range, determined by SetTolerance. More... | |
void | Reset () override |
Reset the previous error, the integral term, and disable the controller. | |
void | PIDWrite (double output) override |
Passes the output directly to SetSetpoint(). More... | |
void | InitSendable (SendableBuilder &builder) override |
Initializes this Sendable object. More... | |
![]() | |
SendableBase (bool addLiveWindow=true) | |
Creates an instance of the sensor base. More... | |
std::string | GetName () const final |
Gets the name of this Sendable object. More... | |
void | SetName (const wpi::Twine &name) final |
Sets the name of this Sendable object. More... | |
std::string | GetSubsystem () const final |
Gets the subsystem name of this Sendable object. More... | |
void | SetSubsystem (const wpi::Twine &subsystem) final |
Sets the subsystem name of this Sendable object. More... | |
![]() | |
void | SetName (const wpi::Twine &subsystem, const wpi::Twine &name) |
Sets both the subsystem name and device name of this Sendable object. More... | |
Additional Inherited Members | |
![]() | |
virtual double | CalculateFeedForward () |
Calculate the feed forward term. More... | |
double | GetContinuousError (double error) const |
Wraps error around for continuous inputs. More... | |
![]() | |
void | AddChild (std::shared_ptr< Sendable > child) |
Add a child component. More... | |
void | AddChild (void *child) |
Add a child component. More... | |
void | SetName (const wpi::Twine &moduleType, int channel) |
Sets the name of the sensor with a channel number. More... | |
void | SetName (const wpi::Twine &moduleType, int moduleNumber, int channel) |
Sets the name of the sensor with a module and channel number. More... | |
![]() | |
bool | m_enabled = false |
wpi::mutex | m_thisMutex |
wpi::mutex | m_pidWriteMutex |
PIDSource * | m_pidInput |
PIDOutput * | m_pidOutput |
Timer | m_setpointTimer |
Class implements a synchronous PID control loop.
Provides a calculate method for the user to call at their desired update rate.
frc::SynchronousPID::SynchronousPID | ( | double | Kp, |
double | Ki, | ||
double | Kd, | ||
double | Kf, | ||
PIDSource & | source, | ||
PIDOutput & | output | ||
) |
Allocate a PID object with the given constants for P, I, and D.