diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj3/command/async/AsyncCommand.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj3/command/async/AsyncCommand.java index 98312182bea..de5c2b53ebe 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj3/command/async/AsyncCommand.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj3/command/async/AsyncCommand.java @@ -83,6 +83,24 @@ default int priority() { return DEFAULT_PRIORITY; } + enum InterruptBehavior { + /** + * Cancel the command when interrupted. This is the default behavior. + */ + Cancel, + + /** + * Suspend the command when interrupted, resuming when no higher-priority commands are still + * running. Useful for commands to automatically pick back up from where they left off; however, + * be careful to ensure the command should still be running when it resumes! + */ + Suspend + } + + default InterruptBehavior interruptBehavior() { + return InterruptBehavior.Cancel; + } + /** * Checks if this command has a lower {@link #priority() priority} than another command. * @@ -158,7 +176,7 @@ static AsyncCommandBuilder requiring(HardwareResource requirement, HardwareResou * @throws InterruptedException if the command was interrupted by another command while paused */ static void pause(Measure