Package com.revrobotics
Interface RelativeEncoder
- All Known Implementing Classes:
SparkFlexExternalEncoder,SparkMaxAlternateEncoder,SparkRelativeEncoder
public interface RelativeEncoder
Get an instance of this interface by using
SparkBase.getEncoder(), SparkMax.getAlternateEncoder(), or SparkFlex.getExternalEncoder().-
Method Summary
Modifier and TypeMethodDescriptiondoubleGet the position of the motor.doubleGet the velocity of the motor.setPosition(double position) Set the position of the encoder.
-
Method Details
-
getPosition
double getPosition()Get the position of the motor. This returns the native units of 'rotations' by default, and can be changed by a scale factor usingAlternateEncoderConfig.positionConversionFactor(double), orExternalEncoderConfig.positionConversionFactor(double), orEncoderConfig.positionConversionFactor(double).- Returns:
- Number of rotations of the motor
-
getVelocity
double getVelocity()Get the velocity of the motor. This returns the native units of 'RPM' by default, and can be changed by a scale factor usingAlternateEncoderConfig.velocityConversionFactor(double), orExternalEncoderConfig.velocityConversionFactor(double), orEncoderConfig.velocityConversionFactor(double).- Returns:
- Number the RPM of the motor
-
setPosition
Set the position of the encoder. By default the units are 'rotations' and can be changed by a scale factor usingAlternateEncoderConfig.positionConversionFactor(double), orExternalEncoderConfig.positionConversionFactor(double), orEncoderConfig.positionConversionFactor(double).- Parameters:
position- Number of rotations of the motor- Returns:
REVLibError.kOkif successful
-