Hi, I have been using CMD-based programming for a while now and I have come into a roadblock when it comes to setting a command to non-Interruptible in Java. I generally have my system set up in a way where all my CMDs extend the class, “CommandBase”, and then are scheduled by a trigger in the robot container bound to a Xbox controller.
I have looked in the API and have found the “setInterruptible()” method in the “Command” class, but this apparently isn’t applicable to a command established in the “CommandBase” class even though the class implements “Command”.
I want to make sure my elevator commands don’t get interrupted by another command that requires the same subsystem when triggered, so I came here for some help.
First, be careful with this. I have yet to find a good use for non-interruptible commands in several years of usage. Using one can get you stuck if the command starts behaving badly.
That said, it looks like this capability has been moved to the binding of a button to a command. For example, there is an overload of Button.whenPressed that takes a boolean for interruptibility.
You can make it so the command doesn’t require a subsystem. (Just don’t add the addRequirements line) Then it won’t get interrupted when another command is using the same subsystem. That being said, if you need two commands running on the same subsystem at the same time, you can probably split that subsystem up into two smaller subsystems.
Interruptibility is specified when the command is scheduled. The schedule method and all of the button bindings take an optional interruptible boolean.
void setInterruptible(boolean interruptible) has been removed; interruptibility is no longer an innate property of commands, and can be set when the command is scheduled.