Package swervelib.encoders
Class SparkMaxAnalogEncoderSwerve
java.lang.Object
swervelib.encoders.SwerveAbsoluteEncoder
swervelib.encoders.SparkMaxAnalogEncoderSwerve
SparkMax absolute encoder, attached through the data port analog pin.
-
Field Summary
Modifier and TypeFieldDescriptionprivate Alert
AnAlert
for if the absolute encoder does not support integrated offsets.com.revrobotics.SparkAnalogSensor
TheSparkAnalogSensor
representing the duty cycle encoder attached to the SparkMax analog port.private Alert
AnAlert
for if there is a failure configuring the encoder.Fields inherited from class swervelib.encoders.SwerveAbsoluteEncoder
maximumRetries, readingError
-
Constructor Summary
ConstructorDescriptionCreate theSparkMaxAnalogEncoderSwerve
object as a analog sensor from theCANSparkMax
motor data port analog pin. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear sticky faults on the encoder.void
configure
(boolean inverted) Configure the absolute encoder to read from [0, 360) per second.private void
configureSparkMax
(Supplier<com.revrobotics.REVLibError> config) Run the configuration until it succeeds or times out.void
Reset the encoder to factory defaults.Get the instantiated absolute encoder Object.double
Get the absolute position of the encoder.double
Get the velocity in degrees/sec.boolean
setAbsoluteEncoderOffset
(double offset) Sets the Absolute Encoder offset at the Encoder Level.
-
Field Details
-
encoder
public com.revrobotics.SparkAnalogSensor encoderTheSparkAnalogSensor
representing the duty cycle encoder attached to the SparkMax analog port. -
failureConfiguring
AnAlert
for if there is a failure configuring the encoder. -
doesNotSupportIntegratedOffsets
AnAlert
for if the absolute encoder does not support integrated offsets.
-
-
Constructor Details
-
SparkMaxAnalogEncoderSwerve
Create theSparkMaxAnalogEncoderSwerve
object as a analog sensor from theCANSparkMax
motor data port analog pin.- Parameters:
motor
- Motor to create the encoder from.
-
-
Method Details
-
configureSparkMax
Run the configuration until it succeeds or times out.- Parameters:
config
- Lambda supplier returning the error state.
-
factoryDefault
public void factoryDefault()Reset the encoder to factory defaults.- Specified by:
factoryDefault
in classSwerveAbsoluteEncoder
-
clearStickyFaults
public void clearStickyFaults()Clear sticky faults on the encoder.- Specified by:
clearStickyFaults
in classSwerveAbsoluteEncoder
-
configure
public void configure(boolean inverted) Configure the absolute encoder to read from [0, 360) per second.- Specified by:
configure
in classSwerveAbsoluteEncoder
- Parameters:
inverted
- Whether the encoder is inverted.
-
getAbsolutePosition
public double getAbsolutePosition()Get the absolute position of the encoder.- Specified by:
getAbsolutePosition
in classSwerveAbsoluteEncoder
- Returns:
- Absolute position in degrees from [0, 360).
-
getAbsoluteEncoder
Get the instantiated absolute encoder Object.- Specified by:
getAbsoluteEncoder
in classSwerveAbsoluteEncoder
- Returns:
- Absolute encoder object.
-
setAbsoluteEncoderOffset
public boolean setAbsoluteEncoderOffset(double offset) Sets the Absolute Encoder offset at the Encoder Level.- Specified by:
setAbsoluteEncoderOffset
in classSwerveAbsoluteEncoder
- Parameters:
offset
- the offset the Absolute Encoder uses as the zero point.- Returns:
- if setting Absolute Encoder Offset was successful or not.
-
getVelocity
public double getVelocity()Get the velocity in degrees/sec.- Specified by:
getVelocity
in classSwerveAbsoluteEncoder
- Returns:
- velocity in degrees/sec.
-