#include <SparkMaxRelativeEncoder.h>
Inherits rev::RelativeEncoder.
Inherited by rev::SparkRelativeEncoder.
◆ Type
◆ SparkMaxRelativeEncoder() [1/2]
◆ SparkMaxRelativeEncoder() [2/2]
◆ ~SparkMaxRelativeEncoder()
rev::SparkMaxRelativeEncoder::~SparkMaxRelativeEncoder |
( |
| ) |
|
|
overridedefault |
◆ operator=()
◆ GetPosition()
double SparkMaxRelativeEncoder::GetPosition |
( |
| ) |
const |
|
overridevirtual |
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
Implements rev::RelativeEncoder.
◆ GetVelocity()
double SparkMaxRelativeEncoder::GetVelocity |
( |
| ) |
const |
|
overridevirtual |
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
Implements rev::RelativeEncoder.
◆ SetPosition()
REVLibError SparkMaxRelativeEncoder::SetPosition |
( |
double |
position | ) |
|
|
overridevirtual |
◆ SetPositionConversionFactor()
REVLibError SparkMaxRelativeEncoder::SetPositionConversionFactor |
( |
double |
factor | ) |
|
|
overridevirtual |
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
Implements rev::RelativeEncoder.
◆ SetVelocityConversionFactor()
REVLibError SparkMaxRelativeEncoder::SetVelocityConversionFactor |
( |
double |
factor | ) |
|
|
overridevirtual |
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
Implements rev::RelativeEncoder.
◆ GetPositionConversionFactor()
double SparkMaxRelativeEncoder::GetPositionConversionFactor |
( |
| ) |
const |
|
overridevirtual |
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
Implements rev::RelativeEncoder.
◆ GetVelocityConversionFactor()
double SparkMaxRelativeEncoder::GetVelocityConversionFactor |
( |
| ) |
const |
|
overridevirtual |
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
Implements rev::RelativeEncoder.
◆ SetAverageDepth()
REVLibError SparkMaxRelativeEncoder::SetAverageDepth |
( |
uint32_t |
depth | ) |
|
|
overridevirtual |
Set the sampling depth of the velocity calculation process for a quadrature or hall sensor encoder. This value sets the number of samples in the average for velocity readings. For a quadrature encoder, this can be any value from 1 to 64 (default). For a hall sensor, it must be either 1, 2, 4, or 8 (default).
- Parameters
-
depth | The velocity calculation process's sampling depth |
- Returns
- REVLibError::kOk if successful
Implements rev::RelativeEncoder.
◆ SetMeasurementPeriod()
REVLibError SparkMaxRelativeEncoder::SetMeasurementPeriod |
( |
uint32_t |
period_ms | ) |
|
|
overridevirtual |
Set the position measurement period used to calculate the velocity of a quadrature or hall sensor encoder. For a quadrature encoder, this number may be between 1 and 100 (default). For a hall sensor, this number may be between 8 and 64. The default for a hall sensor is 32ms.
The basic formula to calculate velocity is change in position / change in time. This parameter sets the change in time for measurement.
- Parameters
-
period_ms | Measurement period in milliseconds |
- Returns
- REVLibError::kOk if successful
Implements rev::RelativeEncoder.
◆ GetAverageDepth()
uint32_t SparkMaxRelativeEncoder::GetAverageDepth |
( |
| ) |
const |
|
overridevirtual |
Get the velocity calculation process's sampling depth for a quadrature or hall sensor encoder.
- Returns
- The velocity calculation averaging process's sampling depth
Implements rev::RelativeEncoder.
◆ GetMeasurementPeriod()
uint32_t SparkMaxRelativeEncoder::GetMeasurementPeriod |
( |
| ) |
const |
|
overridevirtual |
Get the position measurement period used to calculate the velocity of a quadrature or hall sensor encoder.
- Returns
- Measurement period in milliseconds
Implements rev::RelativeEncoder.
◆ GetCountsPerRevolution()
uint32_t SparkMaxRelativeEncoder::GetCountsPerRevolution |
( |
| ) |
const |
|
overridevirtual |
◆ SetInverted()
REVLibError SparkMaxRelativeEncoder::SetInverted |
( |
bool |
inverted | ) |
|
|
overridevirtual |
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.
- Parameters
-
inverted | The phase of the encoder |
- Returns
- REVLibError::kOk if successful
Implements rev::RelativeEncoder.
◆ GetInverted()
bool SparkMaxRelativeEncoder::GetInverted |
( |
| ) |
const |
|
overridevirtual |
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.
- Returns
- The phase of the encoder
Implements rev::RelativeEncoder.
◆ CANSparkBase
◆ SparkRelativeEncoder
The documentation for this class was generated from the following files: