Class ClosedLoopGeneralConfigs
Configs that affect general behavior during closed-looping.
Includes Continuous Wrap features.public class ClosedLoopGeneralConfigs : IParentConfiguration, ISerializable, ICloneable
- Inheritance
-
ClosedLoopGeneralConfigs
- Implements
- Inherited Members
Fields
ContinuousWrap
Wrap position error within [-0.5, +0.5) mechanism rotations. Typically used for continuous position closed-loops like swerve azimuth.
This uses the mechanism rotation value. If there is a gear ratio between the sensor and the mechanism, make sure to apply a SensorToMechanismRatio so the closed loop operates on the full rotation.- Default ValueFalse
public bool ContinuousWrap
Field Value
DifferentialContinuousWrap
Wrap differential difference position error within [-0.5, +0.5) mechanism rotations. Typically used for continuous position closed-loops like a differential wrist.
This uses the differential difference rotation value. If there is a gear ratio on the difference axis, make sure to apply a SensorToDifferentialRatio so the closed loop operates on the full rotation.- Default ValueFalse
public bool DifferentialContinuousWrap
Field Value
GainSchedErrorThreshold
The position closed-loop error threshold for gain scheduling. When the absolute value of the closed-loop error is within the threshold (inclusive), the PID controller will automatically switch gains according to the configured GainSchedBehavior of the slot.
When this is zero (default), no gain scheduling will occur. Additionally, this does not take effect for velocity closed-loop controls. This can be used to implement a closed-loop deadband or, less commonly, to switch to weaker gains when close to the target.- Minimum Value0.0
- Maximum Value1.0
- Default Value0.0
- Unitsrotations
public double GainSchedErrorThreshold
Field Value
GainSchedKpBehavior
The behavior of kP output as the error crosses the GainSchedErrorThreshold during gain scheduling. The output of kP can be adjusted to maintain continuity in output, or it can be left discontinuous.
public GainSchedKpBehaviorValue GainSchedKpBehavior
Field Value
Methods
Clone()
Creates a copy of this config group.
public ClosedLoopGeneralConfigs Clone()
Returns
Deserialize(string)
Deserialize string and put values into this object
public StatusCode Deserialize(string to_deserialize)
Parameters
to_deserializestringString to deserialize
Returns
- StatusCode
OK if deserialization is OK
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
WithContinuousWrap(bool)
Modifies this configuration's ContinuousWrap parameter and returns itself for method-chaining and easier to use config API.
Wrap position error within [-0.5, +0.5) mechanism rotations. Typically used for continuous position closed-loops like swerve azimuth. This uses the mechanism rotation value. If there is a gear ratio between the sensor and the mechanism, make sure to apply a SensorToMechanismRatio so the closed loop operates on the full rotation.- Default ValueFalse
public ClosedLoopGeneralConfigs WithContinuousWrap(bool newContinuousWrap)
Parameters
newContinuousWrapboolParameter to modify
Returns
- ClosedLoopGeneralConfigs
Itself
WithDifferentialContinuousWrap(bool)
Modifies this configuration's DifferentialContinuousWrap parameter and returns itself for method-chaining and easier to use config API.
Wrap differential difference position error within [-0.5, +0.5) mechanism rotations. Typically used for continuous position closed-loops like a differential wrist. This uses the differential difference rotation value. If there is a gear ratio on the difference axis, make sure to apply a SensorToDifferentialRatio so the closed loop operates on the full rotation.- Default ValueFalse
public ClosedLoopGeneralConfigs WithDifferentialContinuousWrap(bool newDifferentialContinuousWrap)
Parameters
newDifferentialContinuousWrapboolParameter to modify
Returns
- ClosedLoopGeneralConfigs
Itself
WithGainSchedErrorThreshold(double)
Modifies this configuration's GainSchedErrorThreshold parameter and returns itself for method-chaining and easier to use config API.
The position closed-loop error threshold for gain scheduling. When the absolute value of the closed-loop error is within the threshold (inclusive), the PID controller will automatically switch gains according to the configured GainSchedBehavior of the slot. When this is zero (default), no gain scheduling will occur. Additionally, this does not take effect for velocity closed-loop controls. This can be used to implement a closed-loop deadband or, less commonly, to switch to weaker gains when close to the target.- Minimum Value0.0
- Maximum Value1.0
- Default Value0.0
- Unitsrotations
public ClosedLoopGeneralConfigs WithGainSchedErrorThreshold(double newGainSchedErrorThreshold)
Parameters
newGainSchedErrorThresholddoubleParameter to modify
Returns
- ClosedLoopGeneralConfigs
Itself
WithGainSchedKpBehavior(GainSchedKpBehaviorValue)
Modifies this configuration's GainSchedKpBehavior parameter and returns itself for method-chaining and easier to use config API.
The behavior of kP output as the error crosses the GainSchedErrorThreshold during gain scheduling. The output of kP can be adjusted to maintain continuity in output, or it can be left discontinuous.public ClosedLoopGeneralConfigs WithGainSchedKpBehavior(GainSchedKpBehaviorValue newGainSchedKpBehavior)
Parameters
newGainSchedKpBehaviorGainSchedKpBehaviorValueParameter to modify
Returns
- ClosedLoopGeneralConfigs
Itself