mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-19 06:21:40 +00:00
Updated to 2024.4.8.3
This commit is contained in:
@@ -53,6 +53,26 @@ public class SwerveModule
|
||||
* An {@link Alert} for if there is no Absolute Encoder on the module.
|
||||
*/
|
||||
private final Alert noEncoderWarning;
|
||||
/**
|
||||
* NT3 Raw Absolute Angle publisher for the absolute encoder.
|
||||
*/
|
||||
private final String rawAbsoluteAngleName;
|
||||
/**
|
||||
* NT3 Adjusted Absolute angle publisher for the absolute encoder.
|
||||
*/
|
||||
private final String adjAbsoluteAngleName;
|
||||
/**
|
||||
* NT3 Absolute encoder read issue.
|
||||
*/
|
||||
private final String absoluteEncoderIssueName;
|
||||
/**
|
||||
* NT3 raw angle motor.
|
||||
*/
|
||||
private final String rawAngleName;
|
||||
/**
|
||||
* NT3 Raw drive motor.
|
||||
*/
|
||||
private final String rawDriveName;
|
||||
/**
|
||||
* Module number for kinematics, usually 0 to 3. front left -> front right -> back left -> back right.
|
||||
*/
|
||||
@@ -176,6 +196,12 @@ public class SwerveModule
|
||||
"Pushing the Absolute Encoder offset to the encoder failed on module #" +
|
||||
moduleNumber,
|
||||
Alert.AlertType.WARNING);
|
||||
|
||||
rawAbsoluteAngleName = "Module[" + configuration.name + "] Raw Absolute Encoder";
|
||||
adjAbsoluteAngleName = "Module[" + configuration.name + "] Adjusted Absolute Encoder";
|
||||
absoluteEncoderIssueName = "Module[" + configuration.name + "] Absolute Encoder Read Issue";
|
||||
rawAngleName = "Module[" + configuration.name + "] Raw Angle Encoder";
|
||||
rawDriveName = "Module[" + configuration.name + "] Raw Drive Encoder";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,7 +319,8 @@ public class SwerveModule
|
||||
/* If error is close to 0 rotations, we're already there, so apply full power */
|
||||
/* If the error is close to 0.25 rotations, then we're 90 degrees, so movement doesn't help us at all */
|
||||
cosineScalar = Rotation2d.fromDegrees(desiredState.angle.getDegrees())
|
||||
.minus(Rotation2d.fromDegrees(getAbsolutePosition())).getCos(); // TODO: Investigate angle modulus by 180.
|
||||
.minus(Rotation2d.fromDegrees(getAbsolutePosition()))
|
||||
.getCos(); // TODO: Investigate angle modulus by 180.
|
||||
/* Make sure we don't invert our drive, even though we shouldn't ever target over 90 degrees anyway */
|
||||
if (cosineScalar < 0.0)
|
||||
{
|
||||
@@ -526,13 +553,11 @@ public class SwerveModule
|
||||
{
|
||||
if (absoluteEncoder != null)
|
||||
{
|
||||
SmartDashboard.putNumber("Module[" + configuration.name + "] Raw Absolute Encoder",
|
||||
absoluteEncoder.getAbsolutePosition());
|
||||
SmartDashboard.putNumber(rawAbsoluteAngleName, absoluteEncoder.getAbsolutePosition());
|
||||
}
|
||||
SmartDashboard.putNumber("Module[" + configuration.name + "] Raw Angle Encoder", angleMotor.getPosition());
|
||||
SmartDashboard.putNumber("Module[" + configuration.name + "] Raw Drive Encoder", driveMotor.getPosition());
|
||||
SmartDashboard.putNumber("Module[" + configuration.name + "] Adjusted Absolute Encoder", getAbsolutePosition());
|
||||
SmartDashboard.putNumber("Module[" + configuration.name + "] Absolute Encoder Read Issue",
|
||||
getAbsoluteEncoderReadIssue() ? 1 : 0);
|
||||
SmartDashboard.putNumber(rawAngleName, angleMotor.getPosition());
|
||||
SmartDashboard.putNumber(rawDriveName, driveMotor.getPosition());
|
||||
SmartDashboard.putNumber(adjAbsoluteAngleName, getAbsolutePosition());
|
||||
SmartDashboard.putNumber(absoluteEncoderIssueName, getAbsoluteEncoderReadIssue() ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user