REVLib - C++
rev::spark::SparkClosedLoopController Class Reference

#include <SparkClosedLoopController.h>

Public Types

enum class  ArbFFUnits { kVoltage = 0 , kPercentOut = 1 }
 

Public Member Functions

 SparkClosedLoopController (SparkClosedLoopController &&)=default
 
SparkClosedLoopControlleroperator= (SparkClosedLoopController &&)=default
 
 SparkClosedLoopController (const SparkClosedLoopController &rhs)=default
 
 ~SparkClosedLoopController ()=default
 
REVLibError SetSetpoint (double setpoint, SparkLowLevel::ControlType ctrl, ClosedLoopSlot slot=ClosedLoopSlot::kSlot0, double arbFeedforward=0, SparkClosedLoopController::ArbFFUnits arbFFUnits=ArbFFUnits::kVoltage)
 
REVLibError SetReference (double setpoint, SparkLowLevel::ControlType ctrl, ClosedLoopSlot slot=ClosedLoopSlot::kSlot0, double arbFeedforward=0, SparkClosedLoopController::ArbFFUnits arbFFUnits=ArbFFUnits::kVoltage)
 
SparkLowLevel::ControlType GetControlType () const
 
REVLibError SetIAccum (double iAccum)
 
double GetIAccum () const
 
double GetSetpoint () const
 
bool IsAtSetpoint () const
 
ClosedLoopSlot GetSelectedSlot () const
 
double GetMAXMotionSetpointPosition () const
 
double GetMAXMotionSetpointVelocity () const
 

Friends

class SparkBase
 

Member Enumeration Documentation

◆ ArbFFUnits

Units for arbitrary feed-forward

Enumerator
kVoltage 
kPercentOut 

Constructor & Destructor Documentation

◆ SparkClosedLoopController() [1/2]

rev::spark::SparkClosedLoopController::SparkClosedLoopController ( SparkClosedLoopController &&  )
default

◆ SparkClosedLoopController() [2/2]

rev::spark::SparkClosedLoopController::SparkClosedLoopController ( const SparkClosedLoopController rhs)
default

◆ ~SparkClosedLoopController()

rev::spark::SparkClosedLoopController::~SparkClosedLoopController ( )
default

Member Function Documentation

◆ operator=()

SparkClosedLoopController & rev::spark::SparkClosedLoopController::operator= ( SparkClosedLoopController &&  )
default

◆ SetSetpoint()

rev::REVLibError SparkClosedLoopController::SetSetpoint ( double  setpoint,
SparkLowLevel::ControlType  ctrl,
ClosedLoopSlot  slot = ClosedLoopSlot::kSlot0,
double  arbFeedforward = 0,
SparkClosedLoopController::ArbFFUnits  arbFFUnits = ArbFFUnits::kVoltage 
)

Set the controller setpoint based on the selected control mode.

Parameters
setpointThe setpoint to set depending on the control mode. For:
ctrlIs the control type
slotThe ClosedLoopSlot to use
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.
arbFFUnitsthe units for arbitrary feed-forward
Returns
REVLibError::kOk if successful

◆ SetReference()

rev::REVLibError SparkClosedLoopController::SetReference ( double  setpoint,
SparkLowLevel::ControlType  ctrl,
ClosedLoopSlot  slot = ClosedLoopSlot::kSlot0,
double  arbFeedforward = 0,
SparkClosedLoopController::ArbFFUnits  arbFFUnits = ArbFFUnits::kVoltage 
)

Set the controller setpoint based on the selected control mode.

Parameters
setpointThe setpoint to set depending on the control mode. For:
ctrlIs the control type
slotThe ClosedLoopSlot to use
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.
arbFFUnitsthe units for arbitrary feed-forward
Returns
REVLibError::kOk if successful
Deprecated:
Use SetSetpoint instead.

◆ GetControlType()

SparkLowLevel::ControlType rev::spark::SparkClosedLoopController::GetControlType ( ) const
inline

Get the selected control type used when SetReference() was called.

Returns
The selected control type

◆ SetIAccum()

rev::REVLibError SparkClosedLoopController::SetIAccum ( double  iAccum)

Set the I accumulator of the closed loop controller. This is useful when wishing to force a reset on the I accumulator of the Closed Loop 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

◆ GetIAccum()

double SparkClosedLoopController::GetIAccum ( ) const

Get the I accumulator of the closed loop 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

◆ GetSetpoint()

double SparkClosedLoopController::GetSetpoint ( ) const

Get the internal setpoint of the closed loop controller.

Returns
The internal setpoint

◆ IsAtSetpoint()

bool SparkClosedLoopController::IsAtSetpoint ( ) const

Determine if the setpoint has been reached.

Returns
true if the setpoint is reached; false otherwise

◆ GetSelectedSlot()

ClosedLoopSlot SparkClosedLoopController::GetSelectedSlot ( ) const

Get the selected closed loop PID slot.

Returns
The selected closed loop PID slot

◆ GetMAXMotionSetpointPosition()

double SparkClosedLoopController::GetMAXMotionSetpointPosition ( ) const

Get the MAXMotion internal setpoint position.

This will be 0 if the controller is not in a MAXMotion control mode.

Returns
The MAXMotion internal setpoint position in rotations or units specified by the conversion factor.

◆ GetMAXMotionSetpointVelocity()

double SparkClosedLoopController::GetMAXMotionSetpointVelocity ( ) const

Get the MAXMotion internal setpoint velocity.

This will be 0 if the controller is not in a MAXMotion control mode.

Returns
The MAXMotion internal setpoint velocity in rotations per minute or units specified by the conversion factor.

Friends And Related Function Documentation

◆ SparkBase

friend class SparkBase
friend

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