[commands] Move GroupedCommands to CommandScheduler (#4728)

Move the command group checking functionality from CommandGroupBase into CommandScheduler.
Update references to grouping as composition for clarity (because explicitly grouping isn't the only way to do it).
Deprecate the static factory methods parallel, race, and deadline in CommandGroupBase in favor of the identical ones in Commands.
This commit is contained in:
Starlight220
2022-12-07 07:13:31 +02:00
committed by GitHub
parent f18fd41ac3
commit 4bbdbdfb48
46 changed files with 450 additions and 472 deletions

View File

@@ -18,12 +18,14 @@
namespace frc2 {
/**
* A CommandGroup that runs a set of commands in parallel, ending only when a
* specific command (the "deadline") ends, interrupting all other commands that
* are still running at that point.
* A command composition that runs a set of commands in parallel, ending only
* when a specific command (the "deadline") ends, interrupting all other
* commands that are still running at that point.
*
* <p>As a rule, CommandGroups require the union of the requirements of their
* component commands.
* <p>The rules for command compositions apply: command instances that are
* passed to it are owned by the composition and cannot be added to any other
* composition or scheduled individually, and the composition requires all
* subsystems its components require.
*
* This class is provided by the NewCommands VendorDep
*/
@@ -31,25 +33,25 @@ class ParallelDeadlineGroup
: public CommandHelper<CommandGroupBase, ParallelDeadlineGroup> {
public:
/**
* Creates a new ParallelDeadlineGroup. The given commands (including the
* deadline) will be executed simultaneously. The CommandGroup will finish
* when the deadline finishes, interrupting all other still-running commands.
* If the CommandGroup is interrupted, only the commands still running will be
* Creates a new ParallelDeadlineGroup. The given commands (including the
* deadline) will be executed simultaneously. The composition will finish when
* the deadline finishes, interrupting all other still-running commands. If
* the composition is interrupted, only the commands still running will be
* interrupted.
*
* @param deadline the command that determines when the group ends
* @param deadline the command that determines when the composition ends
* @param commands the commands to be executed
*/
ParallelDeadlineGroup(std::unique_ptr<Command>&& deadline,
std::vector<std::unique_ptr<Command>>&& commands);
/**
* Creates a new ParallelDeadlineGroup. The given commands (including the
* deadline) will be executed simultaneously. The CommandGroup will finish
* when the deadline finishes, interrupting all other still-running commands.
* If the CommandGroup is interrupted, only the commands still running will be
* Creates a new ParallelDeadlineGroup. The given commands (including the
* deadline) will be executed simultaneously. The composition will finish when
* the deadline finishes, interrupting all other still-running commands. If
* the composition is interrupted, only the commands still running will be
* interrupted.
*
* @param deadline the command that determines when the group ends
* @param deadline the command that determines when the composition ends
* @param commands the commands to be executed
*/
template <class T, class... Types,