Table of Contents

Class SlotConfigs

Namespace
CTRE.Phoenix6.Configs
Assembly
Phoenix6.Hardware.dll

Gains for the specified slot.

If this slot is selected, these gains are used in closed loop control requests.
public class SlotConfigs : IParentConfiguration, ISerializable, ICloneable
Inheritance
SlotConfigs
Implements
Inherited Members

Fields

GainSchedBehavior

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.
public GainSchedBehaviorValue GainSchedBehavior

Field Value

GainSchedBehaviorValue

GravityArmPositionOffset

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 Value0.25
  • Default Value0
  • Unitsrotations
public double GravityArmPositionOffset

Field Value

double

GravityType

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.
public GravityTypeValue GravityType

Field Value

GravityTypeValue

SlotNumber

Chooses which slot these configs are for.

public int SlotNumber

Field Value

int

StaticFeedforwardSign

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.
public StaticFeedforwardSignValue StaticFeedforwardSign

Field Value

StaticFeedforwardSignValue

kA

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 Value0
  • Maximum Value3.4e+38
  • Default Value0
  • Units
public double kA

Field Value

double

kD

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 Value0
  • Maximum Value3.4e+38
  • Default Value0
  • Units
public double kD

Field Value

double

kG

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 Value127
  • Default Value0
  • Units
public double kG

Field Value

double

kI

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 Value0
  • Maximum Value3.4e+38
  • Default Value0
  • Units
public double kI

Field Value

double

kP

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 Value0
  • Maximum Value3.4e+38
  • Default Value0
  • Units
public double kP

Field Value

double

kS

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 Value127
  • Default Value0
  • Units
public double kS

Field Value

double

kV

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 Value0
  • Maximum Value3.4e+38
  • Default Value0
  • Units
public double kV

Field Value

double

Methods

Clone()

Creates a copy of this config group.

public SlotConfigs Clone()

Returns

SlotConfigs

Deserialize(string)

Deserialize string and put values into this object

public StatusCode Deserialize(string to_deserialize)

Parameters

to_deserialize string

String to deserialize

Returns

StatusCode

OK if deserialization is OK

From(Slot0Configs)

Converts the provided value to an instance of this type.

public static SlotConfigs From(Slot0Configs value)

Parameters

value Slot0Configs

The value to convert

Returns

SlotConfigs

Converted value

From(Slot1Configs)

Converts the provided value to an instance of this type.

public static SlotConfigs From(Slot1Configs value)

Parameters

value Slot1Configs

The value to convert

Returns

SlotConfigs

Converted value

From(Slot2Configs)

Converts the provided value to an instance of this type.

public static SlotConfigs From(Slot2Configs value)

Parameters

value Slot2Configs

The value to convert

Returns

SlotConfigs

Converted value

Serialize()

Serialize this object into a string

public string Serialize()

Returns

string

This object's data serialized into a string

ToString()

Provides the string representation of this object

public override string ToString()

Returns

string

WithGainSchedBehavior(GainSchedBehaviorValue)

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.
public SlotConfigs WithGainSchedBehavior(GainSchedBehaviorValue newGainSchedBehavior)

Parameters

newGainSchedBehavior GainSchedBehaviorValue

Parameter to modify

Returns

SlotConfigs

Itself

WithGravityArmPositionOffset(double)

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 Value0.25
  • Default Value0
  • Unitsrotations
public SlotConfigs WithGravityArmPositionOffset(double newGravityArmPositionOffset)

Parameters

newGravityArmPositionOffset double

Parameter to modify

Returns

SlotConfigs

Itself

WithGravityType(GravityTypeValue)

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.
public SlotConfigs WithGravityType(GravityTypeValue newGravityType)

Parameters

newGravityType GravityTypeValue

Parameter to modify

Returns

SlotConfigs

Itself

WithKA(double)

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 Value0
  • Maximum Value3.4e+38
  • Default Value0
  • Units
public SlotConfigs WithKA(double newKA)

Parameters

newKA double

Parameter to modify

Returns

SlotConfigs

Itself

WithKD(double)

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 Value0
  • Maximum Value3.4e+38
  • Default Value0
  • Units
public SlotConfigs WithKD(double newKD)

Parameters

newKD double

Parameter to modify

Returns

SlotConfigs

Itself

WithKG(double)

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 Value127
  • Default Value0
  • Units
public SlotConfigs WithKG(double newKG)

Parameters

newKG double

Parameter to modify

Returns

SlotConfigs

Itself

WithKI(double)

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 Value0
  • Maximum Value3.4e+38
  • Default Value0
  • Units
public SlotConfigs WithKI(double newKI)

Parameters

newKI double

Parameter to modify

Returns

SlotConfigs

Itself

WithKP(double)

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 Value0
  • Maximum Value3.4e+38
  • Default Value0
  • Units
public SlotConfigs WithKP(double newKP)

Parameters

newKP double

Parameter to modify

Returns

SlotConfigs

Itself

WithKS(double)

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 Value127
  • Default Value0
  • Units
public SlotConfigs WithKS(double newKS)

Parameters

newKS double

Parameter to modify

Returns

SlotConfigs

Itself

WithKV(double)

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 Value0
  • Maximum Value3.4e+38
  • Default Value0
  • Units
public SlotConfigs WithKV(double newKV)

Parameters

newKV double

Parameter to modify

Returns

SlotConfigs

Itself

WithStaticFeedforwardSign(StaticFeedforwardSignValue)

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.
public SlotConfigs WithStaticFeedforwardSign(StaticFeedforwardSignValue newStaticFeedforwardSign)

Parameters

newStaticFeedforwardSign StaticFeedforwardSignValue

Parameter to modify

Returns

SlotConfigs

Itself