WPILibPi Romi: Networking Table & Camera Server Issues

Having issues using both Network Tables and Camera Server and wondering if anyone has gotten it to work on the Romi or if support for it is still work in progress. I saw some talk on WPILib on a PI + Romi? - Programming - Chief Delphi about using cameras but figured I would create a separate topic for things people are doing to expand the Romi from the basics (onboard DIO, drivetrain, encoders, gyro) to more advance integration with the rpi.

Network Tables: My initial thought around using network tables is to use it as a way to communicate sensor information for misc sensors and CV2 vision programs (seems like the best way since the RPI gpio outputs are 3.3v and Romi inputs are 5v, same issue as with the Roborio).

I’m getting an error when using the default vision application Built-in multi-camera streaming and can see multiple attempts to connect to the network tables port with this error:

NT: ERROR: select() to 10.0.0.2 port 1735 error 111 - Connection refused (TCPConnector.cpp:175)

I have tried changing the ipv4 address and team numbers to match (10.0.0.2 with team number 0 and 10.72.72.2 with team number 7272) but that results in the same. I can see the error message change

Camera Server: I am trying to start with a basic camera server and have it show in the smart dashboard. Usually this only requires one line of code to call startAutomaticCapture. I have tried a few ways and can’t get the camera feed to carry through from the rpi to the robot + smart dashboard.

CameraServer.getInstance().startAutomaticCapture(); //Should not work because the default name is "USB Camera 0"
CameraServer.getInstance().startAutomaticCapture("rPi Camera ", 0); //Use name that matches the output when starting the vision service
CameraServer.getInstance().startAutomaticCapture("rPi Camera 0", "/dev/video0"); //try using the name and video device path

All of these result in a camera instance created in the network tables & smart dashboard. But with a black screen. I can see the camera is working on the rpi at http://wpilibpi.local:1181/ but the camera stream listed within the network table settings has a black image.

I assume that the issues are related to some networking or communication issue or some step missing.

The Romi setup for this is a bit different than a normal FRC robot, primarily because the Romi code is running on the desktop, not the Raspberry Pi. This means that any CameraServer code you add to your robot program is going to pick up the USB cameras connected to your desktop computer, and not USB cameras on the Romi itself.

The 2021.2.1 Romi image fixes the default multi-camera streaming to “just work” in the Romi use case. The key is that the vision code running on the rPi needs to connect to the NetworkTables server (the robot program), which in the Romi case is running on your desktop computer. The 2021.2.1 image adds a way for the multi-camera server to discover what the desktop computer IP address is. You don’t need to add anything to your robot program.

4 Likes

Nice! Upgrading to 2021.2.1 solved my issue. I was on 2021.1.1 before. I confirmed that the camera configured on wpilibpi.local is now showing in the smart dashboard. Noted about writing any camera server code, which will connect to cameras on the computer running the simulation software and not what is connected to the romi.

I have also uploaded Romi Vision as the vision program and looks like the network tables issue is resolved, too. I am seeing a 2nd processed video feed from the program and also the network table with the target data.

Thanks for fixing this for us!
Michael

The program finds the IP address of my computer, but doesn’t set up a camera server on Shuffleboard. I get the following error:
NT: connect() to 10.0.0.155 port 1735 timed out

The camera stream is available at 10.0.0.2:1181

I am using the built in camera server on wpilib release 2021.2.1

Any help will be appreciated.

This is with the Sim GUI running on the computer with IP 10.0.0.155?
Is shuffleboard connecting to the NT server?
Most likely in that case this is due to computer firewalls preventing the Pi from connecting to the computer NT server–try turning off the firewall.

There is only one computer on the network, so yes it is running on that computer. This Romi has worked in the past with the same computer settings. Annie has two Romis, one displays images on the shuffleboard and one does not which leads me to believe it is not computer related.
Shuffleboard displays all the other NTs - LiveWindow, FMSInfo, SmardDashboard, Preferences.
I will try disabling the firewall, but I think I have tried this before.

Disabling the firewall made no difference.

If you ssh into the pi, can you ping the computer IP? Can you telnet to port 1735 at the computer IP (from the Pi) and connect?

I can ping the computer IP. Telnet doesn’t seem to be on the pi. I tried to install it, but I am locked out.
pi@wpilibpi(rw):~$ apt-get install telnet
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

You have to use sudo to get root, e.g. sudo apt-get install telnet, but it’s also going to need a network connection to the Internet to get packages.

You can also do a quick test with Python, e.g.

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("10.0.0.155", 1735))
1 Like

telnet unable to connect.
telnet: Unable to connect to remote host: Connection timed out

Just to double-check, did you include the port number? E.g. telnet 10.0.0.155 1735 ?

If this is failing when the robot code is running (e.g. the sim window is open), and you’re able to ping 10.0.0.155, there is definitely something wonky going on with the networking layer.

OK. I tried a different computer and no longer got the port 1735 timeout error, but still no camera server on shuffleboard. It did show the CameraPublisher values in network tables.
I had a ROMI that was never assembled. I assembled it and loaded all fresh software and all worked perfectly - had camera server on shuffleboard!. I tested the existing robot again, but NG.

I reflashed the image on the microSD card and now the existing robot worked on the new computer. I turned off the firewall and now the existing robot works on my desktop. Because evidently there was something curupted on the rPi image, turning off the firewall didn’t fix it yesterday.

Anyway, now I have two computers and two ROMIs working on shuffleboard. Thanks for your help.