REVLib - C++
rev::SparkMaxPIDController Class Reference

#include <SparkMaxPIDController.h>

Inherits rev::CANPIDController.

Inherited by rev::SparkPIDController.

Public Types

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

Public Member Functions

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

Friends

class CANSparkBase
 
class SparkPIDController
 

Detailed Description

Member Enumeration Documentation

◆ AccelStrategy

Acceleration strategy used by Smart Motion

Deprecated:
Use SparkPIDController::AccelStrategy instead
Enumerator
kTrapezoidal 
kSCurve 

◆ ArbFFUnits

Units for arbitrary feed-forward

Deprecated:
Use SparkPIDController::ArbFFUnits instead
Enumerator
kVoltage 
kPercentOut 

Constructor & Destructor Documentation

◆ SparkMaxPIDController() [1/2]

rev::SparkMaxPIDController::SparkMaxPIDController ( SparkMaxPIDController &&  )
default

◆ SparkMaxPIDController() [2/2]

rev::SparkMaxPIDController::SparkMaxPIDController ( const SparkMaxPIDController rhs)
default

◆ ~SparkMaxPIDController()

rev::SparkMaxPIDController::~SparkMaxPIDController ( )
overridedefault

Member Function Documentation

◆ operator=()

SparkMaxPIDController & rev::SparkMaxPIDController::operator= ( SparkMaxPIDController &&  )
default

◆ SetReference() [1/3]

REVLibError SparkMaxPIDController::SetReference ( double  value,
CANSparkLowLevel::ControlType  ctrl,
int  pidSlot = 0,
double  arbFeedforward = 0,
SparkMaxPIDController::ArbFFUnits  arbFFUnits = ArbFFUnits::kVoltage 
)

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

◆ SetReference() [2/3]

REVLibError SparkMaxPIDController::SetReference ( double  value,
CANSparkMaxLowLevel::ControlType  ctrl,
int  pidSlot = 0,
double  arbFeedforward = 0,
SparkMaxPIDController::ArbFFUnits  arbFFUnits = ArbFFUnits::kVoltage 
)

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
Deprecated:
Use SparkMaxPIDController::SetReference(double, CANSparkBase::ControlType, int, double, SparkMaxPIDController::ArbFFUnits) instead

◆ SetReference() [3/3]

REVLibError SparkMaxPIDController::SetReference ( double  value,
ControlType  ctrl,
int  pidSlot = 0,
double  arbFeedforward = 0,
CANPIDController::ArbFFUnits  arbFFUnits = CANPIDController::ArbFFUnits::kVoltage 
)
overridevirtual

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
Deprecated:
Use SparkMaxPIDController::SetReference(double, CANSparkBase::ControlType, int, double, SparkMaxPIDController::ArbFFUnits) instead

Implements rev::CANPIDController.

◆ SetP()

REVLibError SparkMaxPIDController::SetP ( double  gain,
int  slotID = 0 
)
overridevirtual

Set the Proportional Gain constant of the PIDF controller on the SPARK. This uses the Set Parameter API and should be used infrequently. The parameter does not persist unless burnFlash() is called. The recommended method to configure this parameter is to use the REV Hardware Client 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

Implements rev::CANPIDController.

◆ SetI()

REVLibError SparkMaxPIDController::SetI ( double  gain,
int  slotID = 0 
)
overridevirtual

Set the Integral Gain constant of the PIDF controller on the SPARK. This uses the Set Parameter API and should be used infrequently. The parameter does not persist unless burnFlash() is called. The recommended method to configure this parameter is to use the REV Hardware Client 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

Implements rev::CANPIDController.

◆ SetD()

REVLibError SparkMaxPIDController::SetD ( double  gain,
int  slotID = 0 
)
overridevirtual

Set the Derivative Gain constant of the PIDF controller on the SPARK. This uses the Set Parameter API and should be used infrequently. The parameter does not persist unless burnFlash() is called. The recommended method to configure this parameter is to use the REV Hardware Client 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

Implements rev::CANPIDController.

◆ SetDFilter()

REVLibError SparkMaxPIDController::SetDFilter ( double  gain,
int  slotID = 0 
)
overridevirtual

Set the Derivative Filter constant of the PIDF controller on the SPARK. This uses the Set Parameter API and should be used infrequently. The parameter does not persist 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

Implements rev::CANPIDController.

◆ SetFF()

REVLibError SparkMaxPIDController::SetFF ( double  gain,
int  slotID = 0 
)
overridevirtual

Set the Feed-forward Gain constant of the PIDF controller on the SPARK. This uses the Set Parameter API and should be used infrequently. The parameter does not persist unless burnFlash() is called. The recommended method to configure this parameter is to use the REV Hardware Client 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

Implements rev::CANPIDController.

◆ SetIZone()

REVLibError SparkMaxPIDController::SetIZone ( double  IZone,
int  slotID = 0 
)
overridevirtual

Set the IZone range of the PIDF controller on the SPARK. 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 persist unless burnFlash() is called. The recommended method to configure this parameter is to use the REV Hardware Client to tune and save parameters.

Parameters
IZoneThe 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

Implements rev::CANPIDController.

◆ SetOutputRange()

REVLibError SparkMaxPIDController::SetOutputRange ( double  min,
double  max,
int  slotID = 0 
)
overridevirtual

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 persist unless burnFlash() is called. The recommended method to configure this parameter is to use the REV Hardware Client 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

Implements rev::CANPIDController.

◆ GetP()

double SparkMaxPIDController::GetP ( int  slotID = 0) const
overridevirtual

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

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

Implements rev::CANPIDController.

◆ GetI()

double SparkMaxPIDController::GetI ( int  slotID = 0) const
overridevirtual

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

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

Implements rev::CANPIDController.

◆ GetD()

double SparkMaxPIDController::GetD ( int  slotID = 0) const
overridevirtual

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

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

Implements rev::CANPIDController.

◆ GetDFilter()

double SparkMaxPIDController::GetDFilter ( int  slotID = 0) const
overridevirtual

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

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

Implements rev::CANPIDController.

◆ GetFF()

double SparkMaxPIDController::GetFF ( int  slotID = 0) const
overridevirtual

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

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

Implements rev::CANPIDController.

◆ GetIZone()

double SparkMaxPIDController::GetIZone ( int  slotID = 0) const
overridevirtual

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

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

Implements rev::CANPIDController.

◆ GetOutputMin()

double SparkMaxPIDController::GetOutputMin ( int  slotID = 0) const
overridevirtual

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

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

Implements rev::CANPIDController.

◆ GetOutputMax()

double SparkMaxPIDController::GetOutputMax ( int  slotID = 0) const
overridevirtual

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

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

Implements rev::CANPIDController.

◆ SetSmartMotionMaxVelocity()

REVLibError SparkMaxPIDController::SetSmartMotionMaxVelocity ( double  maxVel,
int  slotID = 0 
)
overridevirtual

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

Implements rev::CANPIDController.

◆ SetSmartMotionMaxAccel()

REVLibError SparkMaxPIDController::SetSmartMotionMaxAccel ( double  maxAccel,
int  slotID = 0 
)
overridevirtual

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

Implements rev::CANPIDController.

◆ SetSmartMotionMinOutputVelocity()

REVLibError SparkMaxPIDController::SetSmartMotionMinOutputVelocity ( double  minVel,
int  slotID = 0 
)
overridevirtual

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

Implements rev::CANPIDController.

◆ SetSmartMotionAllowedClosedLoopError()

REVLibError SparkMaxPIDController::SetSmartMotionAllowedClosedLoopError ( double  allowedErr,
int  slotID = 0 
)
overridevirtual

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

Implements rev::CANPIDController.

◆ SetSmartMotionAccelStrategy() [1/2]

REVLibError SparkMaxPIDController::SetSmartMotionAccelStrategy ( SparkMaxPIDController::AccelStrategy  accelStrategy,
int  slotID = 0 
)

NOTE: As of the 2022 FRC season, the firmware only supports the trapezoidal motion profiling acceleration strategy.

Configure the acceleration strategy used to control acceleration on the motor.

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

◆ SetSmartMotionAccelStrategy() [2/2]

REVLibError SparkMaxPIDController::SetSmartMotionAccelStrategy ( CANPIDController::AccelStrategy  accelStrategy,
int  slotID = 0 
)
overridevirtual

NOTE: As of the 2022 FRC season, the firmware only supports the trapezoidal motion profiling acceleration strategy.

Configure the acceleration strategy used to control acceleration on the motor.

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
Deprecated:
Use SetSmartMotionAccelStrategy(SparkMaxPIDController::AccelStrategy, int) instead

Implements rev::CANPIDController.

◆ GetSmartMotionMaxVelocity()

double SparkMaxPIDController::GetSmartMotionMaxVelocity ( int  slotID = 0) const
overridevirtual

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

Implements rev::CANPIDController.

◆ GetSmartMotionMaxAccel()

double SparkMaxPIDController::GetSmartMotionMaxAccel ( int  slotID = 0) const
overridevirtual

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

Implements rev::CANPIDController.

◆ GetSmartMotionMinOutputVelocity()

double SparkMaxPIDController::GetSmartMotionMinOutputVelocity ( int  slotID = 0) const
overridevirtual

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

Implements rev::CANPIDController.

◆ GetSmartMotionAllowedClosedLoopError()

double SparkMaxPIDController::GetSmartMotionAllowedClosedLoopError ( int  slotID = 0) const
overridevirtual

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

Implements rev::CANPIDController.

◆ GetSmartMotionAccelStrategy()

SparkMaxPIDController::AccelStrategy SparkMaxPIDController::GetSmartMotionAccelStrategy ( int  slotID = 0) const

Get the acceleration strategy used to control acceleration on the motor. The current strategy is trapezoidal motion profiling.

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 acceleration strategy to use for the automatically generated motion profile

◆ SetIMaxAccum()

REVLibError SparkMaxPIDController::SetIMaxAccum ( double  iMaxAccum,
int  slotID = 0 
)
overridevirtual

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

Implements rev::CANPIDController.

◆ GetIMaxAccum()

double SparkMaxPIDController::GetIMaxAccum ( int  slotID = 0) const
overridevirtual

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

Implements rev::CANPIDController.

◆ SetIAccum()

REVLibError SparkMaxPIDController::SetIAccum ( double  iAccum)
overridevirtual

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

Implements rev::CANPIDController.

◆ GetIAccum()

double SparkMaxPIDController::GetIAccum ( ) const
overridevirtual

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

Implements rev::CANPIDController.

◆ SetFeedbackDevice()

REVLibError SparkMaxPIDController::SetFeedbackDevice ( const CANSensor sensor)
overridevirtual

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

Implements rev::CANPIDController.

◆ SetPositionPIDWrappingEnabled()

REVLibError SparkMaxPIDController::SetPositionPIDWrappingEnabled ( bool  enable)
virtual

Enable or disable PID Wrapping for position closed loop control

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

Implements rev::CANPIDController.

◆ SetPositionPIDWrappingMaxInput()

REVLibError SparkMaxPIDController::SetPositionPIDWrappingMaxInput ( double  value)
virtual

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

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

Implements rev::CANPIDController.

◆ SetPositionPIDWrappingMinInput()

REVLibError SparkMaxPIDController::SetPositionPIDWrappingMinInput ( double  value)
virtual

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

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

Implements rev::CANPIDController.

◆ GetPositionPIDWrappingEnabled()

bool SparkMaxPIDController::GetPositionPIDWrappingEnabled ( ) const
overridevirtual

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

Returns
true if PID Wrapping is enabled

Implements rev::CANPIDController.

◆ GetPositionPIDWrappingMaxInput()

double SparkMaxPIDController::GetPositionPIDWrappingMaxInput ( ) const
overridevirtual

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

Returns
the maximum input value

Implements rev::CANPIDController.

◆ GetPositionPIDWrappingMinInput()

double SparkMaxPIDController::GetPositionPIDWrappingMinInput ( ) const
overridevirtual

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

Returns
the minimum in put value

Implements rev::CANPIDController.

Friends And Related Function Documentation

◆ CANSparkBase

friend class CANSparkBase
friend

◆ SparkPIDController

friend class SparkPIDController
friend

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