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

Add IdleCommand to wpilibJ2 command framework #5555

Merged
merged 10 commits into from
Aug 29, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ public static Command none() {
return new InstantCommand();
}

/**
* Constructs a command that does nothing until interrupted.
*
* @param requirements subsystems the action requires
* @return the command
*/
public static Command idle(Subsystem... requirements) {
return new RunCommand(() -> {}, requirements);
TapChap marked this conversation as resolved.
Show resolved Hide resolved
}

// Action Commands

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ CommandPtr cmd::None() {
return InstantCommand().ToPtr();
}

CommandPtr cmd::Idle(std::initializer_list<Subsystem*> requirements) {
return RunCommand([] {}, requirements).ToPtr();
}

CommandPtr cmd::RunOnce(std::function<void()> action,
std::initializer_list<Subsystem*> requirements) {
return InstantCommand(std::move(action), requirements).ToPtr();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ namespace cmd {
[[nodiscard]]
CommandPtr None();

/**
* Constructs a command that does nothing until interrupted.
*
* @param requirements subsystems the action requires
* @return the command
*/
CommandPtr Idle(std::span<Subsystem* const> requirements = {});

// Action Commands

/**
Expand Down