Trying to pull a variable from the Network Table using Labview. When we are using our Limelight we can Read from the Network Table using the /limelight/tv to determine if we have a target. We are attempting to utilize Photonvision and when we look at the Variables in the Dashboard we can see that the Variable for determining if we have a Target is listed under photonvision, subtable of Cam (which is the nickname for the camera we are using), and the actual Variable we are looking for hasTarget. We can also see on the Dashboard when we have a Target and when we don’t. We are having trouble pulling that boolean value of True/False from the Network Table into our code. We have used the string name of /photonvision/Cam/hasTarget tied into our Read block and also tried //photonvision/Cam/hasTarget without success. Any suggestions?
Please post a snippet of the code
Thanks for the help.
Two things I would check for.
Make sure the NT Read Boolean VI is not throwing an error. As long as they follow LabVIEW style guides there should be an error out indicator you can look at to determine if an error is occurring.
Next I would check that the code is actually executing. Is it sitting in a case structure or other part of your code that is never running? You can check this with a probe on the output boolean wire and run the code in LabVIEW by pressing the execution arrow. This will do a deploy to the robot with the code you have residing on the computer and let you look at the data using probes. Avoid highlight execution mode while doing this because the code slowing down can cause other issues.
We placed the code snipped in the teleop portion to make sure we were not having it in a portion that was not running. We are not getting any errors of any sort when we are using the “run continuously” arrow. We are getting data back on the front panel for other Network Table items we are reading, but nothing for the “hasTarget” variable. We can see the True/False change in the variable table for the dashboard when we move the camera, but no change on the indicator for the front panel of teleop.
We believe we are using the proper format for the name used in the code snippet. Any suggestions would be appreciated.
I notice in the docs they do specify “hasTarget”, but in the Java src it is listed as “hasTargets”. Are you getting ANY network table info from the pipeline of the camera?
I would make sure you are running the entire robot code and not just that individual VI. There shouldn’t be a need to run continuously if you are running robot main and go into teleoperated mode on the driver station. There are setup actions that occur in robot main that if you don’t run them could be causing you issues. When you run robot main, make sure you just press the run arrow and not run continuously.
We haven’t tried pulling any other data yet from the Network Table for the camera yet. We were just trying to pull one variable to start and build from there. We will try “hasTargets” tonight if we can’t find any other solutions. Our assumption was to utilize the same names found in the variable table on the Dashboard.
We will try just the run arrow as well. We have been using the run continuously selection in Robot Main for a couple of years for testing and don’t know that it caused any problems, but we are always willing to learn.
Shouldn’t cause any major issues if you are running robot main. The difference is just that if you end the application in LabVIEW it will automatically run it again. Think of it like a while loop outside of your application code and the only way to stop it is by pressing the VI stop button.
Sounds like you did a lot of your diligence already. Maybe try another variable to read to see if that yields any results as a check of the interface.
From the docs:
- hasTarget boolean
- targetPitch double
- targetYaw double
- targetArea double
should all be from the Network Table.
Try any of these as well.
Thinking that misnaming of the pipeline is the culprit (/photonvision/Cam), case? mispelling?
Assuming that you are able to connect to the camera via browser, check the settings and make sure the name matches.
Would the correct naming convention from the pipeline be “/photonvision/Cam/hasTarget” based upon what we are seeing in the FRC Dashboard? Is there an additional information that needs to be added.
We can see the data on our browser, the names match up. The data we get from the brower, (do we have target, and the targetYaw) matches between the browser and what shows up in the FRC dasboard.
So someone on the team edited the dashboard to show the valid target? That network table entry be exactly the same as you will want to use in your LabView program. You may want to open up the dashboard in Labview to edit and check the actual name that was used on the dashboard.
No we have not edited the default dashboard. When we hit the tab for Variables you get the listing of all network variables. I attached a copy of that portion of the dashboard above along with our code snippet. When the code is running the hasTarget variable will change from True to False as we move the camera. The front panel on LabVIEW however does not display the change in status.
We had used Limelight on other bot, and were trying to apply same logic using the photonvision. There isn’t any documentation that we can find on using photonvision in LabVIEW. It appears to us that the data, from the Raspberry and camera is in the Network table as it changes based upon camera position, but we are having trouble pulling it from the table back into LabVIEW for the robot code.
Not sure,. but from the docs it looks like maybe only use the nickname for the table.
If this does not work, STRONGLY suggest contacting them via the discord server
To close loop:
The naming function of /photonvision/Cam/hasTarget does work to get information from network table back into the program. In addition we were able to utilize /photonvision/Cam/ to access all other information from the RasperryPi running photovision. We deleted the existing read NT block and replaced with same block from the Library and it was successful. Thanks for assistance.