CTRE Phoenix 6 C++ 25.0.0-beta-4
Loading...
Searching...
No Matches
ctre::phoenix6::configs::SlotConfigs Class Reference

Gains for the specified slot. More...

#include <ctre/phoenix6/configs/Configs.hpp>

Inheritance diagram for ctre::phoenix6::configs::SlotConfigs:
ctre::phoenix6::configs::ParentConfiguration ctre::phoenix6::ISerializable

Public Member Functions

constexpr SlotConfigs ()=default
 
constexpr SlotConfigsWithKP (units::dimensionless::scalar_t newKP)
 Modifies this configuration's kP parameter and returns itself for method-chaining and easier to use config API.
 
constexpr SlotConfigsWithKI (units::dimensionless::scalar_t newKI)
 Modifies this configuration's kI parameter and returns itself for method-chaining and easier to use config API.
 
constexpr SlotConfigsWithKD (units::dimensionless::scalar_t newKD)
 Modifies this configuration's kD parameter and returns itself for method-chaining and easier to use config API.
 
constexpr SlotConfigsWithKS (units::dimensionless::scalar_t newKS)
 Modifies this configuration's kS parameter and returns itself for method-chaining and easier to use config API.
 
constexpr SlotConfigsWithKV (units::dimensionless::scalar_t newKV)
 Modifies this configuration's kV parameter and returns itself for method-chaining and easier to use config API.
 
constexpr SlotConfigsWithKA (units::dimensionless::scalar_t newKA)
 Modifies this configuration's kA parameter and returns itself for method-chaining and easier to use config API.
 
constexpr SlotConfigsWithKG (units::dimensionless::scalar_t newKG)
 Modifies this configuration's kG parameter and returns itself for method-chaining and easier to use config API.
 
constexpr SlotConfigsWithGravityType (signals::GravityTypeValue newGravityType)
 Modifies this configuration's GravityType parameter and returns itself for method-chaining and easier to use config API.
 
constexpr SlotConfigsWithStaticFeedforwardSign (signals::StaticFeedforwardSignValue newStaticFeedforwardSign)
 Modifies this configuration's StaticFeedforwardSign parameter and returns itself for method-chaining and easier to use config API.
 
std::string ToString () const
 
std::string Serialize () const
 
ctre::phoenix::StatusCode Deserialize (const std::string &to_deserialize)
 

Static Public Member Functions

static SlotConfigs From (const Slot0Configs &value)
 
static SlotConfigs From (const Slot1Configs &value)
 
static SlotConfigs From (const Slot2Configs &value)
 

Public Attributes

units::dimensionless::scalar_t kP = 0
 Proportional Gain.
 
units::dimensionless::scalar_t kI = 0
 Integral Gain.
 
units::dimensionless::scalar_t kD = 0
 Derivative Gain.
 
units::dimensionless::scalar_t kS = 0
 Static Feedforward Gain.
 
units::dimensionless::scalar_t kV = 0
 Velocity Feedforward Gain.
 
units::dimensionless::scalar_t kA = 0
 Acceleration Feedforward Gain.
 
units::dimensionless::scalar_t kG = 0
 Gravity Feedforward/Feedback Gain.
 
signals::GravityTypeValue GravityType = signals::GravityTypeValue::Elevator_Static
 Gravity Feedforward/Feedback Type.
 
signals::StaticFeedforwardSignValue StaticFeedforwardSign = signals::StaticFeedforwardSignValue::UseVelocitySign
 Static Feedforward Sign during position closed loop.
 
int SlotNumber = 0
 Chooses which slot these configs are for.
 

Detailed Description

Gains for the specified slot.

If this slot is selected, these gains are used in closed loop control requests.

Constructor & Destructor Documentation

◆ SlotConfigs()

constexpr ctre::phoenix6::configs::SlotConfigs::SlotConfigs ( )
constexprdefault

Member Function Documentation

◆ Deserialize()

ctre::phoenix::StatusCode ctre::phoenix6::configs::SlotConfigs::Deserialize ( const std::string & to_deserialize)
inlinevirtual

◆ From() [1/3]

static SlotConfigs ctre::phoenix6::configs::SlotConfigs::From ( const Slot0Configs & value)
static

◆ From() [2/3]

static SlotConfigs ctre::phoenix6::configs::SlotConfigs::From ( const Slot1Configs & value)
static

◆ From() [3/3]

static SlotConfigs ctre::phoenix6::configs::SlotConfigs::From ( const Slot2Configs & value)
static

◆ Serialize()

std::string ctre::phoenix6::configs::SlotConfigs::Serialize ( ) const
inlinevirtual

◆ ToString()

std::string ctre::phoenix6::configs::SlotConfigs::ToString ( ) const
inlinevirtual

◆ WithGravityType()

constexpr SlotConfigs & ctre::phoenix6::configs::SlotConfigs::WithGravityType ( signals::GravityTypeValue newGravityType)
inlineconstexpr

Modifies this configuration's GravityType parameter and returns itself for method-chaining and easier to use config API.

Gravity Feedforward/Feedback Type.

This determines the type of the gravity feedforward/feedback.

Choose Elevator_Static for systems where the gravity feedforward is constant, such as an elevator. The gravity feedforward output will always have the same sign.

Choose Arm_Cosine for systems where the gravity feedback is dependent on the angular position of the mechanism, such as an arm. The gravity feedback output will vary depending on the mechanism angular position. Note that the sensor offset and ratios must be configured so that the sensor reports a position of 0 when the mechanism is horizonal (parallel to the ground), and the reported sensor position is 1:1 with the mechanism.

Parameters
newGravityTypeParameter to modify
Returns
Itself

◆ WithKA()

constexpr SlotConfigs & ctre::phoenix6::configs::SlotConfigs::WithKA ( units::dimensionless::scalar_t newKA)
inlineconstexpr

Modifies this configuration's kA parameter and returns itself for method-chaining and easier to use config API.

Acceleration Feedforward Gain.

The units for this gain is dependent on the control mode. Since this gain is multiplied by the requested acceleration, the units should be defined as units of output per unit of requested input acceleration. For example, when controlling velocity using a duty cycle closed loop, the units for the acceleration feedfoward gain will be duty cycle per requested rot per sec², or 1/(rot per sec²).

  • Minimum Value: 0
  • Maximum Value: 3.4e+38
  • Default Value: 0
  • Units:
Parameters
newKAParameter to modify
Returns
Itself

◆ WithKD()

constexpr SlotConfigs & ctre::phoenix6::configs::SlotConfigs::WithKD ( units::dimensionless::scalar_t newKD)
inlineconstexpr

Modifies this configuration's kD parameter and returns itself for method-chaining and easier to use config API.

Derivative Gain.

The units for this gain is dependent on the control mode. Since this gain is multiplied by the derivative of error in the input with respect to time (in units of seconds), the units should be defined as units of output per unit of the differentiated input error. For example, when controlling velocity using a duty cycle closed loop, the derivative of velocity with respect to time is rot per sec², which is acceleration. Therefore, the units for the derivative gain will be duty cycle per unit of acceleration error, or 1/(rot per sec²).

  • Minimum Value: 0
  • Maximum Value: 3.4e+38
  • Default Value: 0
  • Units:
Parameters
newKDParameter to modify
Returns
Itself

◆ WithKG()

constexpr SlotConfigs & ctre::phoenix6::configs::SlotConfigs::WithKG ( units::dimensionless::scalar_t newKG)
inlineconstexpr

Modifies this configuration's kG parameter and returns itself for method-chaining and easier to use config API.

Gravity Feedforward/Feedback Gain.

This is added to the closed loop output. The sign is determined by GravityType. The unit for this constant is dependent on the control mode, typically fractional duty cycle, voltage, or torque current.

  • Minimum Value: -512
  • Maximum Value: 511
  • Default Value: 0
  • Units:
Parameters
newKGParameter to modify
Returns
Itself

◆ WithKI()

constexpr SlotConfigs & ctre::phoenix6::configs::SlotConfigs::WithKI ( units::dimensionless::scalar_t newKI)
inlineconstexpr

Modifies this configuration's kI parameter and returns itself for method-chaining and easier to use config API.

Integral Gain.

The units for this gain is dependent on the control mode. Since this gain is multiplied by error in the input integrated over time (in units of seconds), the units should be defined as units of output per unit of integrated input error. For example, when controlling velocity using a duty cycle closed loop, integrating velocity over time results in rps * s = rotations. Therefore, the units for the integral gain will be duty cycle per rotation of accumulated error, or 1/rot.

  • Minimum Value: 0
  • Maximum Value: 3.4e+38
  • Default Value: 0
  • Units:
Parameters
newKIParameter to modify
Returns
Itself

◆ WithKP()

constexpr SlotConfigs & ctre::phoenix6::configs::SlotConfigs::WithKP ( units::dimensionless::scalar_t newKP)
inlineconstexpr

Modifies this configuration's kP parameter and returns itself for method-chaining and easier to use config API.

Proportional Gain.

The units for this gain is dependent on the control mode. Since this gain is multiplied by error in the input, the units should be defined as units of output per unit of input error. For example, when controlling velocity using a duty cycle closed loop, the units for the proportional gain will be duty cycle per rps of error, or 1/rps.

  • Minimum Value: 0
  • Maximum Value: 3.4e+38
  • Default Value: 0
  • Units:
Parameters
newKPParameter to modify
Returns
Itself

◆ WithKS()

constexpr SlotConfigs & ctre::phoenix6::configs::SlotConfigs::WithKS ( units::dimensionless::scalar_t newKS)
inlineconstexpr

Modifies this configuration's kS parameter and returns itself for method-chaining and easier to use config API.

Static Feedforward Gain.

This is added to the closed loop output. The unit for this constant is dependent on the control mode, typically fractional duty cycle, voltage, or torque current.

The sign is typically determined by reference velocity when using position, velocity, and Motion Magic® closed loop modes. However, when using position closed loop with zero velocity reference (no motion profiling), the application can instead use the position closed loop error by setting the Static Feedforward Sign configuration parameter. When doing so, we recommend the minimal amount of kS, otherwise the motor output may dither when closed loop error is near zero.

  • Minimum Value: -512
  • Maximum Value: 511
  • Default Value: 0
  • Units:
Parameters
newKSParameter to modify
Returns
Itself

◆ WithKV()

constexpr SlotConfigs & ctre::phoenix6::configs::SlotConfigs::WithKV ( units::dimensionless::scalar_t newKV)
inlineconstexpr

Modifies this configuration's kV parameter and returns itself for method-chaining and easier to use config API.

Velocity Feedforward Gain.

The units for this gain is dependent on the control mode. Since this gain is multiplied by the requested velocity, the units should be defined as units of output per unit of requested input velocity. For example, when controlling velocity using a duty cycle closed loop, the units for the velocity feedfoward gain will be duty cycle per requested rps, or 1/rps.

  • Minimum Value: 0
  • Maximum Value: 3.4e+38
  • Default Value: 0
  • Units:
Parameters
newKVParameter to modify
Returns
Itself

◆ WithStaticFeedforwardSign()

constexpr SlotConfigs & ctre::phoenix6::configs::SlotConfigs::WithStaticFeedforwardSign ( signals::StaticFeedforwardSignValue newStaticFeedforwardSign)
inlineconstexpr

Modifies this configuration's StaticFeedforwardSign parameter and returns itself for method-chaining and easier to use config API.

Static Feedforward Sign during position closed loop.

This determines the sign of the applied kS during position closed-loop modes. The default behavior uses the velocity reference sign. This works well with velocity closed loop, Motion Magic® controls, and position closed loop when velocity reference is specified (motion profiling).

However, when using position closed loop with zero velocity reference (no motion profiling), the application may want to apply static feedforward based on the sign of closed loop error instead. When doing so, we recommend using the minimal amount of kS, otherwise the motor output may dither when closed loop error is near zero.

Parameters
newStaticFeedforwardSignParameter to modify
Returns
Itself

Member Data Documentation

◆ GravityType

signals::GravityTypeValue ctre::phoenix6::configs::SlotConfigs::GravityType = signals::GravityTypeValue::Elevator_Static

Gravity Feedforward/Feedback Type.

This determines the type of the gravity feedforward/feedback.

Choose Elevator_Static for systems where the gravity feedforward is constant, such as an elevator. The gravity feedforward output will always have the same sign.

Choose Arm_Cosine for systems where the gravity feedback is dependent on the angular position of the mechanism, such as an arm. The gravity feedback output will vary depending on the mechanism angular position. Note that the sensor offset and ratios must be configured so that the sensor reports a position of 0 when the mechanism is horizonal (parallel to the ground), and the reported sensor position is 1:1 with the mechanism.

◆ kA

units::dimensionless::scalar_t ctre::phoenix6::configs::SlotConfigs::kA = 0

Acceleration Feedforward Gain.

The units for this gain is dependent on the control mode. Since this gain is multiplied by the requested acceleration, the units should be defined as units of output per unit of requested input acceleration. For example, when controlling velocity using a duty cycle closed loop, the units for the acceleration feedfoward gain will be duty cycle per requested rot per sec², or 1/(rot per sec²).

  • Minimum Value: 0
  • Maximum Value: 3.4e+38
  • Default Value: 0
  • Units:

◆ kD

units::dimensionless::scalar_t ctre::phoenix6::configs::SlotConfigs::kD = 0

Derivative Gain.

The units for this gain is dependent on the control mode. Since this gain is multiplied by the derivative of error in the input with respect to time (in units of seconds), the units should be defined as units of output per unit of the differentiated input error. For example, when controlling velocity using a duty cycle closed loop, the derivative of velocity with respect to time is rot per sec², which is acceleration. Therefore, the units for the derivative gain will be duty cycle per unit of acceleration error, or 1/(rot per sec²).

  • Minimum Value: 0
  • Maximum Value: 3.4e+38
  • Default Value: 0
  • Units:

◆ kG

units::dimensionless::scalar_t ctre::phoenix6::configs::SlotConfigs::kG = 0

Gravity Feedforward/Feedback Gain.

This is added to the closed loop output. The sign is determined by GravityType. The unit for this constant is dependent on the control mode, typically fractional duty cycle, voltage, or torque current.

  • Minimum Value: -512
  • Maximum Value: 511
  • Default Value: 0
  • Units:

◆ kI

units::dimensionless::scalar_t ctre::phoenix6::configs::SlotConfigs::kI = 0

Integral Gain.

The units for this gain is dependent on the control mode. Since this gain is multiplied by error in the input integrated over time (in units of seconds), the units should be defined as units of output per unit of integrated input error. For example, when controlling velocity using a duty cycle closed loop, integrating velocity over time results in rps * s = rotations. Therefore, the units for the integral gain will be duty cycle per rotation of accumulated error, or 1/rot.

  • Minimum Value: 0
  • Maximum Value: 3.4e+38
  • Default Value: 0
  • Units:

◆ kP

units::dimensionless::scalar_t ctre::phoenix6::configs::SlotConfigs::kP = 0

Proportional Gain.

The units for this gain is dependent on the control mode. Since this gain is multiplied by error in the input, the units should be defined as units of output per unit of input error. For example, when controlling velocity using a duty cycle closed loop, the units for the proportional gain will be duty cycle per rps of error, or 1/rps.

  • Minimum Value: 0
  • Maximum Value: 3.4e+38
  • Default Value: 0
  • Units:

◆ kS

units::dimensionless::scalar_t ctre::phoenix6::configs::SlotConfigs::kS = 0

Static Feedforward Gain.

This is added to the closed loop output. The unit for this constant is dependent on the control mode, typically fractional duty cycle, voltage, or torque current.

The sign is typically determined by reference velocity when using position, velocity, and Motion Magic® closed loop modes. However, when using position closed loop with zero velocity reference (no motion profiling), the application can instead use the position closed loop error by setting the Static Feedforward Sign configuration parameter. When doing so, we recommend the minimal amount of kS, otherwise the motor output may dither when closed loop error is near zero.

  • Minimum Value: -512
  • Maximum Value: 511
  • Default Value: 0
  • Units:

◆ kV

units::dimensionless::scalar_t ctre::phoenix6::configs::SlotConfigs::kV = 0

Velocity Feedforward Gain.

The units for this gain is dependent on the control mode. Since this gain is multiplied by the requested velocity, the units should be defined as units of output per unit of requested input velocity. For example, when controlling velocity using a duty cycle closed loop, the units for the velocity feedfoward gain will be duty cycle per requested rps, or 1/rps.

  • Minimum Value: 0
  • Maximum Value: 3.4e+38
  • Default Value: 0
  • Units:

◆ SlotNumber

int ctre::phoenix6::configs::SlotConfigs::SlotNumber = 0

Chooses which slot these configs are for.

◆ StaticFeedforwardSign

signals::StaticFeedforwardSignValue ctre::phoenix6::configs::SlotConfigs::StaticFeedforwardSign = signals::StaticFeedforwardSignValue::UseVelocitySign

Static Feedforward Sign during position closed loop.

This determines the sign of the applied kS during position closed-loop modes. The default behavior uses the velocity reference sign. This works well with velocity closed loop, Motion Magic® controls, and position closed loop when velocity reference is specified (motion profiling).

However, when using position closed loop with zero velocity reference (no motion profiling), the application may want to apply static feedforward based on the sign of closed loop error instead. When doing so, we recommend using the minimal amount of kS, otherwise the motor output may dither when closed loop error is near zero.


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