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 c0e694774c..4a0c056149 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 @@ public interface Subsystem { 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 876269a1b4..8282682b91 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 ea7fbb7591..2ec07f5d88 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.