USB names won't clear from RoboRio Dashboard

Hello all.

(C++ Project)

We have 2 USB cameras connected to the Rio. While they do show up in the standard dashboard as USB Camera 0 and USB Camera 1 as a result of me putting in the CameraServer commands (which I will put below) I have also have in the network tables a lot of USB Camera XXXXXXXX values that I can’t seem to clear. The effect is that we have numerous cameras that really are not connected anymore but are still selectable. Some of these entries appears to be aliases for the real cameras that are connected.

I have 2 requirements. We need the cameras to consistantly be picked as USB 0 and USB 1 and NEVER swap because the cameras will be looking in two different directions. Bad things will happen if the camera we think is USB 0 becomes 1 etc.

I am fine with using the USB camera’s serial number (which may be where these entries are coming from) if they are consistent and we can programicaly identify which one is which.

But see below what the Variables tab shows. Even after rebooting the rio and PCs running the driver station these entries return. Why are they sticking?

cs::UsbCamera camera =
frc::CameraServer::GetInstance()->StartAutomaticCapture(0);

	camera.SetFPS(30);
	camera.SetResolution(320, 240);

	cs::UsbCamera camera2 =
			frc::CameraServer::GetInstance()->StartAutomaticCapture(1);

	camera.SetFPS(30);
	camera.SetResolution(320, 240);

Nevermind, unless someone knows how to use the camera usb serial number to force each camera to allign with a usb port or not. I solved the mystery cameras, as I had a pc in the other room that I had forgotten that was still running a nt table server. It was likely refeeding the tables back and as a result would not let the data to be forgotten.

but I am still interested in making one camera always be on one usb 0 assignment etc.

Ok foks,
I found a BIG hint in this post

So, in my case when I ssh to the roborio I can navigate and find

image

Therefore, if I can supply this absolute path of these cameras, as suggested in the other post, I should be able to statically assure that the correct camera is associated with the correct function.

That’s correct. Even easier, this year the alternate “absolute” paths are given on the camera stream/settings webpage (roborio-TEAM-frc.local:1181 for the first camera, :1182 for the second, etc). There are two alternate paths provided for each camera. The by-id names are based on the camera make/model. The by-path names are based on USB port numbering.

That would have been why they persisted. Why they were there in the first place was probably that you were calling StartAutomaticCapture() in a loop rather than once during initialization.

Any chance you could supply a code snippet for providing the by-id, I cant seem to figureout how to pass the “string”.

For arguments sake, lets say the camera name I want to call it is " USBCamera 1"
and an id path of…

/dev/v4l/by-id/usb-046d_08c7_5BB71F2F-video-index0

I am trying
cameraonename[50] = “USBCamera 1”;
cameraonepath[256] = “/dev/v4l/by-id/usb-046d_Cisco_VTCamera3_964BE070-video-index0”;

frc::CameraServer::GetInstance()->StartAutomaticCapture($cameraonename,&cameraonepath);

The easiest way is just pass it straight to the function:

frc::CameraServer::GetInstance()->StartAutomaticCapture("USBCamera 1", "/dev/v4l/by-id/usb-046d_Cisco_VTCamera3_964BE070-video-index0");

If you want to keep separate variables:

const char* cameraonename = "UsbCamera 1";
const char* cameraonepath = "/dev/v4l/by-id/usb-046d_Cisco_VTCamera3_964BE070-video-index0";

frc::CameraServer::GetInstance()->StartAutomaticCapture(cameraonename,cameraonepath);

Great stuff

Now that we have a specific camera linked to a specific StartAutomaticCapture, this is now associate a specific cvSink

cs::CvSink cvSink = frc::CameraServer::GetInstance()->GetVideo(“USBCamera 0”);

Many thanks for all your help.

md

Yes, GetVideo() with the same name passed as to StartAutomaticCapture() will get the CvSink for that camera. Note the GetVideo() call must be made after the StartAutomaticCapture() call.