Package com.revrobotics.spark
Class SparkRelativeEncoder
java.lang.Object
com.revrobotics.spark.SparkRelativeEncoder
- All Implemented Interfaces:
RelativeEncoder
Get an instance of this class by using
SparkBase.getEncoder().-
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
public double getPosition()Description copied from interface:RelativeEncoderGet 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).- Specified by:
getPositionin interfaceRelativeEncoder- Returns:
- Number of rotations of the motor
-
getVelocity
public double getVelocity()Description copied from interface:RelativeEncoderGet 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).- Specified by:
getVelocityin interfaceRelativeEncoder- Returns:
- Number the RPM of the motor
-
setPosition
Description copied from interface:RelativeEncoderSet 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).- Specified by:
setPositionin interfaceRelativeEncoder- Parameters:
position- Number of rotations of the motor- Returns:
REVLibError.kOkif successful
-