Package swervelib.encoders
Class DIODutyCycleEncoderSwerve
java.lang.Object
swervelib.encoders.SwerveAbsoluteEncoder
swervelib.encoders.DIODutyCycleEncoderSwerve
- All Implemented Interfaces:
AutoCloseable
DutyCycle encoders such as "US Digital MA3 with DIO Output, the CTRE Mag Encoder, the Rev Hex
Encoder, and the AM Mag Encoder." attached via a DIO lane.
Credits to p2reneker25 for building this.
-
Field Summary
Fields inherited from class swervelib.encoders.SwerveAbsoluteEncoder
maximumRetries, readingError -
Constructor Summary
ConstructorsConstructorDescriptionDIODutyCycleEncoderSwerve(int pin) Constructor for the DIO duty cycle encoder. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear sticky faults on the encoder.voidclose()voidconfigure(boolean inverted) Configure the inversion state of the encoder.voidReset the encoder to factory defaults.Get the 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
-
DIODutyCycleEncoderSwerve
public DIODutyCycleEncoderSwerve(int pin) Constructor for the DIO duty cycle encoder.- Parameters:
pin- DIO lane for the encoder.
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classSwerveAbsoluteEncoder
-
configure
public void configure(boolean inverted) Configure the inversion state of the encoder.- 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 encoder object.- Specified by:
getAbsoluteEncoderin classSwerveAbsoluteEncoder- Returns:
DutyCycleEncoderfrom the class.
-
getVelocity
public double getVelocity()Get the velocity in degrees/sec.- Specified by:
getVelocityin classSwerveAbsoluteEncoder- Returns:
- velocity in degrees/sec.
-
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
-
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.
-