View Full Version : global variables and autonomous independent
Team1824
13-02-2010, 11:33
Okay, I have been looking around but I haven't really found the answer to this question. I want to have several cases in autonomous independent that will depend on what field position we are in. I have read something about making a global variable in the finish.vi or something but I don't know anything about global variables. my idea is to put a case structure around all of the autonomous independent and then use the variable to select the case. Is this possible? my cases will be named 1, 2, 3 etc. how do I get the global variable to be read as a number and be wired to a case structure? thanks in advance.
Greg McKaskle
13-02-2010, 13:15
I think you are wanting to use DS switches to tell the robot what part of the field it is on.
If this is correct, you can read the DS I/O as many times as you like. And it can be stored in a global if that is helpful.
If you only want this info in the autonomous code, the sample code already reads the switch positions and the slider positions on the left. You can use these to tell the robot the field location.
To set the switches, you can either connect the I/O board and attach physical switches using the breadboard or another breakout, or you can leave the I/O board detached and use virtual switches and values onscreen in the I/O tab.
Greg McKaskle
Team1824
13-02-2010, 13:27
yeah I only want it for the autonomous code. how can I use the code to show the field position? I really have no idea about any of this.
Greg McKaskle
13-02-2010, 13:43
One way is to read the analog slider and wire it to the case structure. The value will automatically be converted to an integer and you can add cases for 1, 2, and 3.
Set the slider on the DS, run the autonomous, and put something in your code, like a breakpoint or probe so you can verify the right code is running.
Greg McKaskle
Team1824
13-02-2010, 13:47
how do I read the analog slider? is it a .vi or something?
Greg McKaskle
13-02-2010, 13:54
On the left side of the Autonomous, it calls Get Analog Input.vi. This returns the four sliders from the screen on the DS. If you plug in the I/O board, the board sets the sliders, not the screen.
Greg McKaskle
Team1824
18-02-2010, 15:02
okay I connected the analog one slot on the get analog in.vi to a case structure surrounding the autonomous code. So now I can just set the slider on the little laptop they sent us and it will convert that to different cases right?
Greg McKaskle
18-02-2010, 21:18
Test it and see.
Greg McKaskle
mswalker
19-02-2010, 17:25
Also check out the "Get Alliance" vi which outputs field position.
Ziaholic
19-02-2010, 17:31
Also check out the "Get Alliance" vi which outputs field position.
I might be mistaken, but I thought that that Get Alliance only shows your DRIVER STATION position, not necessarily your field position.
Tom Line
19-02-2010, 23:00
I might be mistaken, but I thought that that Get Alliance only shows your DRIVER STATION position, not necessarily your field position.
That is correct. Other than telling you whether you are on the red team or the blue team, Get Alliance does NOT tell you anything about your field position.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.