You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
It does the same thing (create and schedule the command every time the button is pressed and finish instantly), but does the scheduling directly instead of via another command.
That said, this button is unlikely to be pressed more than once a second, so worrying about a few more allocations per button press is almost certainly a premature optimization.
Your code instincts are spot on though! This is definitely a code smell, and I 100% agree that it'd be nice to be able to specify if a command can interrupt itself. (My team ran into the same issue)
My team also ran into the same issue, implementing something similar to choosing which command to do on the same button press depending on current state and then manually scheduling it
Uh oh!
There was an error while loading. Please reload this page.
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.
Additional context
Another fun snippet:
This one allows the driver to interrupt the command that moves and homes the intake
The text was updated successfully, but these errors were encountered: