SendableChooser¶
- class wpilib.SendableChooser[source]¶
Bases: wpilib.Sendable
A useful tool for presenting a selection of options to be displayed on the SmartDashboard
For instance, you may wish to be able to select between multiple autonomous modes. You can do this by putting every possible Command you want to run as an autonomous into a SendableChooser and then put it into the SmartDashboard to have a list of options appear on the laptop. Once autonomous starts, simply ask the SendableChooser what the selected value is.
Example:
# This shows the user two options on the SmartDashboard chooser = wpilib.SendableChooser() chooser.addObject('option1', '1') chooser.addObject('option2', '2') wpilib.SmartDashboard.putData('Choice', chooser) # .. later, ask to see what the user selected? value = chooser.getSelected()
Instantiates a SendableChooser.
- DEFAULT = 'default'¶
- OPTIONS = 'options'¶
- SELECTED = 'selected'¶
- addDefault(name, object)[source]¶
Add the given object to the list of options and marks it as the default. Functionally, this is very close to addObject(...) except that it will use this as the default option if none other is explicitly selected.
Parameters: - name – the name of the option
- object – the option