Package swervelib.encoders
Class SparkMaxEncoderSwerve
java.lang.Object
swervelib.encoders.SwerveAbsoluteEncoder
swervelib.encoders.SparkMaxEncoderSwerve
SparkMax absolute encoder, attached through the data port.
-
Field Summary
FieldsModifier and TypeFieldDescriptioncom.revrobotics.AbsoluteEncoderTheAbsoluteEncoderrepresenting the duty cycle encoder attached to the SparkMax.Fields inherited from class swervelib.encoders.SwerveAbsoluteEncoder
readingError -
Constructor Summary
ConstructorsConstructorDescriptionSparkMaxEncoderSwerve(SwerveMotor motor, int conversionFactor) Create theAbsoluteEncoderobject as a duty cycle. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear sticky faults on the encoder.voidconfigure(boolean inverted) Configure the absolute encoder to read from [0, 360) per second.voidReset the encoder to factory defaults.Get the instantiated absolute encoder Object.doubleGet the absolute position of the encoder.
-
Field Details
-
encoder
public com.revrobotics.AbsoluteEncoder encoderTheAbsoluteEncoderrepresenting the duty cycle encoder attached to the SparkMax.
-
-
Constructor Details
-
SparkMaxEncoderSwerve
Create theAbsoluteEncoderobject as a duty cycle. from theCANSparkMaxmotor.- Parameters:
motor- Motor to create the encoder from.conversionFactor- The conversion factor to set if the output is not from 0 to 360.
-
-
Method Details
-
factoryDefault
public void factoryDefault()Reset the encoder to factory defaults.- Specified by:
factoryDefaultin classSwerveAbsoluteEncoder
-
clearStickyFaults
public void clearStickyFaults()Clear sticky faults on the encoder.- Specified by:
clearStickyFaultsin classSwerveAbsoluteEncoder
-
configure
public void configure(boolean inverted) Configure the absolute encoder to read from [0, 360) per second.- Specified by:
configurein classSwerveAbsoluteEncoder- Parameters:
inverted- Whether the encoder is inverted.
-
getAbsolutePosition
public double getAbsolutePosition()Get the absolute position of the encoder.- Specified by:
getAbsolutePositionin classSwerveAbsoluteEncoder- Returns:
- Absolute position in degrees from [0, 360).
-
getAbsoluteEncoder
Get the instantiated absolute encoder Object.- Specified by:
getAbsoluteEncoderin classSwerveAbsoluteEncoder- Returns:
- Absolute encoder object.
-