Skip to content

Commit

Permalink
some review stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
spacey-sooty committed Feb 25, 2024
1 parent 95379d0 commit c34fb76
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

package edu.wpi.first.wpilibj2.command;

import static edu.wpi.first.units.Units.Second;
import static edu.wpi.first.util.ErrorMessages.requireNonNullParam;

import edu.wpi.first.units.Measure;
import edu.wpi.first.units.Time;
import edu.wpi.first.util.function.BooleanConsumer;
import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.util.sendable.SendableBuilder;
Expand Down Expand Up @@ -149,6 +152,23 @@ public ParallelRaceGroup withTimeout(double seconds) {
return raceWith(new WaitCommand(seconds));
}

/**
* Decorates this command with a timeout. If the specified timeout is exceeded before the command
* finishes normally, the command will be interrupted and un-scheduled.
*
* <p>Note: This decorator works by adding this command to a composition. The command the
* decorator was called on cannot be scheduled independently or be added to a different
* composition (namely, decorators), unless it is manually cleared from the list of composed
* commands with {@link CommandScheduler#removeComposedCommand(Command)}. The command composition
* returned from this method can be further decorated without issue.
*
* @param time the timeout duration
* @return the command with the timeout added
*/
public ParallelRaceGroup withTimeout(Measure<Time> time) {
return raceWith(new WaitCommand(time.in(Second)));
}

/**
* Decorates this command with an interrupt condition. If the specified condition becomes true
* before the command finishes normally, the command will be interrupted and un-scheduled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static Command waitSeconds(double seconds) {
* @return the command
* @see WaitCommand
*/
public static Command waitTime(Measure<Time> time) {
public static Command wait(Measure<Time> time) {
return new WaitCommand(time.in(Second));
}

Expand Down

0 comments on commit c34fb76

Please sign in to comment.