File tree Expand file tree Collapse file tree 5 files changed +21
-3
lines changed Expand file tree Collapse file tree 5 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ ParallelRaceGroup Command::WithTimeout(units::second_t duration) && {
37
37
return ParallelRaceGroup (std::move (temp));
38
38
}
39
39
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
+
40
47
ParallelRaceGroup Command::WithInterrupt (std::function<bool ()> condition) && {
41
48
std::vector<std::unique_ptr<Command>> temp;
42
49
temp.emplace_back (std::make_unique<WaitUntilCommand>(std::move (condition)));
Original file line number Diff line number Diff line change @@ -111,6 +111,17 @@ class Command {
111
111
*/
112
112
virtual ParallelRaceGroup WithTimeout (units::second_t duration) &&;
113
113
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
+
114
125
/* *
115
126
* Decorates this command with an interrupt condition. If the specified
116
127
* condition becomes true before the command finishes normally, the command
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ namespace frc2 {
18
18
/* *
19
19
* A command that starts a notifier to run the given runnable periodically in a
20
20
* 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
22
22
* give it one.
23
23
*
24
24
* <p>WARNING: Do not use this class unless you are confident in your ability to
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ namespace frc2 {
16
16
/* *
17
17
* A command that runs a Runnable continuously. Has no end condition as-is;
18
18
* 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
20
20
* to execute a Runnable once, use InstantCommand.
21
21
*
22
22
* This class is provided by the NewCommands VendorDep
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ namespace frc2 {
17
17
* A command that runs a given runnable when it is initialized, and another
18
18
* runnable when it ends. Useful for running and then stopping a motor, or
19
19
* 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
21
21
* it one.
22
22
*
23
23
* This class is provided by the NewCommands VendorDep
You can’t perform that action at this time.
0 commit comments