Class AnalogAbsoluteEncoderSwerve

java.lang.Object
swervelib.encoders.SwerveAbsoluteEncoder
swervelib.encoders.AnalogAbsoluteEncoderSwerve

public class AnalogAbsoluteEncoderSwerve extends SwerveAbsoluteEncoder
Swerve Absolute Encoder for Thrifty Encoders and other analog encoders.
  • Field Details

    • encoder

      public edu.wpi.first.wpilibj.AnalogInput encoder
      Encoder as Analog Input.
    • inverted

      private boolean inverted
      Inversion state of the encoder.
    • cannotSetOffset

      private Alert cannotSetOffset
      An Alert for if the absolute encoder offset cannot be set.
    • inaccurateVelocities

      private Alert inaccurateVelocities
      An Alert detailing how the analog absolute encoder may not report accurate velocities.
  • Constructor Details

    • AnalogAbsoluteEncoderSwerve

      public AnalogAbsoluteEncoderSwerve(edu.wpi.first.wpilibj.AnalogInput encoder)
      Construct the Thrifty Encoder as a Swerve Absolute Encoder.
      Parameters:
      encoder - Encoder to construct.
    • AnalogAbsoluteEncoderSwerve

      public AnalogAbsoluteEncoderSwerve(int channel)
      Construct the Encoder given the analog input channel.
      Parameters:
      channel - Analog Input channel of which the encoder resides.
  • Method Details

    • factoryDefault

      public void factoryDefault()
      Reset the encoder to factory defaults.
      Specified by:
      factoryDefault in class SwerveAbsoluteEncoder
    • clearStickyFaults

      public void clearStickyFaults()
      Clear sticky faults on the encoder.
      Specified by:
      clearStickyFaults in class SwerveAbsoluteEncoder
    • configure

      public void configure(boolean inverted)
      Configure the absolute encoder to read from [0, 360) per second.
      Specified by:
      configure in class SwerveAbsoluteEncoder
      Parameters:
      inverted - Whether the encoder is inverted.
    • getAbsolutePosition

      public double getAbsolutePosition()
      Get the absolute position of the encoder.
      Specified by:
      getAbsolutePosition in class SwerveAbsoluteEncoder
      Returns:
      Absolute position in degrees from [0, 360).
    • getAbsoluteEncoder

      public Object getAbsoluteEncoder()
      Get the instantiated absolute encoder Object.
      Specified by:
      getAbsoluteEncoder in class SwerveAbsoluteEncoder
      Returns:
      Absolute encoder object.
    • setAbsoluteEncoderOffset

      public boolean setAbsoluteEncoderOffset(double offset)
      Cannot Set the offset of an Analog Absolute Encoder.
      Specified by:
      setAbsoluteEncoderOffset in class SwerveAbsoluteEncoder
      Parameters:
      offset - the offset the Absolute Encoder uses as the zero point.
      Returns:
      Will always be false as setting the offset is unsupported of an Analog absolute encoder.
    • getVelocity

      public double getVelocity()
      Get the velocity in degrees/sec.
      Specified by:
      getVelocity in class SwerveAbsoluteEncoder
      Returns:
      velocity in degrees/sec.