Skip to content

Commit

Permalink
Merge branch 'main' of github.com:BroncBotz3481/YAGSL
Browse files Browse the repository at this point in the history
  • Loading branch information
thenetworkgrinch committed Nov 29, 2023
2 parents c551269 + d0d986f commit 3d19a44
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SwerveDrive swerveDrive=new SwerveParser(new File(Filesystem.getDeployDirectory(
# Library Information
### Installation
- [ ] Install NavX Library
- [ ] Install Pheonix Library
- [ ] Install Phoenix Library
- [ ] Install REVLib.
- [ ] Install YAGSL (`https://broncbotz3481.github.io/YAGSL-Lib/yagsl/yagsl.json`)

Expand Down
2 changes: 2 additions & 0 deletions swervelib/SwerveDrive.java
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,8 @@ public void updateOdometry()
"Module[" + module.configuration.name + "] Relative Encoder", module.getRelativePosition());
SmartDashboard.putNumber(
"Module[" + module.configuration.name + "] Absolute Encoder", module.getAbsolutePosition());
SmartDashboard.putNumber(
"Module[" + module.configuration.name + "] Absolute Encoder Read Issue", module.getAbsoluteEncoderReadIssue());
}
if (SwerveDriveTelemetry.verbosity.ordinal() >= TelemetryVerbosity.HIGH.ordinal())
{
Expand Down
18 changes: 18 additions & 0 deletions swervelib/SwerveModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -298,13 +303,16 @@ public double getAbsolutePosition()
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;
Expand Down Expand Up @@ -387,4 +395,14 @@ public SwerveModuleConfiguration getConfiguration()
{
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;
}
}

0 comments on commit 3d19a44

Please sign in to comment.