So for this year's game we were hoping to do video processing to target the backboard squares. We rewrote the Dashboard in LabView so we do all of our image processing on the Dashboard. We get coordinates of the rectangles and would like to use those numbers in Java, where we program the actual robot. After countless hours of trying various UDP and TCP combinations in both Java and LabView, we finally found a working solution!
The LabView end is pretty simple. First you need a TCP Listen.vi object, and then you need a TCP Write block inside a loop. Things on this end should be pretty clear, but if something isn't, we can post screenshots or more detailed information. We're using port 1180.
The Java end is a bit trickier. You attempt to open a connection to the port, and the LabView listener should accept the connection. Then we stream the data coming from LabView, and the InputStream reads it. We then output that data in Java. The code is from the FRC Iterative Robot Template, and we attached the main RobotTemplate.java file.
One important thing is, at the moment, the data streams faster than Java can process it. We're going to have to slow it down so we don't get a backlog of data when processing. Depending on your needs, this might be a thing to consider.
This code is free for anyone to use and it can be modified in any way. If anyone has a suggestion for improvements, please post them!
Hope this helps and good luck to all teams!!
-CRUSH 1011 Programmers
RobotTemplate.java