CANAnalog
- class rev.CANAnalog
Bases:
MotorFeedbackSensor
- Deprecated:
Use SparkMaxAnalogSensor instead.
- class AnalogMode(value: int)
Bases:
pybind11_object
Analog sensors have the ability to either be absolute or relative. By default, GetAnalog() will return an absolute analog sensor, but it can also be configured to be a relative sensor instead.
- Deprecated:
Use SparkMaxAnalogSensor::Mode instead
Members:
kAbsolute
kRelative
- kAbsolute = <AnalogMode.kAbsolute: 0>
- kRelative = <AnalogMode.kRelative: 1>
- property name
- property value
- getAverageDepth() int
Get the number of samples included in the average for velocity readings.
- Returns:
The average sampling depth
- getInverted() bool
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
- getMeasurementPeriod() int
Get the measurement period used for velocity calculation.
- Returns:
Measurement period in microseconds
- getPosition() float
Get the position of the sensor. Returns value in the native unit of ‘volt’ by default, and can be changed by a scale factor using setPositionConversionFactor().
- Returns:
Position of the sensor in volts
- getPositionConversionFactor() float
Get the current conversion factor for the position of the analog sensor.
- Returns:
Analog position conversion factor
- getVelocity() float
Get the velocity of the sensor. Returns value in the native units of ‘volts per second’ by default, and can be changed by a scale factor using setVelocityConversionFactor().
- Returns:
Velocity of the sensor in volts per second
- getVelocityConversionFactor() float
Get the current conversion factor for the velocity of the analog sensor.
- Returns:
Analog velocity conversion factor
- getVoltage() float
Get the voltage of the analog sensor.
- Returns:
Voltage of the sensor
- setAverageDepth(depth: int) rev._rev.REVLibError
Set 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.
- Parameters:
depth – The average sampling depth between 1 and 64 (default)
- Returns:
REVLibError::kOk if successful
- setInverted(inverted: bool) rev._rev.REVLibError
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
- setMeasurementPeriod(period_ms: int) rev._rev.REVLibError
Set the measurement period for velocity calculations.
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. This number may be between 1 and 100 (default).
- Returns:
REVLibError::kOk if successful
- setPositionConversionFactor(factor: float) rev._rev.REVLibError
Set the conversion factor for the position of the analog sensor. By default, revolutions per volt is 1. Changing the position conversion factor will also change the position units.
- Parameters:
factor – The conversion factor which will be multiplied by volts
- Returns:
REVLibError::kOk if successful
- setVelocityConversionFactor(factor: float) rev._rev.REVLibError
Set the conversion factor for the velocity of the analog sensor. By default, revolutions per volt second is 1. Changing the velocity conversion factor will also change the velocity units.
- Parameters:
factor – The conversion factor which will be multipled by volts per second
- Returns:
REVLibError::kOk if successful