Package swervelib.encoders
Class AnalogAbsoluteEncoderSwerve
java.lang.Object
swervelib.encoders.SwerveAbsoluteEncoder
swervelib.encoders.AnalogAbsoluteEncoderSwerve
Swerve Absolute Encoder for Thrifty Encoders and other analog encoders.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AlertAnAlertfor if the absolute encoder offset cannot be set.edu.wpi.first.wpilibj.AnalogInputEncoder as Analog Input.private AlertAnAlertdetailing how the analog absolute encoder may not report accurate velocities.private booleanInversion state of the encoder.Fields inherited from class swervelib.encoders.SwerveAbsoluteEncoder
maximumRetries, readingError -
Constructor Summary
ConstructorsConstructorDescriptionAnalogAbsoluteEncoderSwerve(int channel) Construct the Encoder given the analog input channel.AnalogAbsoluteEncoderSwerve(edu.wpi.first.wpilibj.AnalogInput encoder) Construct the Thrifty Encoder as a Swerve Absolute Encoder. -
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.doubleGet the velocity in degrees/sec.booleansetAbsoluteEncoderOffset(double offset) Cannot Set the offset of an Analog Absolute Encoder.
-
Field Details
-
encoder
public edu.wpi.first.wpilibj.AnalogInput encoderEncoder as Analog Input. -
inverted
private boolean invertedInversion state of the encoder. -
cannotSetOffset
AnAlertfor if the absolute encoder offset cannot be set. -
inaccurateVelocities
AnAlertdetailing how the analog absolute encoder may not report accurate velocities.
-
-
Constructor Details
-
AnalogAbsoluteEncoderSwerve
public AnalogAbsoluteEncoderSwerve(edu.wpi.first.wpilibj.AnalogInput encoder) Construct the Thrifty Encoder as a Swerve Absolute Encoder.- Parameters:
encoder- Encoder to construct.
-
AnalogAbsoluteEncoderSwerve
public AnalogAbsoluteEncoderSwerve(int channel) Construct the Encoder given the analog input channel.- Parameters:
channel- Analog Input channel of which the encoder resides.
-
-
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.
-
setAbsoluteEncoderOffset
public boolean setAbsoluteEncoderOffset(double offset) Cannot Set the offset of an Analog Absolute Encoder.- Specified by:
setAbsoluteEncoderOffsetin classSwerveAbsoluteEncoder- Parameters:
offset- the offset the Absolute Encoder uses as the zero point.- Returns:
- Will always be false as setting the offset is unsupported of an Analog absolute encoder.
-
getVelocity
public double getVelocity()Get the velocity in degrees/sec.- Specified by:
getVelocityin classSwerveAbsoluteEncoder- Returns:
- velocity in degrees/sec.
-