Skip to content

Commit 1523e6e

Browse files
committed
Merge commit '65487119a64417443618623940a7856e480bbdbb' into upstream
2 parents b23a3e1 + 6548711 commit 1523e6e

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

commands2/src/cpp/frc2/command/Command.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ ParallelRaceGroup Command::WithTimeout(units::second_t duration) && {
3737
return ParallelRaceGroup(std::move(temp));
3838
}
3939

40+
ParallelRaceGroup Command::Until(std::function<bool()> condition) && {
41+
std::vector<std::unique_ptr<Command>> temp;
42+
temp.emplace_back(std::make_unique<WaitUntilCommand>(std::move(condition)));
43+
temp.emplace_back(std::move(*this).TransferOwnership());
44+
return ParallelRaceGroup(std::move(temp));
45+
}
46+
4047
ParallelRaceGroup Command::WithInterrupt(std::function<bool()> condition) && {
4148
std::vector<std::unique_ptr<Command>> temp;
4249
temp.emplace_back(std::make_unique<WaitUntilCommand>(std::move(condition)));

commands2/src/include/frc2/command/Command.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ class Command {
111111
*/
112112
virtual ParallelRaceGroup WithTimeout(units::second_t duration) &&;
113113

114+
/**
115+
* Decorates this command with an interrupt condition. If the specified
116+
* condition becomes true before the command finishes normally, the command
117+
* will be interrupted and un-scheduled. Note that this only applies to the
118+
* command returned by this method; the calling command is not itself changed.
119+
*
120+
* @param condition the interrupt condition
121+
* @return the command with the interrupt condition added
122+
*/
123+
virtual ParallelRaceGroup Until(std::function<bool()> condition) &&;
124+
114125
/**
115126
* Decorates this command with an interrupt condition. If the specified
116127
* condition becomes true before the command finishes normally, the command

commands2/src/include/frc2/command/NotifierCommand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace frc2 {
1818
/**
1919
* A command that starts a notifier to run the given runnable periodically in a
2020
* separate thread. Has no end condition as-is; either subclass it or use
21-
* Command::WithTimeout(double) or Command::WithInterrupt(BooleanSupplier) to
21+
* Command::WithTimeout(double) or Command::Until(BooleanSupplier) to
2222
* give it one.
2323
*
2424
* <p>WARNING: Do not use this class unless you are confident in your ability to

commands2/src/include/frc2/command/RunCommand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace frc2 {
1616
/**
1717
* A command that runs a Runnable continuously. Has no end condition as-is;
1818
* either subclass it or use Command.WithTimeout() or
19-
* Command.WithInterrupt() to give it one. If you only wish
19+
* Command.Until() to give it one. If you only wish
2020
* to execute a Runnable once, use InstantCommand.
2121
*
2222
* This class is provided by the NewCommands VendorDep

commands2/src/include/frc2/command/StartEndCommand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace frc2 {
1717
* A command that runs a given runnable when it is initialized, and another
1818
* runnable when it ends. Useful for running and then stopping a motor, or
1919
* extending and then retracting a solenoid. Has no end condition as-is; either
20-
* subclass it or use Command.WithTimeout() or Command.WithInterrupt() to give
20+
* subclass it or use Command.WithTimeout() or Command.Until() to give
2121
* it one.
2222
*
2323
* This class is provided by the NewCommands VendorDep

0 commit comments

Comments
 (0)