I have a pretty basic question that I cannot seem to find the answer for. Our team is going to do the vision processing on the PC running the driver station (since we’re sending back the image anyway) using labview (since more vision functions are available there). We are also using C++ on the robot (because our programmers like it better).
So, what we are trying to do is send back the x-coordinate of the target (a float) to the robot. What is the recommended way of doing this? I’ve read about the NetworkTable class for C++, but I assume that it requires a specific interface that I would have to recreate in labview. Is there already a corrsponding vi? Is there another completely different way to do it?
If you are interested in beta testing a LabVIEW version of Network Tables, post as much. It doesn’t do transactions yet, and I need to test performance and a few other things.
Well I was trying to come up with a ready made solution or common practice (like using the udp functions), and I don’t think I have enough time with labview this year to beta test it. Isn’t sending data from the dashboard to the robot a common problem?
A few years ago, I’d say it was very uncommon, but from what I’ve seen on the forums, it is becoming common enough to improve the level where it is programmed – to put more support into WPILib. The four slot work pushed off most other work, so it is just now being wrapped up.
I posted on some other forum with some UDP snippets that will accomplish this. I hope to have the Network Tables up in a few days, but I was looking for a few teams who were doing the cross-language stuff, since that has not been easy for me to get to.
My team has been trying to do the exact same thing as WizenedEE. We would be happy to do any beta testing if you need it.
I’m just opening a TCP connection in the labview on port 1140, one of the open ones. I take all my values, TCP Write them, and then outside of the dashboard loop I close the TCP connection.
I’m using Java, so I can’t exactly help you step by step through the cRIO side, but all you need to do is read from the TCP stream. Make sure to include some tokens in your output string in Labview so you can sort it out in the C++.
If anybody wants to look at my java or labview for the TCP send/recieve code, you can look at all of our Java on our github repository. I’m attaching my TCP loop that handles connection on the Dashboard side in the Labview as well. I can attach the transmitting part too but it gets kinda nasty with all my other blocks. It’s my first time doing labview and things aren’t always pretty.
TCPLoop.bmp (652 KB)
TCPLoop.bmp (652 KB)
Since you are using c++, you could switch to the smart dashboard which can send data to the robot. There is already an API for sending and recording data called networktables.
Yes, this is a very good point.
I didn’t use networktables in my Java code because the Java implementation is… terribly done. There are methods documented that don’t actually exist, etc, etc.
Would I be able to get a copy of the Network Tables for labview. We have our dashboard written in labview, and are trying to get the data sent back to our C++ robot code.
The LabVIEW implementation of Network Tables is on FIRSTForge in File Releases/Network Tables. Eight downloads have already happened, and I haven’t heard any explosions, so I guess it is stable enough. But I do need to say that it was built from the spec and tested against the SmartDashboard and LabVIEW running on the other side. I didn’t have enough time or tools to test it thoroughly. Also, I’m redoing some of it for performance and need to get transactions in. A few examples are needed as well.
Please let me hear any questions or issues.
We have been trying to set this up, and dont know exactly what functions to call on the driverstation and the CRIO. currently on the dashboard we have a loop which writes an int. we then on the crio we dont know exactly what code we need to init to read the table. would anyone be able to help us?
Be sure to place the Client in parallel with the other dashboard code and to wire the robot’s IP to the client VI. I don’t believe any of the other inputs are needed.
In the labview code do we use the server vi or the client vi. We are going to be using the dashboard to send the data over to the CRIO. On the crio we are running c++. The CRIO says we dont have a connection, and the value never changes when we are running the code
The robot is the server. The dashboard is the client. So be sure to run the client on the dashboard, give it the robot IP address and make sure that it does the auto-restart. You may want to run interactively at first to see if they are connecting. Also, the default to sync is a table called SmartDashboard. If you need to sync others, add them to the list.
Hi Greg, I’m a programmer working on the project in question. We tried to write up a simple test program to see if we could get data from the Dashboard to the Crio (running in C++). I don’t have the Labview code handy, but here is the C code that’s suppose to receive the data:
NetworkTable *myNetworkTable = new NetworkTable;
myBoolean = myNetworkTable->GetBoolean(“Test”);
Should this code be working? Are we doing anything wrong, at least on the receiving end?
Also, I was looking through the libraries a bit and I realized that the C++ and Labview functionality are different. For example, C++ doesn’t have a function to create a Network Table (at least not one that’s accessible from the NetworkTable class).
Any help you could give us on this would be amazing. Thanks.
Sorry it took longer to respond. I overlooked the message. One of the comments on the project is that it doesn’t implement transactions yet. Can you try commenting out the transaction begin and end and see if that works?
I believe we tried that originally to no success. At this point, we’ve decided not to use this on our robot, but we still want to get it working for future use. Do you have any other ideas for us to try?
I haven’t really had enough time to try the combo out myself, so I’m afraid I don’t know the common failures. Hopefully in a week or so I’ll get to it.
Thanks. Please let us know if/when you find anything…
We are also using Labview on the dashboard and C++ on the robot. We were trying to use the network tables to pass data back and forth, but have had a lot of problems. It looks like we might be having some race conditions, and the data is often not written to the table properly.
As a test, we had a loop running on the robot, that wrote the values 0,1,2, and 3 in a loop once in a second to a network variable. On the receiving end, we would see that some values were skipped, so for example, we would see, 0 ->1 -> then a pause -> 3 -> 0.
Passing data from the driver station (labview) to the robot (c++) seems to be much more reliable, although we still have the occasional instance on the robot, when it tries to read a variable, and just freezes waiting for a response.
Does anyone have any sample C code successfully using the network tables? We are thinking that we might be ignoring some setup functions or something. Essentially we make a table and then use the getINT, getFloat, putInt, PutFloat etc functions as needed. Are there other timing, synchronizing functions we should be worried about. We are doing the same on the Labview side and that seems to be working fine.
Appreciate anyones help,