mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[commands] Add StartRun command factory (#6572)
This commit is contained in:
@@ -93,6 +93,19 @@ public final class Commands {
|
||||
() -> {}, run, interrupted -> end.run(), () -> false, requirements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action once, and then runs an action every iteration until
|
||||
* interrupted.
|
||||
*
|
||||
* @param start the action to run on start
|
||||
* @param run the action to run every iteration
|
||||
* @param requirements subsystems the action requires
|
||||
* @return the command
|
||||
*/
|
||||
public static Command startRun(Runnable start, Runnable run, Subsystem... requirements) {
|
||||
return new FunctionalCommand(start, run, interrupted -> {}, () -> false, requirements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a command that prints a message and finishes.
|
||||
*
|
||||
|
||||
@@ -146,6 +146,18 @@ public interface Subsystem {
|
||||
return Commands.runEnd(run, end, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a command that runs an action once and then runs another action every iteration
|
||||
* until interrupted. Requires this subsystem.
|
||||
*
|
||||
* @param start the action to run on start
|
||||
* @param run the action to run every iteration
|
||||
* @return the command
|
||||
*/
|
||||
default Command startRun(Runnable start, Runnable run) {
|
||||
return Commands.startRun(start, run, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link DeferredCommand} with the provided supplier. This subsystem is added as a
|
||||
* requirement.
|
||||
|
||||
Reference in New Issue
Block a user