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 TypeMethodDescriptiondouble
Get the position of the motor.double
Get 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 using setPositionConversionFactor().- 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 using setVelocityConversionFactor().- 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 using setPositionConversionFactor().- Parameters:
position
- Number of rotations of the motor- Returns:
REVLibError.kOk
if successful
-