SparkMaxAbsoluteEncoder

class rev.SparkMaxAbsoluteEncoder

Bases: AbsoluteEncoder

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

Deprecated:

Use SparkAbsoluteEncoder instead

class Type(value: int)

Bases: pybind11_object

The type of encoder connected to a SPARK MAX

Deprecated:

Use SparkAbsoluteEncoder::Type instead

Members:

kDutyCycle

kDutyCycle = <Type.kDutyCycle: 0>
property name
property value
getAverageDepth() int

Get the average sampling depth for an absolute encoder

Returns:

The average sampling depth

getInverted() bool

Get the phase of the AbsoluteEncoder

Returns:

The phase of the encoder

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 setPositionConversionFactor().

Returns:

Number of rotations of the motor

getPositionConversionFactor() float

Get the conversion factor for position of the encoder. Multiplied by the native output units to give you position

Returns:

The conversion factor for position

getVelocity() float

Get the velocity of the motor. This returns the native units of ‘rotations per second’ by default, and can be changed by a scale factor using setVelocityConversionFactor().

Returns:

Number of rotations per second of the motor

getVelocityConversionFactor() float

Get the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity

Returns:

The conversion factor for velocity

getZeroOffset() float

Gets the zero offset for an absolute encoder (the position that is reported as zero).

The zero offset is specified as the reported position of the encoder in the desired zero position, if the zero offset was set to 0. It is influenced by the absolute encoder’s position conversion factor, and whether it is inverted.

Returns:

The zero offset of the absolute encoder with the position conversion factor applied

setAverageDepth(depth: int) rev._rev.REVLibError

Set the average sampling depth for an absolute encoder. This is a bit size and should be either 1, 2, 4, 8, 16, 32, 64, or 128

Parameters:

depth – The average sampling depth of 1, 2, 4, 8, 16, 32, 64, or 128

Returns:

REVLibError::kOk if successful

setInverted(inverted: bool) rev._rev.REVLibError

Set the phase of the AbsoluteEncoder so that it is set to be in phase with the motor itself

Parameters:

inverted – The phase of the encoder

Returns:

REVLibError::kOk if successful

setPositionConversionFactor(factor: float) rev._rev.REVLibError

Set the conversion factor for position of the encoder. Multiplied by the native output units to give you position

Parameters:

factor – The conversion factor to multiply the native units by

Returns:

REVLibError::kOk if successful

setVelocityConversionFactor(factor: float) rev._rev.REVLibError

Set the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity

Parameters:

factor – The conversion factor to multiply the native units by

Returns:

REVLibError::kOk if successful

setZeroOffset(offset: float) rev._rev.REVLibError

Sets the zero offset of an absolute encoder (the position that is reported as zero).

The zero offset is specified as the reported position of the encoder in the desired zero position, if the zero offset was set to 0. It is influenced by the absolute encoder’s position conversion factor, and whether it is inverted.

Always call SetPositionConversionFactor() and SetInverted() before calling this function.

Parameters:

offset – The zero offset with the position conversion factor applied

Returns:

REVLibError::kOk if successful