Is it possible to read data from a front panel table or multicolumn listbox and use it in the robot programming? If so, can somebody please explain to me how?
Our team would like to use the table to read times, x values, y values, and possibly various game objective settings to be able to change easily between matches.
If possible, we would like to have several strategies that would be switched between using driver station inputs.
It seems like you have two different questions here: How to read tabular data, and how to use driver station inputs:
Array controls work very nicely for this. Drag out an array control, then drag out a control of the type of data you want the array to hold (number, string, etc) and place it in the array control. You can then resize the array control to show as many elements as you like. Note that like other front panel controls in the robot programs, you will have to redeploy the code each time you change their values. Whenever you do so, right click on the control you have changed, go to Data Operations and click Make Current Values Default. This will save the current values so they will be used by your program whenever it runs on the robot. You can do the same thing for any type of control, not just arrays, such as the listbox you mention.
If you want to have multiple autonomous programs, you have a couple options: redeploy the code with the changed program before each match, or like you allude to, you can have switches on the robot or driver station that switch between the modes. As has been noted several times before on this forum, you’ll need to read and save the value of driver station mode switches in the Autonomous Disabled state, because driver station inputs are disabled (i.e. they will read 0) in Autonomous Enabled.
To continue filling in the info. Arrays are the datatype oriented control. An array of strings can be one, two, or multi-dimensional. It allows for decent editing, but not great. A table in LV always has a 2D array of string as the datatype, and it is the editing interface that improves – still not Excel on a panel, but better. The listbox may seem odd because its datatype isn’t string at all, but numeric. It is more for displaying a selection to the user and letting them choose a single or a set of items from a list. You can then read the properties to see what the strings were, or you can just know what you put there. Then you can index the array using the selection index. Beware that RT isn’t really meant for doing interfaces. Some of the UI things work, but not all. Be sure to test and don’t be totally surprised when UI centric things don’t work on RT.
thanks for the responses. I think we may be able to use the array as both of you described. I understand that this is not necessarily going to work as a edit while running interface, but rather my mentor and the other half of our programming group were thinking that it could be inputted before the match and simply rebuilt and loaded to the cRIO before the match. the reason for this type of input is mostly to allow the non-programming team members to understand what is going on [which is not necessarily the best way to go imo].
I wasn’t clear enough before and i was short on time, but i do understand saving default values, and how to use the driverstation switches, though we didn’t know that the switches could not be read in autonomous enabled, thanks for that =)
as for the problem, could either of you show me an image or vi that i could use as a base for developing this system. i want to read time, x and y value [or right and left] and at most two boolean inputs. Thanks again for the help.
Apologies if I’m a bit dense, but where do you want to read these inputs from? If these are settings you’re trying to read in from the DS, you can read x and y axes and buttons from the joystick the same way you normally would, but I’m not sure that would work the best for mode switches, usually I’d go for something more persistent, like toggle switches and pots connected to the digital and analog inputs on the side of the DS. I can give you instructions on how to hook these up if this is what you want.
When you say time, what time are you referring to? Using the Get Tick Count VI on the Timing palette, you can get a sort of system time that you can use for relative timing applications, but the actual number may not mean anything in particular (I’m not sure where it would be getting accurate real world time from). You could expand off of this, for example storing the time you entered into autonomous mode, teleop mode, etc, you could get a sense of how long the match had been running for.
If you’re talking about reading in multiple sets of these values, i.e. in your array control, you can use a cluster for that. Just drag out a cluster control, put in some number controls or boolean controls (what ever you need), then drag the cluster into the array control. This will give you an array of these clusters. When you’re reading them, index into your array, then use Unbundle to get at the individual values.
etc. but it would have to be dynamic in such a way that we can add several lines, up to at most 10, but also have as little as 1 line. as i said, this would be displayed on the front panel so we can say here is exactly what it will do at this point. we’d only be reading from these values and not from the DS or computer. the time i was talking about is the autonomous mode time which is kept track of by a get tick count in the DS vi’s and fed through to the match info.
thanks
[edit] the switches i was referring to are a set of 5 switches on the driverstation which have already been coded to work but we’re still stuck on getting the values into the function.
Sounds like what you want is in fact an array of clusters. Start by making a Cluster Control, then drag in three Numeric Controls and two boolean controls (switches of some sort). Give these appropriate labels, like the ones you described (“Start Time,” “X Position,” etc.). It may be helpful to physically arrange the controls in a horizontal line like you show, but this is not necessary.
Once you have made your cluster control, make an Array Control, then drag your Cluster Control into it. You can then show multiple elements in the Array Control by dragging on the corner to expand the control. Note that even though you have displayed multiple elements of the array, not all of them will necessarily be used; when they’re grayed out, they are “empty” elements. You can then go in and fill in the data. If you need more elements than the array control shows, you can increment the index counter (the little box in the upper left corner of the control), which will change the range of elements of the array that are displayed. If ever you want to remove an element from the array (make it grayed out again), right click on it, and choose Data Operations>>Delete Element. You can also clear the entire array by using Data Operation>>Empty Array. To figure out how many elements have been inputted, just use the Array Size function in your code.