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

#include <ClosedLoopConfig.h>

Inherits rev::spark::BaseConfig.

Public Types

enum  FeedbackSensor : uint32_t {
  kNoSensor = 0 , kPrimaryEncoder = 1 , kAnalogSensor = 2 , kAlternateOrExternalEncoder = 3 ,
  kAbsoluteEncoder = 4
}
 

Public Member Functions

 ClosedLoopConfig ()=default
 
 ~ClosedLoopConfig () override=default
 
 ClosedLoopConfig (const ClosedLoopConfig &)=delete
 
ClosedLoopConfigoperator= (const ClosedLoopConfig &)=delete
 
 ClosedLoopConfig (ClosedLoopConfig &&) noexcept=delete
 
ClosedLoopConfigoperator= (ClosedLoopConfig &&) noexcept=delete
 
ClosedLoopConfigApply (ClosedLoopConfig &config)
 
ClosedLoopConfigApply (SmartMotionConfig &config)
 
ClosedLoopConfigApply (MAXMotionConfig &config)
 
ClosedLoopConfigPidf (double p, double i, double d, double ff, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigPid (double p, double i, double d, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigP (double p, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigI (double i, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigD (double d, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigVelocityFF (double ff, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigDFilter (double dFilter, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigIZone (double iZone, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigMinOutput (double minOutput, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigMaxOutput (double maxOutput, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigOutputRange (double minOutput, double maxOutput, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigIMaxAccum (double iMaxAccum, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigPositionWrappingEnabled (bool enabled)
 
ClosedLoopConfigPositionWrappingMinInput (double minInput)
 
ClosedLoopConfigPositionWrappingMaxInput (double maxInput)
 
ClosedLoopConfigPositionWrappingInputRange (double minInput, double maxInput)
 
ClosedLoopConfigSetFeedbackSensor (FeedbackSensor sensor)
 
std::string Flatten () override
 
- Public Member Functions inherited from rev::spark::BaseConfig
virtual ~BaseConfig ()=default
 

Public Attributes

MAXMotionConfig maxMotion
 
SmartMotionConfig smartMotion
 

Additional Inherited Members

- Protected Types inherited from rev::spark::BaseConfig
using SparkConfig_t = std::variant< int32_t, uint32_t, float, bool >
 
- Protected Member Functions inherited from rev::spark::BaseConfig
 BaseConfig ()=default
 
 BaseConfig (const BaseConfig &)=delete
 
BaseConfigoperator= (const BaseConfig &)=delete
 
 BaseConfig (BaseConfig &&) noexcept=delete
 
BaseConfigoperator= (BaseConfig &&) noexcept=delete
 
template<typename ConfigType >
void PutParameter (uint8_t parameterId, ConfigType value)
 
std::optional< SparkConfig_tGetParameter (uint8_t parameterId)
 
std::optional< SparkConfig_tGetParameter (BaseConfig &fromConfig, uint8_t parameterId)
 
void RemoveParameter (uint8_t parameterId)
 
void RemoveParameter (BaseConfig &fromConfig, uint8_t parameterId)
 
void Apply (BaseConfig &config)
 

Member Enumeration Documentation

◆ FeedbackSensor

Enumerator
kNoSensor 
kPrimaryEncoder 
kAnalogSensor 
kAlternateOrExternalEncoder 
kAbsoluteEncoder 

Constructor & Destructor Documentation

◆ ClosedLoopConfig() [1/3]

rev::spark::ClosedLoopConfig::ClosedLoopConfig ( )
default

◆ ~ClosedLoopConfig()

rev::spark::ClosedLoopConfig::~ClosedLoopConfig ( )
overridedefault

◆ ClosedLoopConfig() [2/3]

rev::spark::ClosedLoopConfig::ClosedLoopConfig ( const ClosedLoopConfig )
delete

◆ ClosedLoopConfig() [3/3]

rev::spark::ClosedLoopConfig::ClosedLoopConfig ( ClosedLoopConfig &&  )
deletenoexcept

Member Function Documentation

◆ operator=() [1/2]

ClosedLoopConfig & rev::spark::ClosedLoopConfig::operator= ( const ClosedLoopConfig )
delete

◆ operator=() [2/2]

ClosedLoopConfig & rev::spark::ClosedLoopConfig::operator= ( ClosedLoopConfig &&  )
deletenoexcept

◆ Apply() [1/3]

ClosedLoopConfig & ClosedLoopConfig::Apply ( ClosedLoopConfig config)

Applies settings from another ClosedLoopConfig to this one, including all of its nested configurations.

Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.

Parameters
configThe ClosedLoopConfig to copy settings from
Returns
The updated ClosedLoopConfig for method chaining

◆ Apply() [2/3]

ClosedLoopConfig & ClosedLoopConfig::Apply ( SmartMotionConfig config)

Applies settings from a SmartMotionConfig to this ClosedLoopConfig.

Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.

Parameters
configThe SmartMotionConfig to copy settings from
Returns
The updated ClosedLoopConfig for method chaining

◆ Apply() [3/3]

ClosedLoopConfig & ClosedLoopConfig::Apply ( MAXMotionConfig config)

Applies settings from a MAXMotionConfig to this ClosedLoopConfig.

Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.

Parameters
configThe MAXMotionConfig to copy settings from
Returns
The updated ClosedLoopConfig for method chaining

◆ Pidf()

ClosedLoopConfig & ClosedLoopConfig::Pidf ( double  p,
double  i,
double  d,
double  ff,
ClosedLoopSlot  slot = kSlot0 
)

Set the PIDF gains of the controller for a specific closed loop slot.

Parameters
pThe proportional gain value
iThe integral gain value
dThe derivative gain value
ffThe velocity feedforward value
slotThe closed loop slot to set the values for
Returns
The modified ClosedLoopConfig object for method chaining

◆ Pid()

ClosedLoopConfig & ClosedLoopConfig::Pid ( double  p,
double  i,
double  d,
ClosedLoopSlot  slot = kSlot0 
)

Set the PID gains of the controller for a specific closed loop slot.

Parameters
pThe proportional gain value
iThe integral gain value
dThe derivative gain value
slotThe closed loop slot to set the values for
Returns
The modified ClosedLoopConfig object for method chaining

◆ P()

ClosedLoopConfig & ClosedLoopConfig::P ( double  p,
ClosedLoopSlot  slot = kSlot0 
)

Set the proportional gain of the controller for a specific closed loop slot.

Parameters
pThe proportional gain value
slotThe closed loop slot to set the values for
Returns
The modified ClosedLoopConfig object for method chaining

◆ I()

ClosedLoopConfig & ClosedLoopConfig::I ( double  i,
ClosedLoopSlot  slot = kSlot0 
)

Set the integral gain of the controller for a specific closed loop slot.

Parameters
iThe integral gain value
slotThe closed loop slot to set the values for
Returns
The modified ClosedLoopConfig object for method chaining

◆ D()

ClosedLoopConfig & ClosedLoopConfig::D ( double  d,
ClosedLoopSlot  slot = kSlot0 
)

Set the derivative gain of the controller for a specific closed loop slot.

Parameters
dThe derivative gain value
slotThe closed loop slot to set the values for
Returns
The modified ClosedLoopConfig object for method chaining

◆ VelocityFF()

ClosedLoopConfig & ClosedLoopConfig::VelocityFF ( double  ff,
ClosedLoopSlot  slot = kSlot0 
)

Set the velocity feedforward gain of the controller for a specific closed loop slot.

Parameters
ffThe velocity feedforward gain value
slotThe closed loop slot to set the values for
Returns
The modified ClosedLoopConfig object for method chaining

◆ DFilter()

ClosedLoopConfig & ClosedLoopConfig::DFilter ( double  dFilter,
ClosedLoopSlot  slot = kSlot0 
)

Set the derivative filter of the controller for a specific closed loop slot.

Parameters
dFilterThe derivative filter value
slotThe closed loop slot to set the values for
Returns
The modified ClosedLoopConfig object for method chaining

◆ IZone()

ClosedLoopConfig & ClosedLoopConfig::IZone ( double  iZone,
ClosedLoopSlot  slot = kSlot0 
)

Set the integral zone of the controller for a specific closed loop slot.

Parameters
iZoneThe integral zone value
slotThe closed loop slot to set the values for
Returns
The modified ClosedLoopConfig object for method chaining

◆ MinOutput()

ClosedLoopConfig & ClosedLoopConfig::MinOutput ( double  minOutput,
ClosedLoopSlot  slot = kSlot0 
)

Set the minimum output of the controller for a specific closed loop slot.

Parameters
minOutputThe minimum output value in the range [-1, 1]
slotThe closed loop slot to set the values for
Returns
The modified ClosedLoopConfig object for method chaining

◆ MaxOutput()

ClosedLoopConfig & ClosedLoopConfig::MaxOutput ( double  maxOutput,
ClosedLoopSlot  slot = kSlot0 
)

Set the maximum output of the controller for a specific closed loop slot.

Parameters
maxOutputThe maximum output value in the range [-1, 1]
slotThe closed loop slot to set the values for
Returns
The modified ClosedLoopConfig object for method chaining

◆ OutputRange()

ClosedLoopConfig & ClosedLoopConfig::OutputRange ( double  minOutput,
double  maxOutput,
ClosedLoopSlot  slot = kSlot0 
)

Set the output range of the controller for a specific closed loop slot.

Parameters
minOutputThe minimum output value in the range [-1, 1]
maxOutputThe maximum output value in the range [-1, 1]
slotThe closed loop slot to set the values for
Returns
The modified ClosedLoopConfig object for method chaining

◆ IMaxAccum()

ClosedLoopConfig & ClosedLoopConfig::IMaxAccum ( double  iMaxAccum,
ClosedLoopSlot  slot = kSlot0 
)

Set the maximum I accumulator of the controller for a specific closed loop slot. This value is used to constrain the I accumulator to help manage integral wind-up.

Parameters
iMaxAccumThe max value to constrain the I accumulator to
slotThe closed loop slot to set the values for
Returns
The modified ClosedLoopConfig object for method chaining

◆ PositionWrappingEnabled()

ClosedLoopConfig & ClosedLoopConfig::PositionWrappingEnabled ( bool  enabled)

Enable or disable PID wrapping for position closed loop control.

Parameters
enabledTrue to enable position PID wrapping
Returns
The modified ClosedLoopConfig object for method chaining

◆ PositionWrappingMinInput()

ClosedLoopConfig & ClosedLoopConfig::PositionWrappingMinInput ( double  minInput)

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

Parameters
minInputThe value of min input for the position
Returns
The modified ClosedLoopConfig object for method chaining

◆ PositionWrappingMaxInput()

ClosedLoopConfig & ClosedLoopConfig::PositionWrappingMaxInput ( double  maxInput)

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

Parameters
maxInputThe value of max input for the position
Returns
The modified ClosedLoopConfig object for method chaining

◆ PositionWrappingInputRange()

ClosedLoopConfig & ClosedLoopConfig::PositionWrappingInputRange ( double  minInput,
double  maxInput 
)

Set the input range for PID wrapping with position closed loop control

Parameters
minInputThe value of min input for the position
maxInputThe value of max input for the position
Returns
The modified ClosedLoopConfig object for method chaining

◆ SetFeedbackSensor()

ClosedLoopConfig & ClosedLoopConfig::SetFeedbackSensor ( FeedbackSensor  sensor)

Set the feedback sensor of the controller. The controller will use this sensor as the source of feedback for its closed loop control.

The default feedback sensor is assumed to be the primary encoder for either brushless or brushed mode. This can be changed to another feedback sensor for the controller such as an analog sensor, absolute encoder, or alternate/external encoder.

Parameters
sensorThe feedback sensor
Returns
The modified ClosedLoopConfig object for method chaining

◆ Flatten()

std::string ClosedLoopConfig::Flatten ( )
overridevirtual

Reimplemented from rev::spark::BaseConfig.

Member Data Documentation

◆ maxMotion

MAXMotionConfig rev::spark::ClosedLoopConfig::maxMotion

◆ smartMotion

SmartMotionConfig rev::spark::ClosedLoopConfig::smartMotion

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