Package com.thunder.lib.auto
Class ThunderAutoSendableChooser
java.lang.Object
com.thunder.lib.auto.ThunderAutoSendableChooser
A wrapper around SendableChooser to handle ThunderAuto trajectory, auto mode,
and command selections.
This chooser will automatically update its options when the associated
project gets updated.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents the current selection in the chooser. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Constructs a chooser with the given trajectory runner properties.ThunderAutoSendableChooser(String smartDashboardKey) Constructs an empty chooser and publishes it to SmartDashboard under the given key.ThunderAutoSendableChooser(String smartDashboardKey, ThunderTrajectoryRunnerProperties runnerProps) Constructs a chooser with the given trajectory runner properties and publishes it to SmartDashboard under the given key. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllAutoModesFromProject(String projectName) Add all auto modes from a previously included project to the chooser.voidaddAllTrajectoriesFromProject(String projectName) Add all trajectories from a previously included project to the chooser.booleanaddAutoModeFromProject(String projectName, String autoModeName) Add an auto mode from a previously included project to the chooser.booleanaddCustomCommand(String name, Command command) Add a custom command to the chooser.booleanaddTrajectoryFromProject(String projectName, String trajectoryName) Add a trajectory from a previously included project to the chooser.Get the currently selected item from the chooser.Get the currently selected command from the chooser.voidincludeProjectSource(ThunderAutoProject project) Include a ThunderAuto project as a source for trajectories and auto modes.voidincludeProjectSource(ThunderAutoProject project, boolean addAllAutoModes, boolean addAllTrajectories) Include a ThunderAuto project as a source for trajectories and auto modes.voidPublishes the chooser to SmartDashboard.voidSets the trajectory runner properties to use for making trajectory commands.
-
Constructor Details
-
ThunderAutoSendableChooser
public ThunderAutoSendableChooser()Default constructor. The chooser will not be published to SmartDashboard until publish() is called. -
ThunderAutoSendableChooser
Constructs an empty chooser and publishes it to SmartDashboard under the given key.- Parameters:
smartDashboardKey- The key in SmartDashboard to publish the chooser under.
-
ThunderAutoSendableChooser
Constructs a chooser with the given trajectory runner properties. The chooser will not be published to SmartDashboard until publish() is called.- Parameters:
runnerProps- The trajectory runner properties to use for making trajectory commands.
-
ThunderAutoSendableChooser
public ThunderAutoSendableChooser(String smartDashboardKey, ThunderTrajectoryRunnerProperties runnerProps) Constructs a chooser with the given trajectory runner properties and publishes it to SmartDashboard under the given key.- Parameters:
smartDashboardKey- The key in SmartDashboard to publish the chooser under.runnerProps- The trajectory runner properties to use for making trajectory commands.
-
-
Method Details
-
setTrajectoryRunnerProperties
Sets the trajectory runner properties to use for making trajectory commands.- Parameters:
runnerProps- The trajectory runner properties to set.
-
publish
Publishes the chooser to SmartDashboard. This only needs to be called once, as the chooser will automatically refresh the chooser when changes are made.- Parameters:
smartDashboardKey- The key to publish the chooser under.
-
includeProjectSource
Include a ThunderAuto project as a source for trajectories and auto modes. Trajectories and auto modes from this project can later be added to the chooser using the appropriate methods.- Parameters:
project- The ThunderAuto project to include.
-
includeProjectSource
public void includeProjectSource(ThunderAutoProject project, boolean addAllAutoModes, boolean addAllTrajectories) Include a ThunderAuto project as a source for trajectories and auto modes. Trajectories and auto modes from this project can later be added to the chooser using the appropriate methods.- Parameters:
project- The ThunderAuto project to include.addAllAutoModes- If true, all auto modes from the project will be added to the chooser.addAllTrajectories- If true, all trajectories from the project will be added to the chooser.
-
addAllTrajectoriesFromProject
Add all trajectories from a previously included project to the chooser.- Parameters:
projectName- The name of the project to add trajectories from. This must match the name of a project previously included using includeProjectSource().
-
addAllAutoModesFromProject
Add all auto modes from a previously included project to the chooser.- Parameters:
projectName- The name of the project to add auto modes from. This must match the name of a project previously included using includeProjectSource().
-
addTrajectoryFromProject
Add a trajectory from a previously included project to the chooser.- Parameters:
projectName- The name of the project to add the trajectory from. This must match the name of a project previously included using includeProjectSource().trajectoryName- The name of the trajectory to add from the project.- Returns:
- True if the trajectory was successfully added, false if the project or trajectory was not found, or another item with the same name was already added to the chooser.
-
addAutoModeFromProject
Add an auto mode from a previously included project to the chooser.- Parameters:
projectName- The name of the project to add the auto mode from. This must match the name of a project previously included using includeProjectSource().autoModeName- The name of the auto mode to add from the project.- Returns:
- True if the auto mode was successfully added, false if the project or auto mode was not found, or another item with the same name was already added to the chooser.
-
addCustomCommand
Add a custom command to the chooser.- Parameters:
name- The name of the custom command.command- The command to add.- Returns:
- True if the command was successfully added, false if another item with the same name was already added to the chooser.
-
getSelectedCommand
Get the currently selected command from the chooser.- Returns:
- The selected command.
-
getSelected
Get the currently selected item from the chooser.- Returns:
- The selected item.
-