REVLib - C++
Loading...
Searching...
No Matches
rev::spark::ClosedLoopConfig Class Reference

#include <ClosedLoopConfig.h>

Inherits rev::BaseConfig.

Public Member Functions

 ClosedLoopConfig ()=default
 
 ~ClosedLoopConfig () override=default
 
 ClosedLoopConfig (const ClosedLoopConfig &)=default
 
ClosedLoopConfigoperator= (const ClosedLoopConfig &)=delete
 
 ClosedLoopConfig (ClosedLoopConfig &&) noexcept=delete
 
ClosedLoopConfigoperator= (ClosedLoopConfig &&) noexcept=delete
 
ClosedLoopConfigApply (ClosedLoopConfig &config)
 
ClosedLoopConfigApply (MAXMotionConfig &config)
 
ClosedLoopConfigApply (FeedForwardConfig &config)
 
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)
 
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)
 
ClosedLoopConfigAllowedClosedLoopError (double allowedError, ClosedLoopSlot slot=kSlot0)
 
ClosedLoopConfigPositionWrappingEnabled (bool enabled)
 
ClosedLoopConfigSetFeedbackSensor (FeedbackSensor sensor)
 
ClosedLoopConfigSetFeedbackSensor (FeedbackSensor sensor, int detachedEncoderDeviceId)
 
ClosedLoopConfigSetFeedbackSensor (FeedbackSensor sensor, const rev::detached::DetachedEncoder &detachedEncoder)
 
std::string Flatten () override
 
- Public Member Functions inherited from rev::BaseConfig
virtual ~BaseConfig ()=default
 

Public Attributes

MAXMotionConfig maxMotion
 
FeedForwardConfig feedForward
 

Additional Inherited Members

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

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 & )
default

◆ 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 ( 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

◆ Apply() [3/3]

ClosedLoopConfig & ClosedLoopConfig::Apply ( FeedForwardConfig & config)

Applies settings from a FeedForwardConfig 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 FeedForwardConfig to copy settings from
Returns
The updated ClosedLoopConfig 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

◆ 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

◆ AllowedClosedLoopError()

ClosedLoopConfig & ClosedLoopConfig::AllowedClosedLoopError ( double allowedError,
ClosedLoopSlot slot = kSlot0 )

Set the allowed closed loop error for the controller for a specific PID slot. This value is how much deviation from the setpoint is tolerated and is useful in preventing oscillation around the setpoint. The units are in rotations.

Parameters
allowedErrorThe allowed error
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

◆ SetFeedbackSensor() [1/3]

ClosedLoopConfig & ClosedLoopConfig::SetFeedbackSensor ( FeedbackSensor sensor)

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

To set a detached encoder, use SetFeedbackSensor(FeedbackSensor, int) or SetFeedbackSensor(FeedbackSensor, rev::detached::DetachedEncoder&) instead. This method will ignore sensor set to a Detached sensor.

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 attached feedback sensor
Returns
The modified ClosedLoopConfig object for method chaining

◆ SetFeedbackSensor() [2/3]

ClosedLoopConfig & ClosedLoopConfig::SetFeedbackSensor ( FeedbackSensor sensor,
int detachedEncoderDeviceId )

Set an external CAN Detached Encoder as the feedback sensor of the controller. The controller will use this sensor as the source of feedback for its closed loop control.

To set an attached encoder, use the SetFeedbackSensor(FeedbackSensor) method instead. This method will ignore sensor set to an attached sensor.

Parameters
sensorThe detached feedback sensor @detachedEncoderDeviceId The device ID of the detached CAN encoder to use
Returns
The modified ClosedLoopConfig object for method chaining

◆ SetFeedbackSensor() [3/3]

ClosedLoopConfig & ClosedLoopConfig::SetFeedbackSensor ( FeedbackSensor sensor,
const rev::detached::DetachedEncoder & detachedEncoder )

Set an external CAN Detached Encoder as the feedback sensor of the controller. The controller will use this sensor as the source of feedback for its closed loop control.

To set an attached encoder, use the SetFeedbackSensor(FeedbackSensor) method instead. This method will ignore sensor set to an attached sensor.

Parameters
sensorThe detached feedback sensor @splineEncoder The detached CAN encoder to use
Returns
The modified ClosedLoopConfig object for method chaining

◆ Flatten()

std::string ClosedLoopConfig::Flatten ( )
overridevirtual

Reimplemented from rev::BaseConfig.

Member Data Documentation

◆ maxMotion

MAXMotionConfig rev::spark::ClosedLoopConfig::maxMotion

◆ feedForward

FeedForwardConfig rev::spark::ClosedLoopConfig::feedForward

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