Files
YAGSL/swervelib/encoders/SwerveAbsoluteEncoder.java

70 lines
1.8 KiB
Java
Raw Permalink Normal View History

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..
*/
2025-02-22 06:15:56 +00:00
public abstract class SwerveAbsoluteEncoder implements AutoCloseable
2023-02-13 14:37:05 -06:00
{
2025-02-22 06:15:56 +00:00
// This is a bit weird because some encoders are closable
// while some get closed with the motor controller
// so for some encoders this will be an empty function
@Override
public abstract void close();
/**
* The maximum amount of times the swerve encoder will attempt to configure itself if failures occur.
*/
public final int maximumRetries = 5;
/**
* Last angle reading was faulty.
*/
public boolean readingError = false;
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();
/**
* Sets the Absolute Encoder offset at the Encoder Level.
*
2024-06-12 15:10:29 -05:00
* @param offset the offset the Absolute Encoder uses as the zero point in degrees.
* @return if setting Absolute Encoder Offset was successful or not.
*/
public abstract boolean setAbsoluteEncoderOffset(double offset);
/**
* Get the velocity in degrees/sec.
2024-01-17 09:17:39 -06:00
*
* @return velocity in degrees/sec.
*/
public abstract double getVelocity();
2023-02-13 14:37:05 -06:00
}