Class AbsoluteEncoderConfig

java.lang.Object
com.revrobotics.spark.config.BaseConfig
com.revrobotics.spark.config.AbsoluteEncoderConfig

public class AbsoluteEncoderConfig extends BaseConfig
  • Constructor Details

    • AbsoluteEncoderConfig

      public AbsoluteEncoderConfig()
  • Method Details

    • apply

      Applies settings from another AbsoluteEncoderConfig to this one.

      Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.

      Parameters:
      config - The AbsoluteEncoderConfig to copy settings from
      Returns:
      The updated AbsoluteEncoderConfig for method chaining
    • setSparkMaxDataPortConfig

      public AbsoluteEncoderConfig setSparkMaxDataPortConfig()
      Configures the data port to use the absolute encoder, which is specifically required for SPARK MAX.

      NOTE: This method is only necessary when using an absolute encoder with a SPARK MAX without configuring any of its settings

      IMPORTANT: SPARK MAX does not support using an absolute encoder in conjunction with an alternate encoder.

      Returns:
      The modified AbsoluteEncoderConfig object for method chaining
    • inverted

      public AbsoluteEncoderConfig inverted(boolean inverted)
      Set the phase of the absolute encoder so that it is in phase with the motor itself.

      NOTE: This only applies to an encoder used in brushed mode.

      Parameters:
      inverted - The phase of the encoder
      Returns:
      The modified AbsoluteEncoderConfig object for method chaining
    • positionConversionFactor

      public AbsoluteEncoderConfig positionConversionFactor(double factor)
      Set the conversion factor for the position of the absolute encoder. Position is returned in native units of rotations and will be multiplied by this conversion factor.
      Parameters:
      factor - The conversion factor to multiply the native units by
      Returns:
      The modified AbsoluteEncoderConfig object for method chaining
    • velocityConversionFactor

      public AbsoluteEncoderConfig velocityConversionFactor(double factor)
      Set the conversion factor for the velocity of the absolute encoder. Velocity is returned in native units of rotations per minute and will be multiplied by this conversion factor.
      Parameters:
      factor - The conversion factor to multiply the native units by
      Returns:
      The modified AbsoluteEncoderConfig object for method chaining
    • zeroOffset

      public AbsoluteEncoderConfig zeroOffset(double offset)
      Set the zero offset of the absolute encoder, the position that is reported as zero.

      The zero offset is specified as the reported position of the encoder in the desired zero position as if the zero offset was set to 0, the position conversion factor was set to 1, and inverted was set to false.

      Parameters:
      offset - The zero offset in the range [0, 1)
      Returns:
      The modified AbsoluteEncoderConfig object for method chaining
    • averageDepth

      public AbsoluteEncoderConfig averageDepth(int depth)
      Set the average sampling depth of the absolute encoder. This is a bit size and should be either 1, 2, 4, 8, 16, 32, 64, or 128 (default).
      Parameters:
      depth - The average sampling depth of 1, 2, 4, 8, 16, 32, 64, or 128
      Returns:
      The modified AbsoluteEncoderConfig object for method chaining
    • startPulseUs

      public AbsoluteEncoderConfig startPulseUs(double startPulseUs)
      Set the length of the start pulse for this encoder. This pulse will be treated as the 0.0 position.
      Parameters:
      startPulseUs - The minimum high pulse in microseconds
      Returns:
      The modified AbsoluteEncoderConfig object for method chaining
    • endPulseUs

      public AbsoluteEncoderConfig endPulseUs(double endPulseUs)
      Set the length of the end pulse for this encoder. This pulse will be treated as the 1.0 position.
      Parameters:
      endPulseUs - The minimum low pulse in microseconds
      Returns:
      The modified AbsoluteEncoderConfig object for method chaining