Fault Resilience
Fault Resilience
High-fidelity health monitoring and driver alerting systems.
On Einstein or at the Championship level, a single wire coming loose can lose a match. MARSLib features a military-grade Two-Layer Fault System designed to detect failures, protect the hardware, and immediately notify the driver before the match is compromised.
1. The Two-Layer Architecture
Fault monitoring is split into two distinct responsibilities to ensure zero-latency detection:
2. The Alert System
Instead of relying on easy-to-miss System.out.println statements or generic SmartDashboard booleans, MARSLib uses the Alert class to trigger specific warnings that light up uniquely defined UI widgets.
// Persistent alert declared in a Subsystemprivate final Alert m_stallAlert = new Alert("Arm Motor Stalled!", AlertType.ERROR);
@Overridepublic void periodic() { // Logic to detect a stall using IO inputs boolean isStalled = inputs.currentAmps > 40.0 && Math.abs(inputs.velocityRadPerSec) < 0.1; m_stallAlert.set(isStalled);}3. Transparent Structural Fallbacks
Alerting the driver is step 1. But what if the robot needs to keep moving? Because MARSLib strictly defines the IO Layer using a unified Struct data model, we achieve a massive structural advantage: Resiliency.
If a CAN bus wire snaps in the middle of a match—or a Kraken motor spontaneously reboots—the IO layer can catch the CANStatus exception and seamlessly redirect the Inputs struct to read from the internal Physics engine fallback. The Subsystem logic never even knows the hardware failed! It continues calculating the target state organically using mathematical models while broadcasting the fault alert concurrently.
Try clicking SEVER CAN WIRE below to see the math fallback gracefully handle the outage without zeroing out the reported velocity! Notice that the software continues simulating the mechanism’s positional state even when the actual hardware is coasting to a stop.
4. Pre-Match Diagnostics
MARSLib includes MARSDiagnostics, which standardizes running “Sweep Tests” of all registered mechanisms in the pits. It stresses the arm, drives the chassis 10cm, and spins the intake at 10% power to verify that no cables were loosened during transport.
📖 Further Reading & External Resources
- WPILib: RoboRIO Brownout Protection - Understanding how hardware handles low voltage.
- CTRE: Phoenix 6 Actuator Limits - Implementing hardware-level current and voltage clamping.