Package org.team1126.lib.util.command
Class AutoChooser
java.lang.Object
org.team1126.lib.util.command.AutoChooser
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
ConstructorsConstructorDescriptionCreates an auto chooser, using the default/Autostable.AutoChooser(String name) Creates an auto chooser.AutoChooser(String name, boolean renameCommands) Creates an auto chooser. -
Method Summary
Modifier and TypeMethodDescriptionedu.wpi.first.wpilibj2.command.button.TriggerAdd an option to the chooser.edu.wpi.first.wpilibj2.command.button.TriggerReturns aTriggerthat istruewhen the default option ("Do Nothing") is selected.voidenableScheduling(boolean enabled) Enables automatically scheduling the selected command when the robot is enabled in autonomous mode.edu.wpi.first.wpilibj2.command.CommandReturns the command of the currently selected auto.edu.wpi.first.wpilibj2.command.button.TriggerReturns aTriggerthat risestruefor one cycle after an auto is selected.
-
Constructor Details
-
AutoChooser
public AutoChooser()Creates an auto chooser, using the default/Autostable. -
AutoChooser
Creates an auto chooser.- Parameters:
name- The name for the chooser in NetworkTables.
-
AutoChooser
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 aTriggerthat risestruefor one cycle after an auto is selected. -
defaultSelected
public edu.wpi.first.wpilibj2.command.button.Trigger defaultSelected()Returns aTriggerthat istruewhen 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
Triggerthat istruewhen 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-trueto enable automatic scheduling.
-