Package swervelib.encoders
Class SparkMaxEncoderSwerve
- java.lang.Object
-
- swervelib.encoders.SwerveAbsoluteEncoder
-
- swervelib.encoders.SparkMaxEncoderSwerve
-
public class SparkMaxEncoderSwerve extends SwerveAbsoluteEncoder
SparkMax absolute encoder, attached through the data port.
-
-
Field Summary
Fields Modifier and Type Field Description com.revrobotics.AbsoluteEncoderencoderTheAbsoluteEncoderrepresenting the duty cycle encoder attached to the SparkMax.
-
Constructor Summary
Constructors Constructor Description SparkMaxEncoderSwerve(SwerveMotor motor)Create theAbsoluteEncoderobject as a duty cycle.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearStickyFaults()Clear sticky faults on the encoder.voidconfigure(boolean inverted)Configure the absolute encoder to read from [0, 360) per second.voidfactoryDefault()Reset the encoder to factory defaults.ObjectgetAbsoluteEncoder()Get the instantiated absolute encoder Object.doublegetAbsolutePosition()Get the absolute position of the encoder.
-
-
-
Constructor Detail
-
SparkMaxEncoderSwerve
public SparkMaxEncoderSwerve(SwerveMotor motor)
Create theAbsoluteEncoderobject as a duty cycle. from theCANSparkMaxmotor.- Parameters:
motor- Motor to create the encoder from.
-
-
Method Detail
-
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
public Object getAbsoluteEncoder()
Get the instantiated absolute encoder Object.- Specified by:
getAbsoluteEncoderin classSwerveAbsoluteEncoder- Returns:
- Absolute encoder object.
-
-