Class SparkRelativeEncoder

java.lang.Object
com.revrobotics.spark.SparkRelativeEncoder
All Implemented Interfaces:
RelativeEncoder

public class SparkRelativeEncoder extends Object implements RelativeEncoder
Get an instance of this class by using SparkBase.getEncoder().
  • Method Details

    • getPosition

      public double getPosition()
      Description copied from interface: RelativeEncoder
      Get the position of the motor. This returns the native units of 'rotations' by default, and can be changed by a scale factor using setPositionConversionFactor().
      Specified by:
      getPosition in interface RelativeEncoder
      Returns:
      Number of rotations of the motor
    • getVelocity

      public double getVelocity()
      Description copied from interface: RelativeEncoder
      Get the velocity of the motor. This returns the native units of 'RPM' by default, and can be changed by a scale factor using setVelocityConversionFactor().
      Specified by:
      getVelocity in interface RelativeEncoder
      Returns:
      Number the RPM of the motor
    • setPosition

      public REVLibError setPosition(double position)
      Description copied from interface: RelativeEncoder
      Set the position of the encoder. By default the units are 'rotations' and can be changed by a scale factor using setPositionConversionFactor().
      Specified by:
      setPosition in interface RelativeEncoder
      Parameters:
      position - Number of rotations of the motor
      Returns:
      REVLibError.kOk if successful