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 SetReference (double value, SparkLowLevel::ControlType ctrl, int pidSlot=0, double arbFeedforward=0, SparkClosedLoopController::ArbFFUnits arbFFUnits=ArbFFUnits::kVoltage)
 
REVLibError SetIAccum (double iAccum)
 
double GetIAccum () 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

◆ SetReference()

rev::REVLibError SparkClosedLoopController::SetReference ( double  value,
SparkLowLevel::ControlType  ctrl,
int  pidSlot = 0,
double  arbFeedforward = 0,
SparkClosedLoopController::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.
arbFFUnitsthe units for arbitrary feed-forward
Returns
REVLibError::kOk if successful

◆ 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

Friends And Related Function Documentation

◆ SparkBase

friend class SparkBase
friend

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