Display Errors with Reading the Absolute Encoders

Display Errors with Reading the Absolute Encoder
This commit is contained in:
Technologyman00
2023-11-20 20:34:28 -06:00
parent 761c6e2ee2
commit a6b43076f0
2 changed files with 20 additions and 0 deletions

View File

@@ -65,6 +65,11 @@ public class SwerveModule
*/
private boolean synchronizeEncoderQueued = false;
/**
* Absolute Encoder Read Issue Dectected.
*/
public boolean absoluteEncoderReadIssue = false;
/**
* Construct the swerve module and initialize the swerve module motors and absolute encoder.
*
@@ -298,13 +303,16 @@ public class SwerveModule
double angle;
if (absoluteEncoder != null)
{
absoluteEncoderReadIssue = false;
angle = absoluteEncoder.getAbsolutePosition() - angleOffset;
if (absoluteEncoder.readingError)
{
absoluteEncoderReadIssue = true;
angle = getRelativePosition();
}
} else
{
absoluteEncoderReadIssue = true;
angle = getRelativePosition();
}
angle %= 360;
@@ -387,4 +395,14 @@ public class SwerveModule
{
return configuration;
}
/*
* Get if the last Absolute Encoder had a read issue.
*
* @return If the last Absolute Encoder had a read issue.
*/
public boolean getAbsoluteEncoderReadIssue()
{
return absoluteEncoderReadIssue;
}
}