SparkRelativeEncoder

class rev.SparkRelativeEncoder

Bases: RelativeEncoder

Get an instance of this class by using SparkBase::GetEncoder() or SparkBase::GetEncoder(SparkRelativeEncoder::Type, int).

getPosition() float

Get the position of the motor. This returns the native units of ‘rotations’ by default, and can be changed by a scale factor using EncoderConfig::PositionConversionFactor().

Returns:

Number of rotations of the motor

getVelocity() float

Get the velocity of the motor. This returns the native units of ‘RPM’ by default, and can be changed by a scale factor using EncoderConfig::VelocityConversionFactor().

Returns:

Number the RPM of the motor

setPosition(position: SupportsFloat | SupportsIndex) rev._rev.REVLibError

Set the position of the encoder.

Parameters:

position – Number of rotations of the motor

Returns:

REVLibError::kOk if successful