I have two examples of the SendableChooser
not behaving as it appears on The SmartDashboard
.
-
Select an option other than the
Default
and use it - that works okay. Then rerunning using theDriverStation Restart Robot Code
, thegetSelected()
initially reports theDefault Value
then on the next iteration or so reports the previous, showing on theSmartDashboard
value. There is that one iteration that has the wrong (not selected Default) value. -
Select an option and use it okay.
Deploy
new robot code instead ofRestart Robot Code
). The default value is selected even though the previously selected value is still showing. On the attached image notice the discrepancy between theRetained Selected Value ("Auto 2")
and theActive Transitory Value ("Auto None")
.
Neither of these two behaviors is desirable but at least in case 1 it fixes itself in one or so robot iterations.
I donāt understand the usage of Retained
and Transitory
Values. If there was a way to clear them both out to a known state by the Robot Code, that would be best. Lacking that I think the getSelected()
should always select what we see on the SmartDashboard
.
Iām pretty sure the 2022 system worked okay last week (at least I never noticed a problem running it many times) so I donāt see how Iām abusing the code today. Any explanation and help is appreciated.
.
public static enum AutoChoice
{
kAuto1, kAuto2, kAuto3, kAuto4, kAuto5, kAuto6, kAuto7, kAuto8
}
private final SendableChooser<AutoChoice> autoChooser;
autoChooser = new SendableChooser<AutoChoice>();
// in the attached image I have some longer ugly test options that I shortened here
autoChooser.addOption( "Auto 1", AutoChoice.kAuto1);
autoChooser.addOption( "Auto 2", AutoChoice.kAuto1);
autoChooser.addOption( "Auto 3", AutoChoice.kAuto1);
autoChooser.addOption( "Auto 4", AutoChoice.kAuto1);
autoChooser.addOption( "Auto 5", AutoChoice.kAuto1);
autoChooser.addOption( "Auto 6", AutoChoice.kAuto1);
autoChooser.addOption( "Auto 7", AutoChoice.kAuto1);
autoChooser.setDefaultOption("Auto None", AutoChoice.kAuto8 );
SmartDashboard.putData("Auto choices", autoChooser);
// call this method to retrieve the selection
AutoChoice getAutoChoice ()
{
return autoChooser.getSelected();
}