Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Driverstation referencing (http://www.chiefdelphi.com/forums/showthread.php?t=113406)

CooneyTech 13-02-2013 10:18

Driverstation referencing
 
1 Attachment(s)
Id like to be able to get values from our driver station into my code so I can quickly change code through my driver station in Labview. I have tried using the new driver station blocks that we got this year in the update that sends code to the driver station but it won't send values back to the code. Anyone have any ideas on how I can get values from the driver station to the code?

The picture below shows the values I want to use in my code.

Greg McKaskle 13-02-2013 21:26

Re: Driverstation referencing
 
1 Attachment(s)
You've made a number of additional tabs. In order to add the controls to the binding list, duplicate the dashboard code that is attached, but create the constant from your new tab datatype and append the arrays together before binding.

That will be enough to create variables on the robot that you can read from wherever you need them.

It would be a good idea to make the variable names unique. having eight Holder controls will likely be confusing.

Greg McKaskle

CooneyTech 13-02-2013 21:38

Re: Driverstation referencing
 
Quote:

Originally Posted by Greg McKaskle (Post 1232976)
You've made a number of additional tabs. In order to add the controls to the binding list, duplicate the dashboard code that is attached, but create the constant from your new tab datatype and append the arrays together before binding.

That will be enough to create variables on the robot that you can read from wherever you need them.

It would be a good idea to make the variable names unique. having eight Holder controls will likely be confusing.

Greg McKaskle

The holder dags are just place holders and will be changed or deleted before competition. Thanks for the help.

CooneyTech 13-02-2013 22:05

Re: Driverstation referencing
 
How do I append the arrays?

CooneyTech 13-02-2013 22:25

Re: Driverstation referencing
 
1 Attachment(s)
I an posting all I have so far so you can look at it. After it's bundled and binded do I reference it in my code through some sort of SD Read?

Greg McKaskle 14-02-2013 08:35

Re: Driverstation referencing
 
1 Attachment(s)
The attached image collects references to the controls in Operation and in your tab. It combines them into a single array using the array builder, and those will then be bound to variables of the same name. In order to write this code, you will need to right-click and tell the array builder whether the 2 one dimensional arrays should be built into a longer 1-D array or a 2-D array. It default to 2-D, so right click and tell it to concatenate.

The other code you were writing outside of the loops will only run once. So the D Shifter Invert doesn't do what you probably intended. If it is to be read each iteration of the loop, the terminal needs to be in the loop. I suspect that most of the other terminals won't be used on the dashboard except for display, and simply need to be stacked on the side, where the Slider 1 and Checkboxes are.

Greg McKaskle

CooneyTech 14-02-2013 10:27

Re: Driverstation referencing
 
Ok I put everything where it should be and it should all be binded. When I reference it it my crio code do I side a SD write in the dashboard and a SD read in the crio code?

Greg McKaskle 14-02-2013 20:40

Re: Driverstation referencing
 
You can both read and write to the variable on the cRIO. You can both read and write to the variable on the dashboard.

Interactive edits to the value of the control will propagate to the variable.

The one case that will not propagate is if you write to a terminal or local of the control and want it to affect the variable. This is to avoid race conditions.

Greg McKaskle

CooneyTech 14-02-2013 20:51

Re: Driverstation referencing
 
Quote:

Originally Posted by Greg McKaskle (Post 1233528)
You can both read and write to the variable on the cRIO. You can both read and write to the variable on the dashboard.

Interactive edits to the value of the control will propagate to the variable.

The one case that will not propagate is if you write to a terminal or local of the control and want it to affect the variable. This is to avoid race conditions.

Greg McKaskle

Is their a read and write for clusters?

Alan Anderson 14-02-2013 23:08

Re: Driverstation referencing
 
Quote:

Originally Posted by CooneyTech (Post 1233533)
Is their a read and write for clusters?

There isn't one built in that I've found. You'll need to unbundle the cluster and write each element separately, and you can bundle them back together at the other end if you want to. If you get fancy, I think you can use a name hierarchy, adding the cluster name and a slash in front of the element name, and get things to "cluster" together in the variable viewer.

CooneyTech 14-02-2013 23:22

Re: Driverstation referencing
 
Thank you Mr. McKaskle and Mr. Anderson for the help. This will make editing code at competition much fast.

Greg McKaskle 15-02-2013 08:15

Re: Driverstation referencing
 
As mentioned, SmartDashboard is very simple and doesn't have clusters. It does have arrays, so if you look at how the motors and joysticks are done, the elements are put into an array of numbers and an array of Booleans and are broken apart when accessed. This trick isn't something you have to do though. If you do it, you may find that converting from array to cluster and back is handy. But you can also do this by dropping and growing the Array Index node and the Build Array node.

Greg McKaskle

CooneyTech 15-02-2013 16:07

Re: Driverstation referencing
 
2 Attachment(s)
I have it so it gets binded, but when I try referencing the values it only gives me zero. Am I doing something wrong?

On the left is teleop on the right is the dashboard reference.

Greg McKaskle 15-02-2013 22:18

Re: Driverstation referencing
 
Have you tried to look at the variables tab to see if the writes are working? On the dashboard, you can click to the tab and scroll to see all variables and their current value.

Greg McKaskle

CooneyTech 16-02-2013 12:25

Re: Driverstation referencing
 
The variables tab works correctly yes but that's getting variables from the code not sending variables to the code. Right?

Greg McKaskle 16-02-2013 17:17

Re: Driverstation referencing
 
The variables tab shows the current value of every variable in all network tables along with metrics on its usage. If it shows the correct value, that indicates the writes are working and the issue is with the reads, otherwise the first issue to resolve is that the writes are not working.

Greg McKaskle

Alan Anderson 17-02-2013 01:43

Re: Driverstation referencing
 
Quote:

Originally Posted by CooneyTech (Post 1233960)
On the left is teleop on the right is the dashboard reference.

I see them in the other order, but no matter.

Where are those wires heading upward in the dashboard code going, and what are they connected to? Is that part of the code inside a loop?

CooneyTech 17-02-2013 09:55

Re: Driverstation referencing
 
Quote:

Originally Posted by Alan Anderson (Post 1234831)
I see them in the other order, but no matter.

Where are those wires heading upward in the dashboard code going, and what are they connected to? Is that part of the code inside a loop?

It was a different test I did I was bundling them then trying to send them that way to. I have sense removed it and just did each one individually.

CooneyTech 17-02-2013 18:09

Re: Driverstation referencing
 
1 Attachment(s)
Attached I have the driver station code and the code for Teleop where i reference it.

Alan Anderson 17-02-2013 22:43

Re: Driverstation referencing
 
Quote:

Originally Posted by CooneyTech (Post 1235171)
Attached I have the driver station code and the code for Teleop where i reference it.

It looks like your Dashboard code does a SmartDashboard write for those values once when the program begins, then never does it again. If you want to use the SD Write functions, you'll need to put them in a loop that runs as long as the values are required.

But you don't need to use the SD functions with the LabVIEW Dashboard. An indicator or control on the Operations tab is automatically a SmartDashboard variable all by itself, and Greg showed you how to make things on other tabs work as well.

CooneyTech 17-02-2013 22:56

Re: Driverstation referencing
 
If its a SD by its self how exactly do I reference it? And for a loop would a while loop work ok?

Alan Anderson 17-02-2013 23:47

Re: Driverstation referencing
 
Quote:

Originally Posted by CooneyTech (Post 1235359)
If its a SD by its self how exactly do I reference it? And for a loop would a while loop work ok?

Most of the time, you would "reference" a SmartDashboard variable simply by looking at it on the Dashboard's front panel, or by clicking on it, or by typing a number in it.

A While loop is perfect. Just make sure to include a short delay (50 ms or so) to keep it from monopolizing the CPU.

DKolberg 19-02-2015 13:42

Re: Driverstation referencing
 
Quote:

Originally Posted by Alan Anderson (Post 1233601)
There isn't one built in that I've found. You'll need to unbundle the cluster and write each element separately, and you can bundle them back together at the other end if you want to. If you get fancy, I think you can use a name hierarchy, adding the cluster name and a slash in front of the element name, and get things to "cluster" together in the variable viewer.

You can use the flatten to/from string to send anything between robot and driver station. Just have to use correct constant type for the unflatten.


All times are GMT -5. The time now is 22:52.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi