mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-24 06:51:39 +00:00
Update to 2024.4.8
This commit is contained in:
@@ -17,26 +17,30 @@ import swervelib.telemetry.Alert;
|
||||
public class CANCoderSwerve extends SwerveAbsoluteEncoder
|
||||
{
|
||||
|
||||
/**
|
||||
* Wait time for status frames to show up.
|
||||
*/
|
||||
private final double STATUS_TIMEOUT_SECONDS = 0.02;
|
||||
/**
|
||||
* CANCoder with WPILib sendable and support.
|
||||
*/
|
||||
public CANcoder encoder;
|
||||
public CANcoder encoder;
|
||||
/**
|
||||
* An {@link Alert} for if the CANCoder magnet field is less than ideal.
|
||||
*/
|
||||
private Alert magnetFieldLessThanIdeal;
|
||||
private Alert magnetFieldLessThanIdeal;
|
||||
/**
|
||||
* An {@link Alert} for if the CANCoder reading is faulty.
|
||||
*/
|
||||
private Alert readingFaulty;
|
||||
private Alert readingFaulty;
|
||||
/**
|
||||
* An {@link Alert} for if the CANCoder reading is faulty and the reading is ignored.
|
||||
*/
|
||||
private Alert readingIgnored;
|
||||
private Alert readingIgnored;
|
||||
/**
|
||||
* An {@link Alert} for if the absolute encoder offset cannot be set.
|
||||
*/
|
||||
private Alert cannotSetOffset;
|
||||
private Alert cannotSetOffset;
|
||||
|
||||
/**
|
||||
* Initialize the CANCoder on the standard CANBus.
|
||||
@@ -45,7 +49,8 @@ public class CANCoderSwerve extends SwerveAbsoluteEncoder
|
||||
*/
|
||||
public CANCoderSwerve(int id)
|
||||
{
|
||||
encoder = new CANcoder(id);
|
||||
// Empty string uses the default canbus for the system
|
||||
this(id, "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +139,7 @@ public class CANCoderSwerve extends SwerveAbsoluteEncoder
|
||||
readingFaulty.set(false);
|
||||
}
|
||||
|
||||
StatusSignal<Double> angle = encoder.getAbsolutePosition().refresh();
|
||||
StatusSignal<Double> angle = encoder.getAbsolutePosition();
|
||||
|
||||
// Taken from democat's library.
|
||||
// Source: https://github.com/democat3457/swerve-lib/blob/7c03126b8c22f23a501b2c2742f9d173a5bcbc40/src/main/java/com/swervedrivespecialties/swervelib/ctre/CanCoderFactoryBuilder.java#L51-L74
|
||||
@@ -144,7 +149,7 @@ public class CANCoderSwerve extends SwerveAbsoluteEncoder
|
||||
{
|
||||
break;
|
||||
}
|
||||
angle = angle.waitForUpdate(0.01);
|
||||
angle = angle.waitForUpdate(STATUS_TIMEOUT_SECONDS);
|
||||
}
|
||||
if (angle.getStatus() != StatusCode.OK)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user