diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java index c3fbfea8389..0130905fb4d 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java @@ -25,6 +25,15 @@ public static Command none() { return new InstantCommand(); } + /** + * Constructs a command that does nothing until interrupted. + * + * @return the command + */ + public static Command idle() { + return run(() -> {}); + } + // Action Commands /** diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/Commands.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/Commands.cpp index 1932e45f677..f3c47765322 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/Commands.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/Commands.cpp @@ -24,6 +24,10 @@ CommandPtr cmd::None() { return InstantCommand().ToPtr(); } +CommandPtr cmd::Idle() { + return Run([] {}); +} + CommandPtr cmd::RunOnce(std::function action, std::initializer_list requirements) { return InstantCommand(std::move(action), requirements).ToPtr(); diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Commands.h b/wpilibNewCommands/src/main/native/include/frc2/command/Commands.h index 92cc54eb04b..f31bab98e05 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Commands.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Commands.h @@ -31,6 +31,14 @@ namespace cmd { [[nodiscard]] CommandPtr None(); +/** + * Constructs a command that does nothing until interrupted. + * + * @return the command + */ +[[nodiscard]] +CommandPtr Idle(); + // Action Commands /**