Package swervelib.encoders
Class TalonSRXEncoderSwerve
java.lang.Object
swervelib.encoders.SwerveAbsoluteEncoder
swervelib.encoders.TalonSRXEncoderSwerve
- All Implemented Interfaces:
AutoCloseable
Talon SRX attached absolute encoder.
-
Field Summary
Fields inherited from class swervelib.encoders.SwerveAbsoluteEncoder
maximumRetries, readingError -
Constructor Summary
ConstructorsConstructorDescriptionTalonSRXEncoderSwerve(SwerveMotor motor, FeedbackDevice feedbackDevice) Creates aTalonSRXEncoderSwerve. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear sticky faults on the encoder.voidclose()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.doubleGet the velocity in degrees/sec.booleansetAbsoluteEncoderOffset(double offset) Sets the Absolute Encoder offset at the Encoder Level.
-
Constructor Details
-
TalonSRXEncoderSwerve
Creates aTalonSRXEncoderSwerve.- Parameters:
motor- motor to poll the sensor from.feedbackDevice- the feedback device the sensor uses e.g. PWM or Analog.
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classSwerveAbsoluteEncoder
-
factoryDefault
public void factoryDefault()Description copied from class:SwerveAbsoluteEncoderReset the encoder to factory defaults.- Specified by:
factoryDefaultin classSwerveAbsoluteEncoder
-
clearStickyFaults
public void clearStickyFaults()Description copied from class:SwerveAbsoluteEncoderClear sticky faults on the encoder.- Specified by:
clearStickyFaultsin classSwerveAbsoluteEncoder
-
configure
public void configure(boolean inverted) Description copied from class:SwerveAbsoluteEncoderConfigure 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()Description copied from class:SwerveAbsoluteEncoderGet the absolute position of the encoder.- Specified by:
getAbsolutePositionin classSwerveAbsoluteEncoder- Returns:
- Absolute position in degrees from [0, 360).
-
getAbsoluteEncoder
Description copied from class:SwerveAbsoluteEncoderGet the instantiated absolute encoder Object.- Specified by:
getAbsoluteEncoderin classSwerveAbsoluteEncoder- Returns:
- Absolute encoder object.
-
setAbsoluteEncoderOffset
public boolean setAbsoluteEncoderOffset(double offset) Description copied from class:SwerveAbsoluteEncoderSets the Absolute Encoder offset at the Encoder Level.- Specified by:
setAbsoluteEncoderOffsetin classSwerveAbsoluteEncoder- Parameters:
offset- the offset the Absolute Encoder uses as the zero point in degrees.- Returns:
- if setting Absolute Encoder Offset was successful or not.
-
getVelocity
public double getVelocity()Description copied from class:SwerveAbsoluteEncoderGet the velocity in degrees/sec.- Specified by:
getVelocityin classSwerveAbsoluteEncoder- Returns:
- velocity in degrees/sec.
-