CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
ctre::phoenix6::configs::Slot2Configs Class Reference

Gains for the specified slot. More...

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

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

Public Member Functions

constexpr Slot2Configs ()=default
 
constexpr Slot2ConfigsWithKP (units::dimensionless::scalar_t newKP)
 Modifies this configuration's kP parameter and returns itself for method-chaining and easier to use config API.
 
constexpr Slot2ConfigsWithKI (units::dimensionless::scalar_t newKI)
 Modifies this configuration's kI parameter and returns itself for method-chaining and easier to use config API.
 
constexpr Slot2ConfigsWithKD (units::dimensionless::scalar_t newKD)
 Modifies this configuration's kD parameter and returns itself for method-chaining and easier to use config API.
 
constexpr Slot2ConfigsWithKS (units::dimensionless::scalar_t newKS)
 Modifies this configuration's kS parameter and returns itself for method-chaining and easier to use config API.
 
constexpr Slot2ConfigsWithKV (units::dimensionless::scalar_t newKV)
 Modifies this configuration's kV parameter and returns itself for method-chaining and easier to use config API.
 
constexpr Slot2ConfigsWithKA (units::dimensionless::scalar_t newKA)
 Modifies this configuration's kA parameter and returns itself for method-chaining and easier to use config API.
 
constexpr Slot2ConfigsWithKG (units::dimensionless::scalar_t newKG)
 Modifies this configuration's kG parameter and returns itself for method-chaining and easier to use config API.
 
constexpr Slot2ConfigsWithGravityType (signals::GravityTypeValue newGravityType)
 Modifies this configuration's GravityType parameter and returns itself for method-chaining and easier to use config API.
 
constexpr Slot2ConfigsWithStaticFeedforwardSign (signals::StaticFeedforwardSignValue newStaticFeedforwardSign)
 Modifies this configuration's StaticFeedforwardSign parameter and returns itself for method-chaining and easier to use config API.
 
constexpr Slot2ConfigsWithGravityArmPositionOffset (units::angle::turn_t newGravityArmPositionOffset)
 Modifies this configuration's GravityArmPositionOffset parameter and returns itself for method-chaining and easier to use config API.
 
constexpr Slot2ConfigsWithGainSchedBehavior (signals::GainSchedBehaviorValue newGainSchedBehavior)
 Modifies this configuration's GainSchedBehavior parameter and returns itself for method-chaining and easier to use config API.
 
std::string ToString () const override
 
std::string Serialize () const final
 
ctre::phoenix::StatusCode Deserialize (std::string const &to_deserialize) final
 
- Public Member Functions inherited from ctre::phoenix6::configs::ParentConfiguration
- Public Member Functions inherited from ctre::phoenix6::ISerializable

Static Public Member Functions

static Slot2Configs From (SlotConfigs const &value)
 Converts the provided value to an instance of this type.
 

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.
 
units::angle::turn_t GravityArmPositionOffset = 0_tr
 Gravity feedback position offset when using the Arm/Cosine gravity type.
 
signals::GainSchedBehaviorValue GainSchedBehavior = signals::GainSchedBehaviorValue::Inactive
 The behavior of the gain scheduler on this slot.
 

Detailed Description

Gains for the specified slot.

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

Constructor & Destructor Documentation

◆ Slot2Configs()

ctre::phoenix6::configs::Slot2Configs::Slot2Configs ( )
constexprdefault

Member Function Documentation

◆ Deserialize()

ctre::phoenix::StatusCode ctre::phoenix6::configs::Slot2Configs::Deserialize ( std::string const & to_deserialize)
finalvirtual

◆ From()

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

Converts the provided value to an instance of this type.

Parameters
valueThe value to convert
Returns
Converted value

◆ Serialize()

std::string ctre::phoenix6::configs::Slot2Configs::Serialize ( ) const
finalvirtual

◆ ToString()

std::string ctre::phoenix6::configs::Slot2Configs::ToString ( ) const
overridevirtual

◆ WithGainSchedBehavior()

Slot2Configs & ctre::phoenix6::configs::Slot2Configs::WithGainSchedBehavior ( signals::GainSchedBehaviorValue newGainSchedBehavior)
inlineconstexpr

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

The behavior of the gain scheduler on this slot. This specifies which gains to use while within the configured GainSchedErrorThreshold. The default is to continue using the specified slot.

Gain scheduling will not take effect when running velocity closed-loop controls.

Parameters
newGainSchedBehaviorParameter to modify
Returns
Itself

◆ WithGravityArmPositionOffset()

Slot2Configs & ctre::phoenix6::configs::Slot2Configs::WithGravityArmPositionOffset ( units::angle::turn_t newGravityArmPositionOffset)
inlineconstexpr

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

Gravity feedback position offset when using the Arm/Cosine gravity type.

This is an offset applied to the position of the arm, within (-0.25, 0.25) rot, before calculating the output of kG. This is useful when the center of gravity of the arm is offset from the actual zero point of the arm, such as when the arm and intake form an L shape.

  • Minimum Value: -0.25
  • Maximum Value: 0.25
  • Default Value: 0
  • Units: rotations
Parameters
newGravityArmPositionOffsetParameter to modify
Returns
Itself

◆ WithGravityType()

Slot2Configs & ctre::phoenix6::configs::Slot2Configs::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 be positive.

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 position is 0 when the mechanism is horizonal, and one rotation of the mechanism corresponds to one rotation of the sensor position.

Parameters
newGravityTypeParameter to modify
Returns
Itself

◆ WithKA()

Slot2Configs & ctre::phoenix6::configs::Slot2Configs::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()

Slot2Configs & ctre::phoenix6::configs::Slot2Configs::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()

Slot2Configs & ctre::phoenix6::configs::Slot2Configs::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. The type of gravity compensation is selected by GravityType.

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

  • Minimum Value: -128
  • Maximum Value: 127
  • Default Value: 0
  • Units:
Parameters
newKGParameter to modify
Returns
Itself

◆ WithKI()

Slot2Configs & ctre::phoenix6::configs::Slot2Configs::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()

Slot2Configs & ctre::phoenix6::configs::Slot2Configs::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, or 1/rps.

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

◆ WithKS()

Slot2Configs & ctre::phoenix6::configs::Slot2Configs::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: -128
  • Maximum Value: 127
  • Default Value: 0
  • Units:
Parameters
newKSParameter to modify
Returns
Itself

◆ WithKV()

Slot2Configs & ctre::phoenix6::configs::Slot2Configs::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()

Slot2Configs & ctre::phoenix6::configs::Slot2Configs::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 closed loop error sign 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

◆ GainSchedBehavior

signals::GainSchedBehaviorValue ctre::phoenix6::configs::Slot2Configs::GainSchedBehavior = signals::GainSchedBehaviorValue::Inactive

The behavior of the gain scheduler on this slot.

This specifies which gains to use while within the configured GainSchedErrorThreshold. The default is to continue using the specified slot.

Gain scheduling will not take effect when running velocity closed-loop controls.

◆ GravityArmPositionOffset

units::angle::turn_t ctre::phoenix6::configs::Slot2Configs::GravityArmPositionOffset = 0_tr

Gravity feedback position offset when using the Arm/Cosine gravity type.

This is an offset applied to the position of the arm, within (-0.25, 0.25) rot, before calculating the output of kG. This is useful when the center of gravity of the arm is offset from the actual zero point of the arm, such as when the arm and intake form an L shape.

  • Minimum Value: -0.25
  • Maximum Value: 0.25
  • Default Value: 0
  • Units: rotations

◆ GravityType

signals::GravityTypeValue ctre::phoenix6::configs::Slot2Configs::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 be positive.

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 position is 0 when the mechanism is horizonal, and one rotation of the mechanism corresponds to one rotation of the sensor position.

◆ kA

units::dimensionless::scalar_t ctre::phoenix6::configs::Slot2Configs::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::Slot2Configs::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::Slot2Configs::kG = 0

Gravity feedforward/feedback gain.

The type of gravity compensation is selected by GravityType.

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

  • Minimum Value: -128
  • Maximum Value: 127
  • Default Value: 0
  • Units:

◆ kI

units::dimensionless::scalar_t ctre::phoenix6::configs::Slot2Configs::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::Slot2Configs::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, or 1/rps.

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

◆ kS

units::dimensionless::scalar_t ctre::phoenix6::configs::Slot2Configs::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: -128
  • Maximum Value: 127
  • Default Value: 0
  • Units:

◆ kV

units::dimensionless::scalar_t ctre::phoenix6::configs::Slot2Configs::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:

◆ StaticFeedforwardSign

signals::StaticFeedforwardSignValue ctre::phoenix6::configs::Slot2Configs::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 closed loop error sign 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: