WPILibC++
unspecified
|
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). More...
#include <PIDSubsystem.h>
Public Member Functions | |
PIDSubsystem (const std::string &name, double p, double i, double d) | |
Instantiates a PIDSubsystem that will use the given p, i and d values. More... | |
PIDSubsystem (const std::string &name, double p, double i, double d, double f) | |
Instantiates a PIDSubsystem that will use the given p, i and d values. More... | |
PIDSubsystem (const std::string &name, double p, double i, double d, double f, double period) | |
Instantiates a PIDSubsystem that will use the given p, i and d values. More... | |
PIDSubsystem (double p, double i, double d) | |
Instantiates a PIDSubsystem that will use the given p, i and d values. More... | |
PIDSubsystem (double p, double i, double d, double f) | |
Instantiates a PIDSubsystem that will use the given p, i and d values. More... | |
PIDSubsystem (double p, double i, double d, double f, double period) | |
Instantiates a PIDSubsystem that will use the given p, i and d values. More... | |
void | Enable () |
Enables the internal PIDController. | |
void | Disable () |
Disables the internal PIDController. | |
virtual void | PIDWrite (double output) |
virtual double | PIDGet () |
void | SetSetpoint (double setpoint) |
Sets the setpoint to the given value. More... | |
void | SetSetpointRelative (double deltaSetpoint) |
Adds the given value to the setpoint. More... | |
void | SetInputRange (double minimumInput, double maximumInput) |
Sets the maximum and minimum values expected from the input. More... | |
void | SetOutputRange (double minimumOutput, double maximumOutput) |
Sets the maximum and minimum values to write. More... | |
double | GetSetpoint () |
Return the current setpoint. More... | |
double | GetPosition () |
Returns the current position. More... | |
double | GetRate () |
Returns the current rate. More... | |
virtual void | SetAbsoluteTolerance (double absValue) |
Set the absolute error which is considered tolerable for use with OnTarget. More... | |
virtual void | SetPercentTolerance (double percent) |
Set the percentage error which is considered tolerable for use with OnTarget. More... | |
virtual bool | OnTarget () const |
Return true if the error is within the percentage of the total input range, determined by SetTolerance. More... | |
void | InitTable (std::shared_ptr< ITable > subtable) override |
Initializes a table for this sendable object. More... | |
std::string | GetSmartDashboardType () const override |
![]() | |
Subsystem (const std::string &name) | |
Creates a subsystem with the given name. More... | |
void | SetDefaultCommand (Command *command) |
Sets the default command. More... | |
Command * | GetDefaultCommand () |
Returns the default command (or null if there is none). More... | |
void | SetCurrentCommand (Command *command) |
Sets the current command. More... | |
Command * | GetCurrentCommand () const |
Returns the command which currently claims this subsystem. More... | |
virtual void | InitDefaultCommand () |
Initialize the default command for this subsystem. More... | |
std::string | GetName () const override |
void | InitTable (std::shared_ptr< ITable > subtable) override |
Initializes a table for this sendable object. More... | |
std::shared_ptr< ITable > | GetTable () const override |
std::string | GetSmartDashboardType () const override |
![]() | |
ErrorBase (const ErrorBase &)=delete | |
ErrorBase & | operator= (const ErrorBase &)=delete |
virtual Error & | GetError () |
Retrieve the current error. More... | |
virtual const Error & | GetError () const |
virtual void | SetErrnoError (llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int 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, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) const |
Set the current error information associated from the nivision Imaq API. More... | |
virtual void | SetError (Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) const |
Set the current error information associated with this sensor. More... | |
virtual void | SetErrorRange (Error::Code code, int32_t minRange, int32_t maxRange, int32_t requestedValue, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) const |
Set the current error information associated with this sensor. More... | |
virtual void | SetWPIError (llvm::StringRef errorMessage, Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) const |
Set the current error information associated with this sensor. More... | |
virtual void | CloneError (const 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... | |
![]() | |
virtual void | SetPIDSourceType (PIDSourceType pidSource) |
Set which parameter you are using as a process control variable. More... | |
PIDSourceType | GetPIDSourceType () const |
Protected Member Functions | |
std::shared_ptr< PIDController > | GetPIDController () |
Returns the PIDController used by this PIDSubsystem. More... | |
virtual double | ReturnPIDInput ()=0 |
virtual void | UsePIDOutput (double output)=0 |
Additional Inherited Members | |
![]() | |
static void | SetGlobalError (Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) |
static void | SetGlobalWPIError (llvm::StringRef errorMessage, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) |
static Error & | GetGlobalError () |
Retrieve the current global error. | |
![]() | |
std::shared_ptr< ITable > | m_table |
![]() | |
Error | m_error |
![]() | |
PIDSourceType | m_pidSource = PIDSourceType::kDisplacement |
![]() | |
static priority_mutex | _globalErrorMutex |
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.
PIDSubsystem::PIDSubsystem | ( | const std::string & | 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 |
PIDSubsystem::PIDSubsystem | ( | const std::string & | 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 |
PIDSubsystem::PIDSubsystem | ( | const std::string & | 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 |
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 |
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 |
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 |
|
protected |
Returns the PIDController used by this PIDSubsystem.
Use this if you would like to fine tune the pid loop.
double PIDSubsystem::GetPosition | ( | ) |
Returns the current position.
double PIDSubsystem::GetRate | ( | ) |
Returns the current rate.
double PIDSubsystem::GetSetpoint | ( | ) |
Return the current setpoint.
|
overridevirtual |
Implements frc::Sendable.
|
overridevirtual |
Initializes a table for this sendable object.
subtable | The table to put the values in. |
Implements frc::Sendable.
|
virtual |
Return true if the error is within the percentage of the total input range, determined by SetTolerance.
This asssumes that the maximum and minimum input were set using SetInput. Use OnTarget() in the IsFinished() method of commands that use this subsystem.
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.
|
virtual |
Set the absolute error which is considered tolerable for use with OnTarget.
absValue | absolute error which is tolerable |
void PIDSubsystem::SetInputRange | ( | double | minimumInput, |
double | 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 |
void PIDSubsystem::SetOutputRange | ( | double | minimumOutput, |
double | maximumOutput | ||
) |
Sets the maximum and minimum values to write.
minimumOutput | the minimum value to write to the output |
maximumOutput | the maximum value to write to the output |
|
virtual |
Set the percentage error which is considered tolerable for use with OnTarget.
percent | percentage error which is tolerable |
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 |
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 |