REVLib - C++
|
#include <CANEncoder.h>
Inherits rev::MotorFeedbackSensor.
Inherited by rev::RelativeEncoder.
Public Types | |
enum class | EncoderType { kNoSensor = 0 , kHallSensor = 1 , kQuadrature = 2 } |
enum class | AlternateEncoderType { kQuadrature } |
Public Member Functions | |
virtual | ~CANEncoder () |
virtual double | GetPosition () const =0 |
virtual double | GetVelocity () const =0 |
virtual REVLibError | SetPosition (double position)=0 |
virtual REVLibError | SetPositionConversionFactor (double factor)=0 |
virtual REVLibError | SetVelocityConversionFactor (double factor)=0 |
virtual double | GetPositionConversionFactor () const =0 |
virtual double | GetVelocityConversionFactor () const =0 |
virtual REVLibError | SetAverageDepth (uint32_t depth)=0 |
virtual REVLibError | SetMeasurementPeriod (uint32_t period_ms)=0 |
virtual uint32_t | GetAverageDepth () const =0 |
virtual uint32_t | GetMeasurementPeriod () const =0 |
virtual uint32_t | GetCountsPerRevolution () const =0 |
REVLibError | SetInverted (bool inverted) override=0 |
bool | GetInverted () const override=0 |
Public Member Functions inherited from rev::MotorFeedbackSensor | |
virtual | ~MotorFeedbackSensor () |
Public Member Functions inherited from rev::CANSensor | |
virtual | ~CANSensor () |
Friends | |
class | RelativeEncoder |
|
strong |
Enumerator | |
---|---|
kNoSensor | |
kHallSensor | |
kQuadrature |
|
strong |
Enumerator | |
---|---|
kQuadrature |
|
inlinevirtual |
|
pure virtual |
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().
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
pure virtual |
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().
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
pure virtual |
Set the position of the encoder.
position | Number of rotations of the motor |
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
pure virtual |
Set the conversion factor for position of the encoder. Multiplied by the native output units to give you position
factor | The conversion factor to multiply the native units by |
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
pure virtual |
Set the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity
factor | The conversion factor to multiply the native units by |
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
pure virtual |
Get the conversion factor for position of the encoder. Multiplied by the native output units to give you position
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
pure virtual |
Get the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
pure virtual |
Set the average sampling depth for a quadrature encoder. This value sets the number of samples in the average for velocity readings. This can be any value from 1 to 64.
When the SparkMax controller is in Brushless mode, this will not change any behavior.
depth | The average sampling depth between 1 and 64 (default) |
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
pure virtual |
Set the measurement period for velocity measurements of a quadrature encoder. When the SparkMax controller is in Brushless mode, this will not change any behavior.
The basic formula to calculate velocity is change in positon / change in time. This parameter sets the change in time for measurement.
period_ms | Measurement period in milliseconds. This number may be between 1 and 100 (default). |
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
pure virtual |
Get the average sampling depth for a quadrature encoder.
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
pure virtual |
Get the number of samples for reading from a quadrature encoder. This value sets the number of samples in the average for velocity readings.
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
pure virtual |
Get the counts per revolution of the quadrature encoder.
For a description on the difference between CPR, PPR, etc. go to https://www.cuidevices.com/blog/what-is-encoder-ppr-cpr-and-lpr
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
overridepure virtual |
Set the phase of the MotorFeedbackSensor so that it is set to be in phase with the motor itself. This only works for quadrature encoders. This will throw an error if the user tries to set inverted while the SparkMax is Brushless and using the hall effect sensor.
inverted | The phase of the encoder |
Implements rev::MotorFeedbackSensor.
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
overridepure virtual |
Get the phase of the MotorFeedbackSensor. This will just return false if the user tries to get inverted while the SparkMax is Brushless and using the hall effect sensor.
Implements rev::MotorFeedbackSensor.
Implemented in rev::SparkFlexExternalEncoder, rev::SparkMaxAlternateEncoder, rev::SparkMaxRelativeEncoder, and rev::RelativeEncoder.
|
friend |