+ +
+ +

Class SparkMaxAnalogEncoderSwerve

+
+
java.lang.Object +
swervelib.encoders.SwerveAbsoluteEncoder +
swervelib.encoders.SparkMaxAnalogEncoderSwerve
+
+
+
+
+
public class SparkMaxAnalogEncoderSwerve +extends SwerveAbsoluteEncoder
+
SparkMax absolute encoder, attached through the data port analog pin.
+
+
+ +
+
+
    + +
  • +
    +

    Field Details

    +
      +
    • +
      +

      encoder

      +
      public com.revrobotics.SparkMaxAnalogSensor encoder
      +
      The AbsoluteEncoder representing the duty cycle encoder attached to the SparkMax.
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Constructor Details

    +
      +
    • +
      +

      SparkMaxAnalogEncoderSwerve

      +
      public SparkMaxAnalogEncoderSwerve(SwerveMotor motor)
      +
      Create the SparkMaxAnalogEncoderSwerve object as a analog sensor from the CANSparkMax motor data port analog pin.
      +
      +
      Parameters:
      +
      motor - Motor to create the encoder from.
      +
      +
      +
    • +
    +
    +
  • + +
  • +
    +

    Method Details

    +
      +
    • +
      +

      configureSparkMax

      +
      private void configureSparkMax(Supplier<com.revrobotics.REVLibError> config)
      +
      Run the configuration until it succeeds or times out.
      +
      +
      Parameters:
      +
      config - Lambda supplier returning the error state.
      +
      +
      +
    • +
    • +
      +

      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.
      +
      +
      +
    • +
    • +
      +

      getVelocity

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