WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
PIDSubsystem Class Referenceabstract

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>

Inheritance diagram for PIDSubsystem:
Subsystem PIDOutput PIDSource ErrorBase NamedSendable Sendable

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 (float 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 (float minimumInput, float maximumInput)
 Sets the maximum and minimum values expected from the input. More...
 
void SetOutputRange (float minimumOutput, float 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 (float absValue)
 
virtual void SetPercentTolerance (float percent)
 
virtual bool OnTarget () const
 
virtual void InitTable (std::shared_ptr< ITable > table)
 Initializes a table for this sendable object. More...
 
virtual std::string GetSmartDashboardType () const
 
- Public Member Functions inherited from Subsystem
 Subsystem (const std::string &name)
 Creates a subsystem with the given name. More...
 
void SetDefaultCommand (Command *command)
 Sets the default command. More...
 
CommandGetDefaultCommand ()
 Returns the default command (or null if there is none). More...
 
void SetCurrentCommand (Command *command)
 Sets the current command. More...
 
CommandGetCurrentCommand () const
 Returns the command which currently claims this subsystem. More...
 
virtual void InitDefaultCommand ()
 Initialize the default command for this subsystem This is meant to be the place to call SetDefaultCommand in a subsystem and will be called on all the subsystems by the CommandBase method before the program starts running by using the list of all registered Subsystems inside the Scheduler. More...
 
virtual std::string GetName () const
 
virtual std::shared_ptr< ITableGetTable () const
 
- Public Member Functions inherited from ErrorBase
 ErrorBase (const ErrorBase &)=delete
 
ErrorBaseoperator= (const ErrorBase &)=delete
 
virtual ErrorGetError ()
 Retrieve the current error. More...
 
virtual const ErrorGetError () const
 
virtual void SetErrnoError (llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef 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, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t 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, uint32_t 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, uint32_t 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...
 
- Public Member Functions inherited from PIDSource
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< PIDControllerGetPIDController ()
 Returns the PIDController used by this PIDSubsystem. More...
 
virtual double ReturnPIDInput ()=0
 
virtual void UsePIDOutput (double output)=0
 

Additional Inherited Members

- Static Public Member Functions inherited from ErrorBase
static void SetGlobalError (Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber)
 
static void SetGlobalWPIError (llvm::StringRef errorMessage, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, uint32_t lineNumber)
 
static ErrorGetGlobalError ()
 Retrieve the current global error.
 
- Protected Attributes inherited from Subsystem
std::shared_ptr< ITablem_table
 
- Protected Attributes inherited from ErrorBase
Error m_error
 
- Protected Attributes inherited from PIDSource
PIDSourceType m_pidSource = PIDSourceType::kDisplacement
 
- Static Protected Attributes inherited from ErrorBase
static priority_mutex _globalErrorMutex
 
static Error _globalError
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
namethe name
pthe proportional value
ithe integral value
dthe 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.

Parameters
namethe name
pthe proportional value
ithe integral value
dthe derivative value
fthe 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.

Parameters
namethe name
pthe proportional value
ithe integral value
dthe derivative value
fthe feedfoward value
periodthe 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.

Parameters
pthe proportional value
ithe integral value
dthe 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.

Parameters
pthe proportional value
ithe integral value
dthe derivative value
fthe 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.

Parameters
pthe proportional value
ithe integral value
dthe derivative value
fthe feedforward value
periodthe time (in seconds) between calculations

Member Function Documentation

std::shared_ptr< PIDController > PIDSubsystem::GetPIDController ( )
protected

Returns the PIDController used by this PIDSubsystem.

Use this if you would like to fine tune the pid loop.

Returns
the PIDController used by this PIDSubsystem
double PIDSubsystem::GetPosition ( )

Returns the current position.

Returns
the current position
double PIDSubsystem::GetRate ( )

Returns the current rate.

Returns
the current rate
double PIDSubsystem::GetSetpoint ( )

Return the current setpoint.

Returns
The current setpoint
std::string PIDSubsystem::GetSmartDashboardType ( ) const
virtual
Returns
the string representation of the named data type that will be used by the smart dashboard for this sendable

Reimplemented from Subsystem.

void PIDSubsystem::InitTable ( std::shared_ptr< ITable subtable)
virtual

Initializes a table for this sendable object.

Parameters
subtableThe table to put the values in.

Reimplemented from Subsystem.

void PIDSubsystem::SetInputRange ( float  minimumInput,
float  maximumInput 
)

Sets the maximum and minimum values expected from the input.

Parameters
minimumInputthe minimum value expected from the input
maximumInputthe maximum value expected from the output
void PIDSubsystem::SetOutputRange ( float  minimumOutput,
float  maximumOutput 
)

Sets the maximum and minimum values to write.

Parameters
minimumOutputthe minimum value to write to the output
maximumOutputthe maximum value to write to the output
void PIDSubsystem::SetSetpoint ( double  setpoint)

Sets the setpoint to the given value.

If double) SetRange(...) was called, then the given setpoint will be trimmed to fit within the range.

Parameters
setpointthe 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.

Parameters
deltaSetpointthe change in the setpoint

The documentation for this class was generated from the following files: