Just wondering…has anyone else had issues with variables in autonomous? In our code, we like to make our variables controls so that they are easily adjustable from the front panel of autonomous. This worked fine while testing it at home. When we got to the competition, it became obvious that the code could not recognize these control values, even though we always set “make values default”. There were no errors, but the robot practically made up its own numbers rather than use the ones we gave it. For example, rather than driving the 100 inches we set in the control, it drove something like 512 inches. Very random…We fixed the problem by changing all the controls back to constants. I think I remember a similar problem occurring last year with controls and constants, but I’m not sure. As a side note, the controls work fine everywhere else in the code (Begin, telop, periodic tasks, etc.)
Did anyone else have this issue? I’m curious as to why this occurs? It’s got to be some kind of Labview thing…and word to the wise - USE CONSTANTS IN AUTONOMOUS!
If the code only reads from a variable and never changes it, you should always set it as a constant. Its safer, faster, and keeps you from accidentally changing values you don’t want to change.
I haven’t noticed any difference with deploying versus building and putting the files on the c RIO, and we have controls EVERYWHERE. There are about 20 in autonomous, with two that are actually variable. The thing is, I used all of them whilst testing.
For the set as default thing, I noticed that you can select all of the controls and then go to edit -> Make current values default to do it faster. You probably already know that though.
Should I quickly change all of them into constants? That would make it much much harder to debug and tune.
Using controls in the way you describe is equivalent to using constants. There is no reason to change things to controls.
Just to be clear, though, there is a difference between controls that are connected to the connector pane and are actually parameters, and controls that are not.
If the controls are connected to the connector, the value is passed in or the default value is used.
If not connected, the initial value of the control is the default value, but programmatic or interactive changes persist until it leaves memory.
If you have concerns about the value being used, load the code interactively and see if the default values are the correct ones, or if the default was set to the incorrect value last time.