Class LoggedDashboardChooser<V>
java.lang.Object
org.littletonrobotics.junction.networktables.LoggedNetworkInput
org.littletonrobotics.junction.networktables.LoggedDashboardChooser<V>
- Type Parameters:
V- The value type associated with each string key.
Manages a chooser value published to the "SmartDashboard" table of NT.
-
Field Summary
Fields inherited from class org.littletonrobotics.junction.networktables.LoggedNetworkInput
prefix -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new LoggedDashboardChooser, for handling a chooser input sent via NetworkTables.LoggedDashboardChooser(String key, SendableChooser<V> chooser) Creates a new LoggedDashboardChooser, for handling a chooser input sent via NetworkTables. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDefaultOption(String key, V value) Adds a new option to the chooser and sets it to the default.voidAdds a new option to the chooser.get()Returns the selected option.Returns the internal SendableChooser object, for use when setting up dashboard layouts.voidBinds the callback to run whenever the selected option changes.voidperiodic()Update the current value and save/replay the input.Methods inherited from class org.littletonrobotics.junction.networktables.LoggedNetworkInput
removeSlash
-
Constructor Details
-
LoggedDashboardChooser
Creates a new LoggedDashboardChooser, for handling a chooser input sent via NetworkTables.- Parameters:
key- The key for the chooser, published to "/SmartDashboard/{key}" for NT or "/DashboardInputs/SmartDashboard/{key}" when logged.
-
LoggedDashboardChooser
Creates a new LoggedDashboardChooser, for handling a chooser input sent via NetworkTables. This constructor copies the options from a SendableChooser. Note that updates to the original SendableChooser will not affect this object.- Parameters:
key- The key for the chooser, published to "/SmartDashboard/{key}" for NT or "/DashboardInputs/{key}" when logged.chooser- The existing SendableChooser object.
-
-
Method Details
-
addOption
Adds a new option to the chooser.- Parameters:
key- The string key for the option.value- The value of the option.
-
addDefaultOption
Adds a new option to the chooser and sets it to the default.- Parameters:
key- The string key for the option.value- The value of the option.
-
get
Returns the selected option. If there is none selected, it will return the default. If there is none selected and no default, then it will returnnull.- Returns:
- The value for the selected option.
-
onChange
Binds the callback to run whenever the selected option changes. There can only be one listener, and this method overrites it with each invokation.- Parameters:
listener- The function to call that accepts the new value.
-
getSendableChooser
Returns the internal SendableChooser object, for use when setting up dashboard layouts. Do not read data from the SendableChooser directly.- Returns:
- The internal SendableChooser object.
-
periodic
public void periodic()Description copied from class:LoggedNetworkInputUpdate the current value and save/replay the input. This function should never be called by user code.- Specified by:
periodicin classLoggedNetworkInput
-