Class BLineCommands

java.lang.Object
frc.robot.lib.BLine.BLineCommands

public final class BLineCommands extends Object
Command composition helpers that proxy child commands before delegating to WPILib.

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:
  • Commands
  • Command.asProxy()
  • Method Summary

    Modifier and Type
    Method
    Description
    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 to Commands.deadline(Command, Command...).
    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 to Commands.defer(Supplier, Set).
    static edu.wpi.first.wpilibj2.command.Command
    deferredProxy(Supplier<edu.wpi.first.wpilibj2.command.Command> supplier)
    Marker-safe counterpart to Commands.deferredProxy(Supplier).
    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 to Commands.either(Command, Command, BooleanSupplier).
    static edu.wpi.first.wpilibj2.command.Command
    parallel(edu.wpi.first.wpilibj2.command.Command... commands)
    Marker-safe counterpart to Commands.parallel(Command...).
    static edu.wpi.first.wpilibj2.command.Command
    race(edu.wpi.first.wpilibj2.command.Command... commands)
    Marker-safe counterpart to Commands.race(Command...).
    static edu.wpi.first.wpilibj2.command.Command
    repeatingSequence(edu.wpi.first.wpilibj2.command.Command... commands)
    Marker-safe counterpart to Commands.repeatingSequence(Command...).
    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 to Commands.select(Map, Supplier).
    static edu.wpi.first.wpilibj2.command.Command
    sequence(edu.wpi.first.wpilibj2.command.Command... commands)
    Marker-safe counterpart to Commands.sequence(Command...).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 to Commands.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 when selector returns true
      onFalse - the command selected when selector returns false
      selector - 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 to Commands.select(Map, Supplier).

      Each command in commands is wrapped with Command.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 commands
      selector - 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 to Commands.defer(Supplier, Set).

      The command supplied at runtime is wrapped with Command.asProxy() before it is run by WPILib. The explicit requirements argument 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 initialized
      requirements - 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 to Commands.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 to Commands.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 to Commands.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 to Commands.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 to Commands.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 to Commands.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 finishes
      commands - other commands to run with the deadline
      Returns:
      a marker-safe parallel deadline group
      See Also:
      • Commands.deadline(Command, Command...)
      • Command.asProxy()