Description
Is your feature request related to a problem? Please describe.
This season my team and I decided to implement complex sequences, such as aligning and scoring and bind them to button on the driver's controller. There work great until a part of the robot gets unintentionally stuck on the reef. The driver suggested that pressing the button again would rerun the sequence, but since it never finished due to waiting for the robot to reach a position, pressing the button again simply does nothing as the command is already running.
Describe the solution you'd like
A new enum option in InterruptionBehavior or separate enum that can be set to make the CommandScheduler restart the command if it is scheduled while already active.
Describe alternatives you've considered
I've taken to using this ugly pattern to schedule a new instance of the same command logic, but it seems like code smell to me, and is not the best in terms of gc.
public Command scoreCancelSelf() {
return Commands.defer(
() -> new ScheduleCommand(score()),
Set.of());
}
Additional context
Another fun snippet:
mainController
.povLeft()
.onTrue(Commands.defer(() -> new ScheduleCommand(s.intake.toggleDeploy()), Set.of()));
This one allows the driver to interrupt the command that moves and homes the intake