Hello, today while testing autonomous I found a breaking issue. The error is the following:
Ignore the “Cannot find layout” error.
Regarding the error, I was testing some sendablechoosers to help with our autonomous. We are using two: one for the actual path, and another one for the position the pieces will be placed in. These can be found in the autonomousPaths.java, and the choosers can be found in the AutoModeSelector.java & GridPlacementSelector.java
Here is the repo for the repository: Commits · VOLTEC6647/Voltec-2023 · GitHub
I would greatly appreciate any help, as the robot goes tomorrow for a regional, and it doesn’t move because of this .
The ERROR message doesn’t really give enough information. The full console log will show the stack trace of how it got there. If you’ve closed the DS so you can’t pop up the console window anymore, it should also be in the DS log file.
I have a guess at what’s happening: your getAutoMode() function calls autoChooser.getSelected() and then switches on the result. That function can return null if the selected key exists, but none of the values in the map match. The switch statement can’t handle this case, as it’s expecting an enum value. If this is the issue, you can fix it by adding a null check before entering the switch.
Okay, Im going to try that. My question is, if there are a defined number of options in the enum, then why doesnt the map match?
The map lookup in getSelected() is from the string (in NT) to the option value. The string could be anything (since it’s coming from NT, it’s not restricted to the set of options); it returns null if the string isn’t in the map.
Okay then, thanks a lot, I’ll try it out
Hi, It worked, the thing now is that the value is not updating. I’ve tried doing shuffleboard.update() but it just picks the default value. Can you help me, please?
You shouldn’t need to call either update or updateValues (the IterativeRobotBase class does that for you). A few things to try:
- Open OutlineViewer and see if you can see the Auto Mode selection in NetworkTables and validate that it’s indeed changing when you change the selection in Shuffleboard
- Does Shuffleboard display a checkmark next to the auto mode selection? When you change it it may momentarily change to an X before changing back to a checkmark. The checkmark is an indicator that the robot code is echoing back the same value.
- Print out the value returned by getSelected()
According to what I’ve seen, it appears that it runs the command that was selected when the robot code first starts. As if the autonomous init was run before the robot was in autonomous.
- I’ve tried outline viewer and it does update the value
- Shuffleboard displays the checkmark, and when I change it I also get a checkmark
-Printing out the value during robotperiodic works fine, but in autonomous, if I put it in the autonomousInit, it will only run once when the robot starts.
I think I’ve seen the issue. I think that the commands are initially scheduled when the robot starts, and these are the commands that run, meaning that they are not updated. If I am right, are there any fixes to it?
Okay fixed it, my issue sorry, I was creating the commands at run time on another file