Package com.revrobotics
Class SparkMaxAnalogSensor
- java.lang.Object
-
- com.revrobotics.SparkMaxAnalogSensor
-
- All Implemented Interfaces:
AnalogInput
,CANAnalog
,CANSensor
,MotorFeedbackSensor
public class SparkMaxAnalogSensor extends java.lang.Object implements AnalogInput, CANAnalog
Get an instance of this class by usingCANSparkMax.getAnalog(Mode)
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SparkMaxAnalogSensor.Mode
-
Nested classes/interfaces inherited from interface com.revrobotics.CANAnalog
CANAnalog.AnalogMode
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getInverted()
Get the phase of the analog sensordouble
getPosition()
Get the position of the sensor.double
getPositionConversionFactor()
Get the current conversion factor for the position of the analog sensor.double
getVelocity()
Get the velocity of the sensor.double
getVelocityConversionFactor()
Get the current conversion factor for the velocity of the analog sensor.double
getVoltage()
Get the voltage of the analog sensor.REVLibError
setInverted(boolean inverted)
Set the phase of the anlog sensor so that it is set to be in phase with the motor itselfREVLibError
setPositionConversionFactor(double factor)
Set the conversion factor for the position of the analog sensor.REVLibError
setVelocityConversionFactor(double factor)
Set the conversion factor for the velocity of the analog sensor.
-
-
-
Method Detail
-
getVoltage
public double getVoltage()
Get the voltage of the analog sensor.- Specified by:
getVoltage
in interfaceAnalogInput
- Specified by:
getVoltage
in interfaceCANAnalog
- Returns:
- Voltage of the sensor.
-
getPosition
public double 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
public double 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
public REVLibError setPositionConversionFactor(double factor)
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
public REVLibError setVelocityConversionFactor(double factor)
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
public double 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
public double getVelocityConversionFactor()
Get the current conversion factor for the velocity of the analog sensor.- Specified by:
getVelocityConversionFactor
in interfaceCANAnalog
- Returns:
- Analog velocity conversion factor
-
setInverted
public REVLibError setInverted(boolean inverted)
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
public boolean 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
-
-