Add sequence and parallel groups that run the default commands of idle subsystems#8293
Add sequence and parallel groups that run the default commands of idle subsystems#8293Daniel1464 wants to merge 4 commits intowpilibsuite:mainfrom
Conversation
|
This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR. |
KangarooKoala
left a comment
There was a problem hiding this comment.
Eventually this will also need tests and C++.
There was a problem hiding this comment.
Why can't this be a (private) factory method in NonBlockingCommands wrapping around Commands.parallel()?
This class violates the command method lifecycle invariants- For example, scheduling cmd.deadlineFor(new RunDefaultsCommand(requirements)) (with no other commands involving requirements running) will cause the default commands to be initialized, executed, then initialized again without a call to end() once the deadline finishes. Another example is a default command finishing normally (which is generally not advised but does happen) but other default commands still running, causing the finished default command to have execute() called at unexpected times.
Currently, standard command groups (like Commands.sequence and Commands.parallel) require all subsystems used by any of their children for the entire duration of the group's execution. This prevents the default commands of "idle" subsystems (those required by the group but not by the currently running child command) from running.
This new class provides factory methods that fix this behavior by ensuring default commands run on any subsystem that is not in use by the active command(s).
These commands are designed to bring most of the appeal of proxying(having default commands run within command groups) without the compromise of undefined cancellation behavior and requirements conflicts.