REVLib - C++
rev::CANPIDController Class Referenceabstract

#include <CANPIDController.h>

Inherited by rev::SparkMaxPIDController [private].

Public Types

enum class  AccelStrategy { kTrapezoidal = 0 , kSCurve = 1 }
 
enum class  ArbFFUnits { kVoltage = 0 , kPercentOut = 1 }
 

Public Member Functions

virtual ~CANPIDController ()
 
virtual REVLibError SetReference (double value, ControlType ctrl, int pidSlot=0, double arbFeedforward=0, ArbFFUnits arbFFUnits=ArbFFUnits::kVoltage)=0
 
virtual REVLibError SetP (double gain, int slotID=0)=0
 
virtual REVLibError SetI (double gain, int slotID=0)=0
 
virtual REVLibError SetD (double gain, int slotID=0)=0
 
virtual REVLibError SetDFilter (double gain, int slotID=0)=0
 
virtual REVLibError SetFF (double gain, int slotID=0)=0
 
virtual REVLibError SetIZone (double IZone, int slotID=0)=0
 
virtual REVLibError SetOutputRange (double min, double max, int slotID=0)=0
 
virtual double GetP (int slotID=0) const =0
 
virtual double GetI (int slotID=0) const =0
 
virtual double GetD (int slotID=0) const =0
 
virtual double GetDFilter (int slotID=0) const =0
 
virtual double GetFF (int slotID=0) const =0
 
virtual double GetIZone (int slotID=0) const =0
 
virtual double GetOutputMin (int slotID=0) const =0
 
virtual double GetOutputMax (int slotID=0) const =0
 
virtual REVLibError SetSmartMotionMaxVelocity (double maxVel, int slotID=0)=0
 
virtual REVLibError SetSmartMotionMaxAccel (double maxAccel, int slotID=0)=0
 
virtual REVLibError SetSmartMotionMinOutputVelocity (double minVel, int slotID=0)=0
 
virtual REVLibError SetSmartMotionAllowedClosedLoopError (double allowedErr, int slotID=0)=0
 
virtual REVLibError SetSmartMotionAccelStrategy (AccelStrategy accelStrategy, int slotID=0)=0
 
virtual double GetSmartMotionMaxVelocity (int slotID=0) const =0
 
virtual double GetSmartMotionMaxAccel (int slotID=0) const =0
 
virtual double GetSmartMotionMinOutputVelocity (int slotID=0) const =0
 
virtual double GetSmartMotionAllowedClosedLoopError (int slotID=0) const =0
 
virtual REVLibError SetIMaxAccum (double iMaxAccum, int slotID=0)=0
 
virtual double GetIMaxAccum (int slotID=0) const =0
 
virtual REVLibError SetIAccum (double iAccum)=0
 
virtual double GetIAccum () const =0
 
virtual REVLibError SetFeedbackDevice (const CANSensor &sensor)=0
 
virtual REVLibError SetPositionPIDWrappingEnabled (bool enable)=0
 
virtual REVLibError SetPositionPIDWrappingMaxInput (double value)=0
 
virtual REVLibError SetPositionPIDWrappingMinInput (double value)=0
 
virtual bool GetPositionPIDWrappingEnabled () const =0
 
virtual double GetPositionPIDWrappingMaxInput () const =0
 
virtual double GetPositionPIDWrappingMinInput () const =0
 

Friends

class SparkMaxPIDController
 

Detailed Description

Member Enumeration Documentation

◆ AccelStrategy

Deprecated:
Use SparkMaxPIDController::AccelStrategy instead
Enumerator
kTrapezoidal 
kSCurve 

◆ ArbFFUnits

Deprecated:
Use SparkMaxPIDController::ArbFFUnits instead
Enumerator
kVoltage 
kPercentOut 

Constructor & Destructor Documentation

◆ ~CANPIDController()

virtual rev::CANPIDController::~CANPIDController ( )
inlinevirtual

Member Function Documentation

◆ SetReference()

virtual REVLibError rev::CANPIDController::SetReference ( double  value,
ControlType  ctrl,
int  pidSlot = 0,
double  arbFeedforward = 0,
ArbFFUnits  arbFFUnits = ArbFFUnits::kVoltage 
)
pure virtual

Set the controller reference value based on the selected control mode.

Parameters
valueThe value to set depending on the control mode. For basic duty cycle control this should be a value between -1 and 1 Otherwise: Voltage Control: Voltage (volts) Velocity Control: Velocity (RPM) Position Control: Position (Rotations) Current Control: Current (Amps). The units can be changed for position and velocity by a scale factor using setPositionConversionFactor().
ctrlIs the control type
pidSlotfor this command
arbFeedforwardA value from -32.0 to 32.0 which is a voltage applied to the motor after the result of the specified control mode. The units for the parameter is Volts. This value is set after the control mode, but before any current limits or ramp rates.
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetP()

virtual REVLibError rev::CANPIDController::SetP ( double  gain,
int  slotID = 0 
)
pure virtual

Set the Proportional Gain constant of the PIDF controller on the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX GUI to tune and save parameters.

Parameters
gainThe proportional gain value, must be positive
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetI()

virtual REVLibError rev::CANPIDController::SetI ( double  gain,
int  slotID = 0 
)
pure virtual

Set the Integral Gain constant of the PIDF controller on the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX GUI to tune and save parameters.

Parameters
gainThe integral gain value, must be positive
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetD()

virtual REVLibError rev::CANPIDController::SetD ( double  gain,
int  slotID = 0 
)
pure virtual

Set the Derivative Gain constant of the PIDF controller on the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX GUI to tune and save parameters.

Parameters
gainThe derivative gain value, must be positive
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetDFilter()

virtual REVLibError rev::CANPIDController::SetDFilter ( double  gain,
int  slotID = 0 
)
pure virtual

Set the Derivative Filter constant of the PIDF controller on the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called.

Parameters
gainThe derivative filter value, must be a positive number between 0 and 1
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetFF()

virtual REVLibError rev::CANPIDController::SetFF ( double  gain,
int  slotID = 0 
)
pure virtual

Set the Feed-forward Gain constant of the PIDF controller on the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX GUI to tune and save parameters.

Parameters
gainThe feed-forward gain value
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetIZone()

virtual REVLibError rev::CANPIDController::SetIZone ( double  IZone,
int  slotID = 0 
)
pure virtual

Set the IZone range of the PIDF controller on the SPARK MAX. This value specifies the range the |error| must be within for the integral constant to take effect.

This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is to use the SPARK MAX GUI to tune and save parameters.

Parameters
gainThe IZone value, must be positive. Set to 0 to disable
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetOutputRange()

virtual REVLibError rev::CANPIDController::SetOutputRange ( double  min,
double  max,
int  slotID = 0 
)
pure virtual

Set the min amd max output for the closed loop mode.

This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is to use the SPARK MAX GUI to tune and save parameters.

Parameters
minReverse power minimum to allow the controller to output
maxForward power maximum to allow the controller to output
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ GetP()

virtual double rev::CANPIDController::GetP ( int  slotID = 0) const
pure virtual

Get the Proportional Gain constant of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
double P Gain value

Implemented in rev::SparkMaxPIDController.

◆ GetI()

virtual double rev::CANPIDController::GetI ( int  slotID = 0) const
pure virtual

Get the Integral Gain constant of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
double I Gain value

Implemented in rev::SparkMaxPIDController.

◆ GetD()

virtual double rev::CANPIDController::GetD ( int  slotID = 0) const
pure virtual

Get the Derivative Gain constant of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
double D Gain value

Implemented in rev::SparkMaxPIDController.

◆ GetDFilter()

virtual double rev::CANPIDController::GetDFilter ( int  slotID = 0) const
pure virtual

Get the Derivative Filter constant of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
double D Filter value

Implemented in rev::SparkMaxPIDController.

◆ GetFF()

virtual double rev::CANPIDController::GetFF ( int  slotID = 0) const
pure virtual

Get the Feed-forward Gain constant of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
double F Gain value

Implemented in rev::SparkMaxPIDController.

◆ GetIZone()

virtual double rev::CANPIDController::GetIZone ( int  slotID = 0) const
pure virtual

Get the IZone constant of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
double IZone value

Implemented in rev::SparkMaxPIDController.

◆ GetOutputMin()

virtual double rev::CANPIDController::GetOutputMin ( int  slotID = 0) const
pure virtual

Get the min output of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
double min value

Implemented in rev::SparkMaxPIDController.

◆ GetOutputMax()

virtual double rev::CANPIDController::GetOutputMax ( int  slotID = 0) const
pure virtual

Get the max output of the PIDF controller on the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
double max value

Implemented in rev::SparkMaxPIDController.

◆ SetSmartMotionMaxVelocity()

virtual REVLibError rev::CANPIDController::SetSmartMotionMaxVelocity ( double  maxVel,
int  slotID = 0 
)
pure virtual

Configure the maximum velocity of the SmartMotion mode. This is the velocity that is reached in the middle of the profile and is what the motor should spend most of its time at

Parameters
maxVelThe maxmimum cruise velocity for the motion profile in RPM
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetSmartMotionMaxAccel()

virtual REVLibError rev::CANPIDController::SetSmartMotionMaxAccel ( double  maxAccel,
int  slotID = 0 
)
pure virtual

Configure the maximum acceleration of the SmartMotion mode. This is the accleration that the motor velocity will increase at until the max velocity is reached

Parameters
maxAccelThe maxmimum acceleration for the motion profile in RPM per second
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetSmartMotionMinOutputVelocity()

virtual REVLibError rev::CANPIDController::SetSmartMotionMinOutputVelocity ( double  minVel,
int  slotID = 0 
)
pure virtual

Configure the mimimum velocity of the SmartMotion mode. Any requested velocities below this value will be set to 0.

Parameters
minVelThe minimum velocity for the motion profile in RPM
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetSmartMotionAllowedClosedLoopError()

virtual REVLibError rev::CANPIDController::SetSmartMotionAllowedClosedLoopError ( double  allowedErr,
int  slotID = 0 
)
pure virtual

Configure the allowed closed loop error of SmartMotion mode. This value is how much deviation from your setpoint is tolerated and is useful in preventing oscillation around your setpoint.

Parameters
allowedErrThe allowed deviation for your setpoint vs actual position in rotations
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetSmartMotionAccelStrategy()

virtual REVLibError rev::CANPIDController::SetSmartMotionAccelStrategy ( AccelStrategy  accelStrategy,
int  slotID = 0 
)
pure virtual

Coming soon. Configure the acceleration strategy used to control acceleration on the motor. The current strategy is trapezoidal motion profiling.

Parameters
accelStrategyThe acceleration strategy to use for the automatically generated motion profile
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ GetSmartMotionMaxVelocity()

virtual double rev::CANPIDController::GetSmartMotionMaxVelocity ( int  slotID = 0) const
pure virtual

Get the maximum velocity of the SmartMotion mode. This is the velocity that is reached in the middle of the profile and is what the motor should spend most of its time at

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
The maxmimum cruise velocity for the motion profile in RPM

Implemented in rev::SparkMaxPIDController.

◆ GetSmartMotionMaxAccel()

virtual double rev::CANPIDController::GetSmartMotionMaxAccel ( int  slotID = 0) const
pure virtual

Get the maximum acceleration of the SmartMotion mode. This is the accleration that the motor velocity will increase at until the max velocity is reached

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
The maxmimum acceleration for the motion profile in RPM per second

Implemented in rev::SparkMaxPIDController.

◆ GetSmartMotionMinOutputVelocity()

virtual double rev::CANPIDController::GetSmartMotionMinOutputVelocity ( int  slotID = 0) const
pure virtual

Get the mimimum velocity of the SmartMotion mode. Any requested velocities below this value will be set to 0.

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
The minimum velocity for the motion profile in RPM

Implemented in rev::SparkMaxPIDController.

◆ GetSmartMotionAllowedClosedLoopError()

virtual double rev::CANPIDController::GetSmartMotionAllowedClosedLoopError ( int  slotID = 0) const
pure virtual

Get the allowed closed loop error of SmartMotion mode. This value is how much deviation from your setpoint is tolerated and is useful in preventing oscillation around your setpoint.

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
The allowed deviation for your setpoint vs actual position in rotations

Implemented in rev::SparkMaxPIDController.

◆ SetIMaxAccum()

virtual REVLibError rev::CANPIDController::SetIMaxAccum ( double  iMaxAccum,
int  slotID = 0 
)
pure virtual

Configure the maximum I accumulator of the PID controller. This value is used to constrain the I accumulator to help manage integral wind-up

Parameters
iMaxAccumThe max value to contrain the I accumulator to
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ GetIMaxAccum()

virtual double rev::CANPIDController::GetIMaxAccum ( int  slotID = 0) const
pure virtual

Get the maximum I accumulator of the PID controller. This value is used to constrain the I accumulator to help manage integral wind-up

Parameters
slotIDIs the gain schedule slot, the value is a number between 0 and 3. Each slot has its own set of gain values and can be changed in each control frame using SetReference().
Returns
The max value to contrain the I accumulator to

Implemented in rev::SparkMaxPIDController.

◆ SetIAccum()

virtual REVLibError rev::CANPIDController::SetIAccum ( double  iAccum)
pure virtual

Set the I accumulator of the PID controller. This is useful when wishing to force a reset on the I accumulator of the PID controller. You can also preset values to see how it will respond to certain I characteristics

To use this function, the controller must be in a closed loop control mode by calling setReference()

Parameters
iAccumThe value to set the I accumulator to
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ GetIAccum()

virtual double rev::CANPIDController::GetIAccum ( ) const
pure virtual

Get the I accumulator of the PID controller. This is useful when wishing to see what the I accumulator value is to help with PID tuning

Returns
The value of the I accumulator

Implemented in rev::SparkMaxPIDController.

◆ SetFeedbackDevice()

virtual REVLibError rev::CANPIDController::SetFeedbackDevice ( const CANSensor sensor)
pure virtual

Set the controller's feedback device.

The default feedback device is assumed to be the integrated encoder. This is used to changed to another feedback device for the controller, such as an analog sensor.

If there is a limited range on the feedback sensor that should be observed by the PIDController, it can be set by calling SetFeedbackSensorRange() on the sensor object.

Parameters
sensorThe sensor to be used as a feedback device
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetPositionPIDWrappingEnabled()

virtual REVLibError rev::CANPIDController::SetPositionPIDWrappingEnabled ( bool  enable)
pure virtual

Enable or disable PID Wrapping for position closed loop control

Parameters
enableWhether position PID wrapping should be enabled
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetPositionPIDWrappingMaxInput()

virtual REVLibError rev::CANPIDController::SetPositionPIDWrappingMaxInput ( double  value)
pure virtual

Set the maximum input value for PID Wrapping with position closed loop control

Parameters
valueThe maximum input value
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ SetPositionPIDWrappingMinInput()

virtual REVLibError rev::CANPIDController::SetPositionPIDWrappingMinInput ( double  value)
pure virtual

Set the minimum input value for PID Wrapping with position closed loop control

Parameters
valueThe minimum input value
Returns
REVLibError::kOk if successful

Implemented in rev::SparkMaxPIDController.

◆ GetPositionPIDWrappingEnabled()

virtual bool rev::CANPIDController::GetPositionPIDWrappingEnabled ( ) const
pure virtual

Get whether or not PID Wrapping for position closed loop control is enabled

Returns
true if PID Wrapping is enabled

Implemented in rev::SparkMaxPIDController.

◆ GetPositionPIDWrappingMaxInput()

virtual double rev::CANPIDController::GetPositionPIDWrappingMaxInput ( ) const
pure virtual

Get the maximum input value for PID Wrapping with position closed loop control

Returns
the maximum input value

Implemented in rev::SparkMaxPIDController.

◆ GetPositionPIDWrappingMinInput()

virtual double rev::CANPIDController::GetPositionPIDWrappingMinInput ( ) const
pure virtual

Get the minimum input value for PID Wrapping with position closed loop control

Returns
the minimum input value

Implemented in rev::SparkMaxPIDController.

Friends And Related Function Documentation

◆ SparkMaxPIDController

friend class SparkMaxPIDController
friend

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