Class BLineCommands
This class mirrors the WPILib Commands methods that accept child
Commands. Each supplied child command is wrapped with
Command.asProxy() before it is added to the WPILib composition. That
keeps the returned composition from owning all child command requirements for
its whole lifetime, while still letting WPILib schedule each child command
normally when that child actually runs.
This is useful when a path contains event triggers:
import static frc.robot.lib.BLine.BLineCommands.sequence;
import edu.wpi.first.wpilibj2.command.Command;
Command auto = sequence(
shooter.shoot().withTimeout(2.0),
pathing.followPath("intakethroughdepot"),
shooter.shoot()
);
Real requirement conflicts still exist. If two scheduled commands require
the same subsystem at the same time, WPILib's CommandScheduler
resolves that conflict normally.
- See Also:
-
CommandsCommand.asProxy()
-
Method Summary
Modifier and TypeMethodDescriptionstatic edu.wpi.first.wpilibj2.command.Commanddeadline(edu.wpi.first.wpilibj2.command.Command deadline, edu.wpi.first.wpilibj2.command.Command... commands) Marker-safe counterpart toCommands.deadline(Command, Command...).static edu.wpi.first.wpilibj2.command.Commanddefer(Supplier<edu.wpi.first.wpilibj2.command.Command> supplier, Set<edu.wpi.first.wpilibj2.command.Subsystem> requirements) Marker-safe counterpart toCommands.defer(Supplier, Set).static edu.wpi.first.wpilibj2.command.CommanddeferredProxy(Supplier<edu.wpi.first.wpilibj2.command.Command> supplier) Marker-safe counterpart toCommands.deferredProxy(Supplier).static edu.wpi.first.wpilibj2.command.Commandeither(edu.wpi.first.wpilibj2.command.Command onTrue, edu.wpi.first.wpilibj2.command.Command onFalse, BooleanSupplier selector) Marker-safe counterpart toCommands.either(Command, Command, BooleanSupplier).static edu.wpi.first.wpilibj2.command.Commandparallel(edu.wpi.first.wpilibj2.command.Command... commands) Marker-safe counterpart toCommands.parallel(Command...).static edu.wpi.first.wpilibj2.command.Commandrace(edu.wpi.first.wpilibj2.command.Command... commands) Marker-safe counterpart toCommands.race(Command...).static edu.wpi.first.wpilibj2.command.CommandrepeatingSequence(edu.wpi.first.wpilibj2.command.Command... commands) Marker-safe counterpart toCommands.repeatingSequence(Command...).static <K> edu.wpi.first.wpilibj2.command.CommandMarker-safe counterpart toCommands.select(Map, Supplier).static edu.wpi.first.wpilibj2.command.Commandsequence(edu.wpi.first.wpilibj2.command.Command... commands) Marker-safe counterpart toCommands.sequence(Command...).
-
Method Details
-
either
public static edu.wpi.first.wpilibj2.command.Command either(edu.wpi.first.wpilibj2.command.Command onTrue, edu.wpi.first.wpilibj2.command.Command onFalse, BooleanSupplier selector) Marker-safe counterpart toCommands.either(Command, Command, BooleanSupplier).The supplied branch commands are wrapped with
Command.asProxy()before they are passed to WPILib. The returned conditional command does not inherit the proxied branch requirements; those requirements are claimed only when WPILib schedules the selected proxied command.- Parameters:
onTrue- the command selected whenselectorreturns trueonFalse- the command selected whenselectorreturns falseselector- selects which command branch to run- Returns:
- a marker-safe conditional command
- See Also:
-
Commands.either(Command, Command, BooleanSupplier)Command.asProxy()
-
select
public static <K> edu.wpi.first.wpilibj2.command.Command select(Map<K, edu.wpi.first.wpilibj2.command.Command> commands, Supplier<? extends K> selector) Marker-safe counterpart toCommands.select(Map, Supplier).Each command in
commandsis wrapped withCommand.asProxy()before it is passed to WPILib. The returned select command does not inherit the proxied branch requirements; those requirements are claimed only when WPILib schedules the selected proxied command.- Type Parameters:
K- selector key type- Parameters:
commands- map of selector values to commandsselector- supplies the selector value at runtime- Returns:
- a marker-safe select command
- See Also:
-
Commands.select(Map, Supplier)Command.asProxy()
-
defer
public static edu.wpi.first.wpilibj2.command.Command defer(Supplier<edu.wpi.first.wpilibj2.command.Command> supplier, Set<edu.wpi.first.wpilibj2.command.Subsystem> requirements) Marker-safe counterpart toCommands.defer(Supplier, Set).The command supplied at runtime is wrapped with
Command.asProxy()before it is run by WPILib. The explicitrequirementsargument still belongs to the returned deferred command, matching WPILib's deferred-command contract. The supplied command's own requirements are claimed only when WPILib schedules the proxied command.- Parameters:
supplier- supplies the command to proxy and run when initializedrequirements- requirements for the returned deferred command- Returns:
- a marker-safe deferred command
- See Also:
-
Commands.defer(Supplier, Set)Command.asProxy()
-
deferredProxy
public static edu.wpi.first.wpilibj2.command.Command deferredProxy(Supplier<edu.wpi.first.wpilibj2.command.Command> supplier) Marker-safe counterpart toCommands.deferredProxy(Supplier).The command supplied at runtime is wrapped with
Command.asProxy()before it is run by WPILib. The returned deferred proxy has no requirements; the supplied command's requirements are claimed only when WPILib schedules the proxied command.- Parameters:
supplier- supplies the command to proxy and run when initialized- Returns:
- a marker-safe deferred proxy command
- See Also:
-
Commands.deferredProxy(Supplier)Command.asProxy()
-
sequence
public static edu.wpi.first.wpilibj2.command.Command sequence(edu.wpi.first.wpilibj2.command.Command... commands) Marker-safe counterpart toCommands.sequence(Command...).Each supplied command is wrapped with
Command.asProxy()before it is passed to WPILib. The returned sequence does not inherit the proxied child requirements; those requirements are claimed only when WPILib schedules each proxied command.- Parameters:
commands- commands to run in sequence- Returns:
- a marker-safe sequential command group
- See Also:
-
Commands.sequence(Command...)Command.asProxy()
-
repeatingSequence
public static edu.wpi.first.wpilibj2.command.Command repeatingSequence(edu.wpi.first.wpilibj2.command.Command... commands) Marker-safe counterpart toCommands.repeatingSequence(Command...).Each supplied command is wrapped with
Command.asProxy()before it is passed to WPILib. The returned repeating sequence does not inherit the proxied child requirements; those requirements are claimed only when WPILib schedules each proxied command.- Parameters:
commands- commands to run in sequence repeatedly- Returns:
- a marker-safe repeating sequential command group
- See Also:
-
Commands.repeatingSequence(Command...)Command.asProxy()
-
parallel
public static edu.wpi.first.wpilibj2.command.Command parallel(edu.wpi.first.wpilibj2.command.Command... commands) Marker-safe counterpart toCommands.parallel(Command...).Each supplied command is wrapped with
Command.asProxy()before it is passed to WPILib. The returned parallel group does not inherit the proxied child requirements; those requirements are claimed only when WPILib schedules each proxied command.- Parameters:
commands- commands to run in parallel- Returns:
- a marker-safe parallel command group
- See Also:
-
Commands.parallel(Command...)Command.asProxy()
-
race
public static edu.wpi.first.wpilibj2.command.Command race(edu.wpi.first.wpilibj2.command.Command... commands) Marker-safe counterpart toCommands.race(Command...).Each supplied command is wrapped with
Command.asProxy()before it is passed to WPILib. The returned race group does not inherit the proxied child requirements; those requirements are claimed only when WPILib schedules each proxied command.- Parameters:
commands- commands to run until the first command finishes- Returns:
- a marker-safe parallel race group
- See Also:
-
Commands.race(Command...)Command.asProxy()
-
deadline
public static edu.wpi.first.wpilibj2.command.Command deadline(edu.wpi.first.wpilibj2.command.Command deadline, edu.wpi.first.wpilibj2.command.Command... commands) Marker-safe counterpart toCommands.deadline(Command, Command...).The deadline and parallel commands are wrapped with
Command.asProxy()before they are passed to WPILib. The returned deadline group does not inherit the proxied child requirements; those requirements are claimed only when WPILib schedules each proxied command.- Parameters:
deadline- the command that ends the group when it finishescommands- other commands to run with the deadline- Returns:
- a marker-safe parallel deadline group
- See Also:
-
Commands.deadline(Command, Command...)Command.asProxy()
-