2023-02-13 17:21:24 -06:00
|
|
|
package swervelib.encoders;
|
2023-02-13 14:37:05 -06:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Swerve abstraction class to define a standard interface with absolute encoders for swerve modules..
|
|
|
|
|
*/
|
|
|
|
|
public abstract class SwerveAbsoluteEncoder
|
|
|
|
|
{
|
|
|
|
|
|
2023-08-29 21:56:52 -05:00
|
|
|
/**
|
|
|
|
|
* The maximum amount of times the swerve encoder will attempt to configure itself if failures occur.
|
|
|
|
|
*/
|
|
|
|
|
public final int maximumRetries = 5;
|
2023-02-20 20:59:31 -06:00
|
|
|
/**
|
|
|
|
|
* Last angle reading was faulty.
|
|
|
|
|
*/
|
2023-08-29 21:56:52 -05:00
|
|
|
public boolean readingError = false;
|
2023-02-20 20:59:31 -06:00
|
|
|
|
2023-02-13 14:37:05 -06:00
|
|
|
/**
|
|
|
|
|
* Reset the encoder to factory defaults.
|
|
|
|
|
*/
|
|
|
|
|
public abstract void factoryDefault();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clear sticky faults on the encoder.
|
|
|
|
|
*/
|
|
|
|
|
public abstract void clearStickyFaults();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configure the absolute encoder to read from [0, 360) per second.
|
|
|
|
|
*
|
|
|
|
|
* @param inverted Whether the encoder is inverted.
|
|
|
|
|
*/
|
|
|
|
|
public abstract void configure(boolean inverted);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the absolute position of the encoder.
|
|
|
|
|
*
|
|
|
|
|
* @return Absolute position in degrees from [0, 360).
|
|
|
|
|
*/
|
|
|
|
|
public abstract double getAbsolutePosition();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the instantiated absolute encoder Object.
|
|
|
|
|
*
|
|
|
|
|
* @return Absolute encoder object.
|
|
|
|
|
*/
|
|
|
|
|
public abstract Object getAbsoluteEncoder();
|
2023-12-05 16:25:42 -06:00
|
|
|
|
2023-12-12 10:48:54 -06:00
|
|
|
/**
|
|
|
|
|
* Sets the Absolute Encoder offset at the Encoder Level.
|
|
|
|
|
*
|
|
|
|
|
* @param offset the offset the Absolute Encoder uses as the zero point.
|
|
|
|
|
* @return if setting Absolute Encoder Offset was successful or not.
|
|
|
|
|
*/
|
|
|
|
|
public abstract boolean setAbsoluteEncoderOffset(double offset);
|
|
|
|
|
|
2023-12-05 16:25:42 -06:00
|
|
|
/**
|
|
|
|
|
* Get the velocity in degrees/sec.
|
2024-01-17 09:17:39 -06:00
|
|
|
*
|
2023-12-05 16:25:42 -06:00
|
|
|
* @return velocity in degrees/sec.
|
|
|
|
|
*/
|
|
|
|
|
public abstract double getVelocity();
|
2023-02-13 14:37:05 -06:00
|
|
|
}
|