Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmd] Add Scheduled command decorator #7083

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,28 @@ public ProxyCommand asProxy() {
return new ProxyCommand(this);
}

/**
* Decorates this command to run "forked" by wrapping it in a {@link ScheduleCommand}. Use this
* for "forking off" from command compositions when the user does not wish to extend the command's
* requirements to the entire command composition. Note that if run from a composition, the
* composition will not know about the status of the scheduled commands, and will treat this
* command as finishing instantly. Commands can be added to this and will be scheduled in order
* with this command scheduled first.
*
* @param other other commands to schedule along with this one. This command is scheduled first.
* @return the decorated command
* @see ScheduleCommand
* @see <a
* href="https://docs.wpilib.org/en/stable/docs/software/commandbased/command-compositions.html#scheduling-other-commands">WPILib
* docs</a>
*/
public ScheduleCommand fork(Command... other) {
Command[] commands = new Command[1 + other.length];
commands[0] = this;
System.arraycopy(other, 0, commands, 1, other.length);
return new ScheduleCommand(commands);
}

/**
* Decorates this command to only run if this condition is not met. If the command is already
* running and the condition changes to true, the command will not stop running. The requirements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "frc2/command/ParallelRaceGroup.h"
#include "frc2/command/ProxyCommand.h"
#include "frc2/command/RepeatCommand.h"
#include "frc2/command/ScheduleCommand.h"
#include "frc2/command/SequentialCommandGroup.h"
#include "frc2/command/WaitCommand.h"
#include "frc2/command/WaitUntilCommand.h"
Expand Down
Loading