#include <PIDSubsystem.h>
Public Member Functions | |
PIDSubsystem (const char *name, double p, double i, double d) | |
PIDSubsystem (const char *name, double p, double i, double d, double f) | |
PIDSubsystem (const char *name, double p, double i, double d, double f, double period) | |
PIDSubsystem (double p, double i, double d) | |
PIDSubsystem (double p, double i, double d, double f) | |
PIDSubsystem (double p, double i, double d, double f, double period) | |
void | Enable () |
void | Disable () |
virtual void | PIDWrite (float output) |
virtual double | PIDGet () |
void | SetSetpoint (double setpoint) |
void | SetSetpointRelative (double deltaSetpoint) |
void | SetInputRange (float minimumInput, float maximumInput) |
double | GetSetpoint () |
double | GetPosition () |
virtual void | SetAbsoluteTolerance (float absValue) |
virtual void | SetPercentTolerance (float percent) |
virtual bool | OnTarget () |
virtual void | InitTable (ITable *table) |
virtual std::string | GetSmartDashboardType () |
Public Member Functions inherited from Subsystem | |
Subsystem (const char *name) | |
void | SetDefaultCommand (Command *command) |
Command * | GetDefaultCommand () |
void | SetCurrentCommand (Command *command) |
Command * | GetCurrentCommand () |
virtual void | InitDefaultCommand () |
virtual std::string | GetName () |
virtual ITable * | GetTable () |
Public Member Functions inherited from ErrorBase | |
virtual Error & | GetError () |
Retrieve the current error. Get the current error information associated with this sensor. | |
virtual const Error & | GetError () const |
virtual void | SetErrnoError (const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const |
Set error information associated with a C library call that set an error to the "errno" global variable. More... | |
virtual void | SetImaqError (int success, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const |
Set the current error information associated from the nivision Imaq API. More... | |
virtual void | SetError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const |
Set the current error information associated with this sensor. More... | |
virtual void | SetWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const |
Set the current error information associated with this sensor. More... | |
virtual void | CloneError (ErrorBase *rhs) const |
virtual void | ClearError () const |
Clear the current error information associated with this sensor. | |
virtual bool | StatusIsFatal () const |
Check if the current error code represents a fatal error. More... | |
Protected Member Functions | |
PIDController * | GetPIDController () |
virtual double | ReturnPIDInput ()=0 |
virtual void | UsePIDOutput (double output)=0 |
Protected Member Functions inherited from ErrorBase | |
ErrorBase () | |
Initialize the instance status to 0 for now. | |
Additional Inherited Members | |
Public Types inherited from PIDSource | |
enum | PIDSourceParameter { kDistance, kRate, kAngle } |
Static Public Member Functions inherited from ErrorBase | |
static void | SetGlobalError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) |
static void | SetGlobalWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) |
static Error & | GetGlobalError () |
Protected Attributes inherited from Subsystem | |
ITable * | m_table |
Protected Attributes inherited from ErrorBase | |
Error | m_error |
Static Protected Attributes inherited from ErrorBase | |
static SEM_ID | _globalErrorMutex = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE) |
static Error | _globalError |
This class is designed to handle the case where there is a Subsystem which uses a single PIDController almost constantly (for instance, an elevator which attempts to stay at a constant height).
It provides some convenience methods to run an internal PIDController. It also allows access to the internal PIDController in order to give total control to the programmer.
Definition at line 25 of file PIDSubsystem.h.
PIDSubsystem::PIDSubsystem | ( | const char * | name, |
double | p, | ||
double | i, | ||
double | d | ||
) |
Instantiates a PIDSubsystem that will use the given p, i and d values.
name | the name |
p | the proportional value |
i | the integral value |
d | the derivative value |
Definition at line 20 of file PIDSubsystem.cpp.
PIDSubsystem::PIDSubsystem | ( | const char * | name, |
double | p, | ||
double | i, | ||
double | d, | ||
double | f | ||
) |
Instantiates a PIDSubsystem that will use the given p, i and d values.
name | the name |
p | the proportional value |
i | the integral value |
d | the derivative value |
f | the feedforward value |
Definition at line 34 of file PIDSubsystem.cpp.
PIDSubsystem::PIDSubsystem | ( | const char * | name, |
double | p, | ||
double | i, | ||
double | d, | ||
double | f, | ||
double | period | ||
) |
Instantiates a PIDSubsystem that will use the given p, i and d values. It will also space the time between PID loop calculations to be equal to the given period.
name | the name |
p | the proportional value |
i | the integral value |
d | the derivative value |
f | the feedfoward value |
period | the time (in seconds) between calculations |
Definition at line 50 of file PIDSubsystem.cpp.
PIDSubsystem::PIDSubsystem | ( | double | p, |
double | i, | ||
double | d | ||
) |
Instantiates a PIDSubsystem that will use the given p, i and d values. It will use the class name as its name.
p | the proportional value |
i | the integral value |
d | the derivative value |
Definition at line 64 of file PIDSubsystem.cpp.
PIDSubsystem::PIDSubsystem | ( | double | p, |
double | i, | ||
double | d, | ||
double | f | ||
) |
Instantiates a PIDSubsystem that will use the given p, i and d values. It will use the class name as its name.
p | the proportional value |
i | the integral value |
d | the derivative value |
f | the feedforward value |
Definition at line 78 of file PIDSubsystem.cpp.
PIDSubsystem::PIDSubsystem | ( | double | p, |
double | i, | ||
double | d, | ||
double | f, | ||
double | period | ||
) |
Instantiates a PIDSubsystem that will use the given p, i and d values. It will use the class name as its name. It will also space the time between PID loop calculations to be equal to the given period.
p | the proportional value |
i | the integral value |
d | the derivative value |
f | the feedforward value |
period | the time (in seconds) between calculations |
Definition at line 95 of file PIDSubsystem.cpp.
void PIDSubsystem::Disable | ( | ) |
Disables the internal PIDController
Definition at line 117 of file PIDSubsystem.cpp.
void PIDSubsystem::Enable | ( | ) |
Enables the internal PIDController
Definition at line 109 of file PIDSubsystem.cpp.
|
protected |
Returns the PIDController used by this PIDSubsystem. Use this if you would like to fine tune the pid loop.
Definition at line 129 of file PIDSubsystem.cpp.
double PIDSubsystem::GetPosition | ( | ) |
Returns the current position
Definition at line 215 of file PIDSubsystem.cpp.
double PIDSubsystem::GetSetpoint | ( | ) |
Return the current setpoint
Definition at line 161 of file PIDSubsystem.cpp.
|
virtual |
Reimplemented from Subsystem.
Definition at line 231 of file PIDSubsystem.cpp.
|
virtual |
Initializes a table for this sendable object.
subtable | The table to put the values in. |
Reimplemented from Subsystem.
Definition at line 234 of file PIDSubsystem.cpp.
void PIDSubsystem::SetInputRange | ( | float | minimumInput, |
float | maximumInput | ||
) |
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 |
Definition at line 172 of file PIDSubsystem.cpp.
void PIDSubsystem::SetSetpoint | ( | double | setpoint | ) |
Sets the setpoint to the given value. If SetRange(...) was called, then the given setpoint will be trimmed to fit within the range.
setpoint | the new setpoint |
Definition at line 141 of file PIDSubsystem.cpp.
void PIDSubsystem::SetSetpointRelative | ( | double | deltaSetpoint | ) |
Adds the given value to the setpoint. If SetRange(...) was used, then the bounds will still be honored by this method.
deltaSetpoint | the change in the setpoint |
Definition at line 152 of file PIDSubsystem.cpp.