Class AutoChooser

java.lang.Object
org.team1126.lib.util.command.AutoChooser

public final class AutoChooser extends Object
Similar to SendableChooser, this class implements a selector over NetworkTables for choosing a command to run during the autonomous period.

The AutoChooser binds itself to the default CommandScheduler instance, and will automatically schedule the selected command at the beginning of autonomous.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an auto chooser, using the default /Autos table.
    Creates an auto chooser.
    AutoChooser(String name, boolean renameCommands)
    Creates an auto chooser.
  • Method Summary

    Modifier and Type
    Method
    Description
    edu.wpi.first.wpilibj2.command.button.Trigger
    add(String name, edu.wpi.first.wpilibj2.command.Command command)
    Add an option to the chooser.
    edu.wpi.first.wpilibj2.command.button.Trigger
    Returns a Trigger that is true when the default option ("Do Nothing") is selected.
    void
    enableScheduling(boolean enabled)
    Enables automatically scheduling the selected command when the robot is enabled in autonomous mode.
    edu.wpi.first.wpilibj2.command.Command
    Returns the command of the currently selected auto.
    edu.wpi.first.wpilibj2.command.button.Trigger
    Returns a Trigger that rises true for one cycle after an auto is selected.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AutoChooser

      public AutoChooser()
      Creates an auto chooser, using the default /Autos table.
    • AutoChooser

      public AutoChooser(String name)
      Creates an auto chooser.
      Parameters:
      name - The name for the chooser in NetworkTables.
    • AutoChooser

      public AutoChooser(String name, boolean renameCommands)
      Creates an auto chooser.
      Parameters:
      name - The name for the chooser in NetworkTables.
      renameCommands - If the specified names of autonomous options should be applied to their corresponding commands when adding them to the chooser.
  • Method Details

    • getSelected

      public edu.wpi.first.wpilibj2.command.Command getSelected()
      Returns the command of the currently selected auto.
    • newSelection

      public edu.wpi.first.wpilibj2.command.button.Trigger newSelection()
      Returns a Trigger that rises true for one cycle after an auto is selected.
    • defaultSelected

      public edu.wpi.first.wpilibj2.command.button.Trigger defaultSelected()
      Returns a Trigger that is true when the default option ("Do Nothing") is selected.
    • add

      public edu.wpi.first.wpilibj2.command.button.Trigger add(String name, edu.wpi.first.wpilibj2.command.Command command)
      Add an option to the chooser.
      Parameters:
      name - The name of the option. Must be unique.
      command - The option's command.
      Returns:
      A Trigger that is true when the option is selected.
    • enableScheduling

      public void enableScheduling(boolean enabled)
      Enables automatically scheduling the selected command when the robot is enabled in autonomous mode. This behavior is enabled by default.
      Parameters:
      enabled - true to enable automatic scheduling.