Package com.revrobotics
Class SparkMaxAnalogSensor
java.lang.Object
com.revrobotics.SparkMaxAnalogSensor
- All Implemented Interfaces:
AnalogInput
,CANAnalog
,CANSensor
,MotorFeedbackSensor
Get an instance of this class by using
CANSparkMax.getAnalog(Mode)
.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.revrobotics.CANAnalog
CANAnalog.AnalogMode
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Get the phase of the analog sensordouble
Get the position of the sensor.double
Get the current conversion factor for the position of the analog sensor.double
Get the velocity of the sensor.double
Get the current conversion factor for the velocity of the analog sensor.double
Get the voltage of the analog sensor.setInverted
(boolean inverted) Set the phase of the anlog sensor so that it is set to be in phase with the motor itselfsetPositionConversionFactor
(double factor) Set the conversion factor for the position of the analog sensor.setVelocityConversionFactor
(double factor) Set the conversion factor for the velocity of the analog sensor.
-
Method Details
-
getVoltage
Get the voltage of the analog sensor.- Specified by:
getVoltage
in interfaceAnalogInput
- Specified by:
getVoltage
in interfaceCANAnalog
- Returns:
- Voltage of the sensor.
-
getPosition
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().- Specified by:
getPosition
in interfaceAnalogInput
- Specified by:
getPosition
in interfaceCANAnalog
- Returns:
- Position of the sensor
-
getVelocity
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().- Specified by:
getVelocity
in interfaceCANAnalog
- Returns:
- Velocity of the sensor in volts per second
-
setPositionConversionFactor
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.- Specified by:
setPositionConversionFactor
in interfaceAnalogInput
- Specified by:
setPositionConversionFactor
in interfaceCANAnalog
- Parameters:
factor
- The conversion factor which will be multiplied by volts- Returns:
REVLibError.kOk
if successful
-
setVelocityConversionFactor
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.- Specified by:
setVelocityConversionFactor
in interfaceCANAnalog
- Parameters:
factor
- The conversion factor which will be multiplied by volts per second- Returns:
REVLibError.kOk
if successful
-
getPositionConversionFactor
Get the current conversion factor for the position of the analog sensor.- Specified by:
getPositionConversionFactor
in interfaceAnalogInput
- Specified by:
getPositionConversionFactor
in interfaceCANAnalog
- Returns:
- Analog position conversion factor
-
getVelocityConversionFactor
Get the current conversion factor for the velocity of the analog sensor.- Specified by:
getVelocityConversionFactor
in interfaceCANAnalog
- Returns:
- Analog velocity conversion factor
-
setInverted
Set the phase of the anlog sensor so that it is set to be in phase with the motor itself- Specified by:
setInverted
in interfaceCANAnalog
- Specified by:
setInverted
in interfaceCANSensor
- Specified by:
setInverted
in interfaceMotorFeedbackSensor
- Parameters:
inverted
- The phase of the sensor- Returns:
REVLibError.kOk
if successful
-
getInverted
Get the phase of the analog sensor- Specified by:
getInverted
in interfaceCANAnalog
- Specified by:
getInverted
in interfaceCANSensor
- Specified by:
getInverted
in interfaceMotorFeedbackSensor
- Returns:
- The phase of the sensor
-