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 0584ced2b2..be7a2a7215 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 @@ -50,6 +50,14 @@ public interface Subsystem { CommandScheduler.getInstance().setDefaultCommand(this, defaultCommand); } + /** + * Removes the default command for the subsystem. This will not cancel the default command if it + * is currently running. + */ + default void removeDefaultCommand() { + CommandScheduler.getInstance().removeDefaultCommand(this); + } + /** * Gets the default command for this subsystem. Returns null if no default command is currently * associated with the subsystem. diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/Subsystem.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/Subsystem.cpp index 3c388bbadf..d1d50e1de0 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/Subsystem.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/Subsystem.cpp @@ -21,6 +21,10 @@ void Subsystem::SetDefaultCommand(CommandPtr&& defaultCommand) { std::move(defaultCommand)); } +void Subsystem::RemoveDefaultCommand() { + CommandScheduler::GetInstance().RemoveDefaultCommand(this); +} + Command* Subsystem::GetDefaultCommand() const { return CommandScheduler::GetInstance().GetDefaultCommand(this); } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h b/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h index 0c3a2a3282..2c8f093053 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h @@ -83,6 +83,12 @@ class Subsystem { */ void SetDefaultCommand(CommandPtr&& defaultCommand); + /** + * Removes the default command for the subsystem. This will not cancel the + * default command if it is currently running. + */ + void RemoveDefaultCommand(); + /** * Gets the default command for this subsystem. Returns null if no default * command is currently associated with the subsystem.