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 TypeMethodDescriptionbooleanGet the phase of the analog sensordoubleGet the position of the sensor.doubleGet the current conversion factor for the position of the analog sensor.doubleGet the velocity of the sensor.doubleGet the current conversion factor for the velocity of the analog sensor.doubleGet 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:
getVoltagein interfaceAnalogInput- Specified by:
getVoltagein 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:
getPositionin interfaceAnalogInput- Specified by:
getPositionin 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:
getVelocityin 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:
setPositionConversionFactorin interfaceAnalogInput- Specified by:
setPositionConversionFactorin interfaceCANAnalog- Parameters:
factor- The conversion factor which will be multiplied by volts- Returns:
REVLibError.kOkif 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:
setVelocityConversionFactorin interfaceCANAnalog- Parameters:
factor- The conversion factor which will be multiplied by volts per second- Returns:
REVLibError.kOkif successful
-
getPositionConversionFactor
Get the current conversion factor for the position of the analog sensor.- Specified by:
getPositionConversionFactorin interfaceAnalogInput- Specified by:
getPositionConversionFactorin interfaceCANAnalog- Returns:
- Analog position conversion factor
-
getVelocityConversionFactor
Get the current conversion factor for the velocity of the analog sensor.- Specified by:
getVelocityConversionFactorin 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:
setInvertedin interfaceCANAnalog- Specified by:
setInvertedin interfaceCANSensor- Specified by:
setInvertedin interfaceMotorFeedbackSensor- Parameters:
inverted- The phase of the sensor- Returns:
REVLibError.kOkif successful
-
getInverted
Get the phase of the analog sensor- Specified by:
getInvertedin interfaceCANAnalog- Specified by:
getInvertedin interfaceCANSensor- Specified by:
getInvertedin interfaceMotorFeedbackSensor- Returns:
- The phase of the sensor
-