diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Subsystem.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Subsystem.java index c0e694774c3..4a0c0561491 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Subsystem.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Subsystem.java @@ -98,6 +98,15 @@ default void register() { CommandScheduler.getInstance().registerSubsystem(this); } + /** + * Constructs a command that does nothing until interrupted. Requires this subsystem. + * + * @return the command + */ + default Command idle() { + return Commands.idle(this); + } + /** * Constructs a command that runs an action once and finishes. Requires this subsystem. * diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/Subsystem.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/Subsystem.cpp index 876269a1b47..8282682b918 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/Subsystem.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/Subsystem.cpp @@ -46,6 +46,10 @@ void Subsystem::Register() { return CommandScheduler::GetInstance().RegisterSubsystem(this); } +CommandPtr Subsystem::Idle() { + return cmd::Idle({this}); +} + CommandPtr Subsystem::RunOnce(std::function action) { return cmd::RunOnce(std::move(action), {this}); } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h b/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h index d62f69ca356..ab6c9321562 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h @@ -121,6 +121,15 @@ class Subsystem { */ void Register(); + /** + * Constructs a command that does nothing until interrupted. Requires this + * subsystem. + * + * @return the command + */ + [[nodiscard]] + CommandPtr Idle(); + /** * Constructs a command that runs an action once and finishes. Requires this * subsystem.