This year I want to have dynamic autonomous selection. This means that when I choose center auton, the option to start on the left/right disappears but when I select an autonomous mode such as side auton, a chooser appears for me to select which side we’re starting on.
Currently, if I add a SendableChooser to a ShuffleboardContainer I get a ComplexWidget to deal with. I cannot figure out how to remove this. However, I see that SimpleWidget has a NetworkTableEntry that I can delete().
So my question is if I can add and remove a SendableChooser or if I can add the SendableChooser in a way that I get a SimpleWidget in return. Getting a SimpleWidget would be preferable because I would also like to add a listener to the NetworkTableEntry so I get notified whenever the chooser’s value changed.
Widgets cannot be removed from Shuffleboard from the robot program.
You can, however, modify the choices available in an existing sendable chooser.
1 Like
Thanks! I didn’t think of doing that but it will accomplish what I want perfectly.
1 Like
Clarification: you can add new options to an existing chooser, but can’t remove them. So you won’t be able to remove the options for the left and right sides.
An alternative to making dynamic choosers would be to make a single chooser with all possible options in it (LEFT_SIDE_TO_SHIP
, CENTER_TO_SHIP
, RIGHT_TO_SHIP
). Maybe have another chooser for doing something after scoring, like going to the nearest loading station.
Or you can make a custom widget for doing the dynamic options you want.
Do you know if I have to make my own SendableChooser or can I just replace the SendableChooser with a new one each time I want to change the options? I am unable to test my code on a roborio right now.
Can I do this?
tab.add("Side Chooser", leftAndRightChooser);
then later do
tab.add("Side Chooser", centerChooser);
Will the second one replace the first?
If it doesn’t I’ll end up creating my own SendableChooser like class.
No, that would throw an exception.
For the SendableChooser
-like class, you could take the contents of SendableChooser and add your own removeOption
method. That’d mean no need to create your own custom widget, since the Shuffleboard widgets for SendableChooser will automatically handle removing and adding options.