From 06d4a69d921b8c3e70df4be5e81c208a329b518d Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Sun, 5 Feb 2023 16:52:37 -0600 Subject: [PATCH 1/7] Add Subsystem#removeDefaultCommand (java) --- .../java/edu/wpi/first/wpilibj2/command/Subsystem.java | 9 +++++++++ 1 file changed, 9 insertions(+) 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 0584ced2b27..142839f24c3 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,15 @@ default void setDefaultCommand(Command defaultCommand) { CommandScheduler.getInstance().setDefaultCommand(this, defaultCommand); } + /** + * Removes the default command for the subsystem. The current default command will run until + * another command is scheduled that requires the subsystem, at which point the current default + * command will not be re-scheduled. + */ + 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. From 2d94f2c61e283fb1f7520b67498387f8cc7aaa8b Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Sun, 5 Feb 2023 16:56:54 -0600 Subject: [PATCH 2/7] Add Subsystem#RemoveDefaultCommand (include) --- .../src/main/native/include/frc2/command/Subsystem.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h b/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h index 0c3a2a3282c..fc9adb57698 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h @@ -82,6 +82,13 @@ class Subsystem { * @param defaultCommand the default command to associate with this subsystem */ void SetDefaultCommand(CommandPtr&& defaultCommand); + + /** + * Removes the default command for the subsystem. The current default command + * will run until another command is scheduled that requires the subsystem, at + * which point the current default command will not be re-scheduled. + */ + void RemoveDefaultCommand(); /** * Gets the default command for this subsystem. Returns null if no default From 3eed532eaf6d81e707b61d85ac3ce9d2ce7f9663 Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Sun, 5 Feb 2023 16:58:28 -0600 Subject: [PATCH 3/7] Add Subsystem#RemoveDefaultCommand (cpp) --- .../src/main/native/cpp/frc2/command/Subsystem.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/Subsystem.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/Subsystem.cpp index 3c388bbadf7..d1d50e1de0b 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); } From f37801b75019d44341785d4fca401b53c21276bc Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Sun, 5 Feb 2023 17:10:50 -0600 Subject: [PATCH 4/7] Remove space --- .../src/main/native/include/frc2/command/Subsystem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h b/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h index fc9adb57698..b6db77ea932 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h @@ -82,7 +82,7 @@ class Subsystem { * @param defaultCommand the default command to associate with this subsystem */ void SetDefaultCommand(CommandPtr&& defaultCommand); - + /** * Removes the default command for the subsystem. The current default command * will run until another command is scheduled that requires the subsystem, at From cea73f58a4c4b1b04c47663f81897702b4876680 Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Sun, 19 Feb 2023 18:00:20 -0600 Subject: [PATCH 5/7] update comment --- .../main/java/edu/wpi/first/wpilibj2/command/Subsystem.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 142839f24c3..df6f0160457 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 @@ -51,9 +51,8 @@ default void setDefaultCommand(Command defaultCommand) { } /** - * Removes the default command for the subsystem. The current default command will run until - * another command is scheduled that requires the subsystem, at which point the current default - * command will not be re-scheduled. + * 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); From bbc1642f4586cc1af2974b87c2b45986cbaf4552 Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Sun, 19 Feb 2023 18:01:25 -0600 Subject: [PATCH 6/7] update comment --- .../src/main/native/include/frc2/command/Subsystem.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h b/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h index b6db77ea932..2c8f093053c 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Subsystem.h @@ -84,9 +84,8 @@ class Subsystem { void SetDefaultCommand(CommandPtr&& defaultCommand); /** - * Removes the default command for the subsystem. The current default command - * will run until another command is scheduled that requires the subsystem, at - * which point the current default command will not be re-scheduled. + * Removes the default command for the subsystem. This will not cancel the + * default command if it is currently running. */ void RemoveDefaultCommand(); From 6b0610ac944dad46e53ccf3251799c92bbf32d4f Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Sun, 19 Feb 2023 19:13:13 -0600 Subject: [PATCH 7/7] move line break --- .../main/java/edu/wpi/first/wpilibj2/command/Subsystem.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 df6f0160457..be7a2a7215a 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 @@ -51,8 +51,8 @@ default void setDefaultCommand(Command defaultCommand) { } /** - * Removes the default command for the subsystem. This will not cancel the default command if - * it is currently running. + * 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);