From ae43b8b6dd0fe68212dea1305d41b3331bc6f31e Mon Sep 17 00:00:00 2001 From: sciencewhiz Date: Mon, 23 Feb 2026 17:11:59 -0800 Subject: [PATCH] [cmd] Fix WaitUntilCommand for match time counting down (#8632) Fixes #8631 Documents that it will return immediately if FMS isn't attached or DS isn't in practice mode. Related to change in DS match time behavior that was documented in #8606 --- .../edu/wpi/first/wpilibj2/command/WaitUntilCommand.java | 7 ++++++- .../src/main/native/cpp/frc2/command/WaitUntilCommand.cpp | 2 +- .../main/native/include/frc2/command/WaitUntilCommand.h | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/WaitUntilCommand.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/WaitUntilCommand.java index b96bc26a3a..78c4819977 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/WaitUntilCommand.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/WaitUntilCommand.java @@ -34,10 +34,15 @@ public class WaitUntilCommand extends Command { * guarantee that the time at which the action is performed will be judged to be legal by the * referees. When in doubt, add a safety factor or time the action manually. * + *

The match time counts down when connected to FMS or the DS is in practice mode for the + * current mode. When the DS is not connected to FMS or in practice mode, the command will not + * wait. + * * @param time the match time after which to end, in seconds + * @see edu.wpi.first.wpilibj.DriverStation#getMatchTime() */ public WaitUntilCommand(double time) { - this(() -> Timer.getMatchTime() - time > 0); + this(() -> Timer.getMatchTime() < time); } @Override diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/WaitUntilCommand.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/WaitUntilCommand.cpp index 9ea6fbfae9..5a24801927 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/WaitUntilCommand.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/WaitUntilCommand.cpp @@ -14,7 +14,7 @@ WaitUntilCommand::WaitUntilCommand(std::function condition) : m_condition{std::move(condition)} {} WaitUntilCommand::WaitUntilCommand(units::second_t time) - : m_condition{[=] { return frc::Timer::GetMatchTime() - time > 0_s; }} {} + : m_condition{[=] { return frc::Timer::GetMatchTime() < time; }} {} bool WaitUntilCommand::IsFinished() { return m_condition(); diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/WaitUntilCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/WaitUntilCommand.h index 377a1ba9a6..ea23885860 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/WaitUntilCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/WaitUntilCommand.h @@ -36,7 +36,12 @@ class WaitUntilCommand : public CommandHelper { * will be judged to be legal by the referees. When in doubt, add a safety * factor or time the action manually. * + * The match time counts down when connected to FMS or the DS is in practice + * mode for the current mode. When the DS is not connected to FMS or in + * practice mode, the command will not wait. + * * @param time the match time after which to end, in seconds + * @see frc::DriverStation::GetMatchTime() */ explicit WaitUntilCommand(units::second_t time);