We have our main robot code written in Java and can simulate it on the laptop. We’d like to add the PhotonVision to our simulation so we can test the pipeline from recognizing AprilTags to motor voltage commands without having the RoboRio plugged in.
Is this possible? We tried plugging the laptop and PhotonVision into a switch and we can see PhotonVision’s dashboard from the laptop at photonvision.local:5800, but we aren’t seeing anything come up on the NetworkTable in the simulation.
We are currently in the process of completely rewriting our simulation infrastructure to better support AprilTags. I recommend looking at our AprilTag example code documentation page on how to view things in simulation in the way you’re talking about (there are some things you have to set in Robot.java).
That’s going to be useful and I’ll work with the team on taking advantage of it. What I meant by “simulation” in this case was using PhotonVision (a real instance running on live Pi hardware) without the RoboRio (i.e. the robot code running on just the laptop). I’d have expected that to “just work” (i.e. one of the two software stacks should be able to find the NetworkTables server of the other one), but it doesn’t seem to.
It doesn’t look like PhotonVision has an option to set an actual IP address instead of a team number for the NetworkTables server, which is what you’d need to run the simulated robot as a server and PhotonVision as a client to it (you’d plug your computer IP into PhotonVision).
Since you can run PhotonVision in server mode, you could set up the robot program to run as a client instead of as a server–it requires stopping and running startClient4 and setServer to the PhotonVision IP on the default instance. In this mode, other dashboards won’t be able to talk to the robot code though, so they would also need to be set up to connect to the PV IP.
You should just be able to set your coprocessor IP here and it should just work. What issues are you running into? (note that you have to run your code in simulation for this to be happening).
We were attempting to sanity-check the data on the NetworkTables by running our robot code in simulation without doing anything related to PhotonLib with it, then opening Shuffleboard to view the data we expected PhotonVision to be putting on the NetworkTables. That did not work (and I think it’s because of our fundamental understanding of how the client / server model on NetworkTables works coupled with the inability to set another IP address for PhotonVision to use when seeking out the NetworkTables server).
These insights should have us oriented and we can move forward from there; I think I’ll recommend to the team that they set up enough of PhotonLib to proxy the info from the pipeline through to the NetworkTable under names we choose (we’ll need to do that anyway because we’re planning to run multiple Raspberry Pis on the final robot).
Are these links out of date? I am getting a page not found when trying to access them. I think I am trying to do the same thing as the individual here.
RaspberryPi - connected to home network and running PhotonVision. I can successfully access the PhotonVision UI via a browser on the laptop, can detect AprilTag targets, etc. I set the team name but it always says that it is not connected to a robot (I guess it can’t find a running instance of the networktables).
WPILIib Visual Studio running on laptop
Trying to download some standard Robot example code project from WPILib
Added the photonLib via “Manage vendor Libraries” per the instructions
Adding the PhotonCamera object into the code and getLatestResult.
Trying to debug the code to see the results from the camera and start coding around it.
I don’t have access to the RoboRIO at home.
So, am I understanding that the network tables typically run only on the RoboRIO? And is it right that photonVision is programmed to find the network tables by simply having the team name and then assuming that the roboRio network always runs in the same way and that the RasberryPi should be connected to the RoboRio in a standard way? So, it is impossible to setup photonVision to find a simulated robot NetworkTables on a laptop on the same network? So, I have to turn on the network tables on the RaspberryPi (photonVision ui) via the settings page and then change something in the VisualStudio (laptop running) code to connect to that* IP for the network tables? Where do I set that? Again, I think the links above aren’t working.
I tried to create a NetworkTableInstance and set the server and pass that into the PhotonCamera constructor (NetworkTableInstance, CameraName). That didn’t work either.
So, from what I am understanding, there is no way to have PhotonVision running on a RaspberryPi connect to a network table that is running on a laptop on the same network. Is that right? I am obviously confused on how to get most code running in a test setup way so I can write a lot of the code without direct access to the RoboRIO.
Feel free to refer me to videos or other things I should read. I have gone through all of the photonVision docs but maybe I am missing some other basic documentation to absorb?
Well, I had given up frankly. I had taken everything apart and put it away. And then I thought that I would post an issue on the github. Like a somewhat responsible developer, I searched the github page directly and I found out that they actually pushed a pull request which now allows you to enter in PhotonVision the hostname or IP address of the remote network tables.
Even after flashing the most recent beta version, I still wasn’t able to see this option in the UI. Not sure if my browser was caching pages or what. I exported the settings and then for some reason it DID pop up.
So, I used the WPILib command to turn on Desktop Support and then I also ran “Simulate Robot” command.
When given two options, I choose the SIM Gui:
And then I was able to see the Network Tables and data was streaming to it. I also saw in the PhotonVision UI that it was connected.
MAN! What A LONG painful experience for honestly a fairly simple solution in the end.
I truly hope that at least my post helps someone else get up and running in a shorter timeframe.
So, in short PhotonVision DOES support running NetworkTables remotely now and running it on a laptop (VisualStudio Code Simulating Robot Code). This makes it SO much easier to test out some code without a RoboRIO nearby. Then when you take the RasberryPi back to where the RoboRIO is at, I assume that you would only have to change the setting back from the IP address or hostname back to a TEAM number and then it will automatically connect to the right NetworkTables and you are up and running while connected to the robot.
The site only lets me (a new user) post one image per reply so I will post subsequent replies with my other screen shots.