Class ClosedLoopGeneralConfigs

java.lang.Object
com.ctre.phoenix6.configs.ClosedLoopGeneralConfigs
All Implemented Interfaces:
ParentConfiguration, ISerializable, Cloneable

Configs that affect general behavior during closed-looping.

Includes Continuous Wrap features.

  • Field Details

    • ContinuousWrap

      public boolean 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 Value: False
    • 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 Value: False
    • GainSchedErrorThreshold

      public double 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 Value: 0.0
      • Maximum Value: 1.0
      • Default Value: 0.0
      • Units: rotations
    • 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.
  • Constructor Details

  • Method Details

    • withContinuousWrap

      public final ClosedLoopGeneralConfigs withContinuousWrap(boolean newContinuousWrap)
      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 Value: False
      Parameters:
      newContinuousWrap - Parameter to modify
      Returns:
      Itself
    • withDifferentialContinuousWrap

      public final ClosedLoopGeneralConfigs withDifferentialContinuousWrap(boolean newDifferentialContinuousWrap)
      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 Value: False
      Parameters:
      newDifferentialContinuousWrap - Parameter to modify
      Returns:
      Itself
    • withGainSchedErrorThreshold

      public final ClosedLoopGeneralConfigs withGainSchedErrorThreshold(double newGainSchedErrorThreshold)
      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 Value: 0.0
      • Maximum Value: 1.0
      • Default Value: 0.0
      • Units: rotations
      Parameters:
      newGainSchedErrorThreshold - Parameter to modify
      Returns:
      Itself
    • withGainSchedErrorThreshold

      public final ClosedLoopGeneralConfigs withGainSchedErrorThreshold(Angle newGainSchedErrorThreshold)
      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 Value: 0.0
      • Maximum Value: 1.0
      • Default Value: 0.0
      • Units: rotations
      Parameters:
      newGainSchedErrorThreshold - Parameter to modify
      Returns:
      Itself
    • getGainSchedErrorThresholdMeasure

      Helper method to get this configuration's GainSchedErrorThreshold parameter converted to a unit type. If not using the Java units library, GainSchedErrorThreshold can be accessed directly instead.

      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 Value: 0.0
      • Maximum Value: 1.0
      • Default Value: 0.0
      • Units: rotations
      Returns:
      GainSchedErrorThreshold
    • withGainSchedKpBehavior

      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.

      Parameters:
      newGainSchedKpBehavior - Parameter to modify
      Returns:
      Itself
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • serialize

      public final String serialize()
      Get the serialized form of this configuration group.
      Specified by:
      serialize in interface ISerializable
      Returns:
      Serialized form of this config group
    • deserialize

      public final StatusCode deserialize(String to_deserialize)
      Take a string and deserialize it to this configuration group.
      Specified by:
      deserialize in interface ParentConfiguration
      Returns:
      Return code of the deserialize method
    • clone

      Overrides:
      clone in class Object