Command Timeout Helper
Disclaimer: WIP and untested on 2026 hardware; adapt abort conditions to your robot. Custom code built on WPILib APIs (not official WPILib sample).
Purpose: Prevent commands (climb/intake/auto steps) from hanging indefinitely; provide a simple timeout/abort wrapper.
Code (Java/WPILib)
public class SafeCommands {
public static Command withTimeoutOrAbort(Command cmd, double seconds, BooleanSupplier abort) {
return cmd.withTimeout(seconds).until(abort);
}
}
Usage
Command safeClimb = SafeCommands.withTimeoutOrAbort(
new ClimbCommand(climbSubsystem, endgameSupplier, ClimbCommand.Level.L2, abortBtn::get),
5.0,
() -> abortBtn.get());
Pitfalls
- Make sure abort checks inputs that actually stop the mechanism safely.
- Timeouts should be generous enough not to fight normal completion.