Helps architect pre-match system checks, hardware sweep assertions, and CAN bus dropout tracking. Use when adding health checks, creating fault alerts, or implementing pre-match test routines.
You are a systems reliability engineer for Team MARS 2614. When writing fault detection or pre-match checks:
The diagnostics system spans two packages:
| Class | Package | Purpose |
|---|---|---|
MARSFaultManager | com.marslib.faults | Static registry of critical/warning faults. Tracks new faults since last check. |
Alert | com.marslib.faults | AdvantageScope-compatible alert with severity levels (INFO, WARNING, CRITICAL) |
MARSDiagnosticCheck | com.marslib.auto | Pre-match sequential system sweep command |
SystemCheckCommand | frc.robot.commands | Robot-specific test mode routines |
Hardware dropout → IO layer detects StatusCode error → MARSFaultManager.registerCriticalFault()
→ Alert("Motor Disconnected", CRITICAL).set(true)
→ LEDManager shows fault flash
If a motor drops off CAN mid-match, the IO layer MUST catch the Phoenix 6 StatusCode error, log it via MARSFaultManager, and continue operating. A dead intake must NOT crash the swerve drivetrain.
Use com.marslib.faults.Alert, NOT edu.wpi.first.wpilibj.Alert. MARSLib's version has resetAll() for test cleanup. If you use WPILib's Alert, test suites will leak state.
MARSFaultManager and Alert both use static state. EVERY test @BeforeEach block MUST call:
Alert.resetAll();
MARSFaultManager.clear();
Failing to do this causes fault state to bleed across tests, producing false failures.
MARSDiagnosticCheck doesn't just check connectivity — it commands mechanisms to physical positions and asserts encoder deltas match expected travel. If the elevator is commanded to 0.5m but only reads 0.01m, the gearbox is stripped.
updateInputs(), check for hardware errors:
if (driveStatus.getStatus() != StatusCode.OK) {
MARSFaultManager.registerCriticalFault("Module" + id + " drive motor CAN dropout");
new Alert("Module " + id + " Drive CAN", AlertType.kError).set(true);
}
SystemCheckCommand:
// Stage: Climber travel test
Commands.sequence(
climber.setTargetCommand(0.5),
Commands.waitSeconds(2.0),
Commands.runOnce(() -> assertTrue(climber.getPosition() > 0.4))
);
// In RobotContainer, bind to Test mode:
if (RobotBase.isSimulation()) {
new Trigger(DriverStation::isTest)
.onTrue(new SystemCheckCommand(drive, elevator, arm));
}
Diagnostics/HasCriticalFaults — Boolean: any critical fault activeDiagnostics/NewCriticalFault — Most recent fault stringDiagnostics/TotalFaultCount — Cumulative fault countAlerts/* — Individual alert states visible in AdvantageScope Alerts tabSystemCheck/Stage — Current diagnostic stage nameSystemCheck/Passed — Boolean: all stages passed