-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tool to set a USB Camera Symlink #89
Conversation
This is great to see @hello-fazil! Thanks for creating this. Should the udev rule be backed up to the "~/stretch_user/stretch-xxx-yyyy/udev/" and "/etc/hello-robot/stretch-xxx-yyyy/udev/" directories? |
Yes, It is a good idea. I have updated the code to do the backup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm testing this script with the beta teleop kit cameras. Each of the uvc cameras show up as two devices. For example, the gripper uvc camera shows up as /dev/video6 and /dev/video7. The first is the actual camera that can stream imagery, and the second is purely for metadata and can't stream imagery. The udev rules generated by this script are symlinking to both devices, and so tools like stretch_camera_streams_check.py --usb_cam_port /dev/hello-gripper-camera
don't function properly. Here's the udevadm info for video6 and video7
hello-robot@stretch-re2-2002:~$ udevadm info -n /dev/video6
P: /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1.3/3-2.1.3.1/3-2.1.3.1:1.0/video4linux/video6
N: video6
L: 0
S: hello-gripper-camera
S: v4l/by-path/pci-0000:00:14.0-usb-0:2.1.3.1:1.0-video-index0
S: v4l/by-id/usb-Generic_USB_CAMERA_SN221101003-video-index0
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1.3/3-2.1.3.1/3-2.1.3.1:1.0/video4linux/video6
E: DEVNAME=/dev/video6
E: MAJOR=81
E: MINOR=6
E: SUBSYSTEM=video4linux
E: USEC_INITIALIZED=415284931
E: ID_V4L_VERSION=2
E: ID_V4L_PRODUCT=USB CAMERA: USB CAMERA
E: ID_V4L_CAPABILITIES=:capture:
E: ID_VENDOR=Generic
E: ID_VENDOR_ENC=Generic
E: ID_VENDOR_ID=10bb
E: ID_MODEL=USB_CAMERA
E: ID_MODEL_ENC=USB\x20CAMERA
E: ID_MODEL_ID=2b08
E: ID_REVISION=0001
E: ID_SERIAL=Generic_USB_CAMERA_SN221101003
E: ID_SERIAL_SHORT=SN221101003
E: ID_TYPE=video
E: ID_BUS=usb
E: ID_USB_INTERFACES=:0e0100:0e0200:010100:010200:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=uvcvideo
E: ID_PATH=pci-0000:00:14.0-usb-0:2.1.3.1:1.0
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_2_1_3_1_1_0
E: ID_FOR_SEAT=video4linux-pci-0000_00_14_0-usb-0_2_1_3_1_1_0
E: COLORD_DEVICE=1
E: COLORD_KIND=camera
E: DEVLINKS=/dev/hello-gripper-camera /dev/v4l/by-path/pci-0000:00:14.0-usb-0:2.1.3.1:1.0-video-index0 /dev/v4l/by-id/usb-Generic_USB_CAMERA_SN221101003-video-index0
E: TAGS=:uaccess:snap_chromium_chromium:snap_chromium_chromedriver:seat:
hello-robot@stretch-re2-2002:~$ udevadm info -n /dev/video7
P: /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1.3/3-2.1.3.1/3-2.1.3.1:1.0/video4linux/video7
N: video7
L: 0
S: v4l/by-id/usb-Generic_USB_CAMERA_SN221101003-video-index1
S: hello-gripper-camera
S: v4l/by-path/pci-0000:00:14.0-usb-0:2.1.3.1:1.0-video-index1
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1.3/3-2.1.3.1/3-2.1.3.1:1.0/video4linux/video7
E: DEVNAME=/dev/video7
E: MAJOR=81
E: MINOR=7
E: SUBSYSTEM=video4linux
E: USEC_INITIALIZED=415286839
E: ID_V4L_VERSION=2
E: ID_V4L_PRODUCT=USB CAMERA: USB CAMERA
E: ID_V4L_CAPABILITIES=:
E: ID_VENDOR=Generic
E: ID_VENDOR_ENC=Generic
E: ID_VENDOR_ID=10bb
E: ID_MODEL=USB_CAMERA
E: ID_MODEL_ENC=USB\x20CAMERA
E: ID_MODEL_ID=2b08
E: ID_REVISION=0001
E: ID_SERIAL=Generic_USB_CAMERA_SN221101003
E: ID_SERIAL_SHORT=SN221101003
E: ID_TYPE=video
E: ID_BUS=usb
E: ID_USB_INTERFACES=:0e0100:0e0200:010100:010200:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=uvcvideo
E: ID_PATH=pci-0000:00:14.0-usb-0:2.1.3.1:1.0
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_2_1_3_1_1_0
E: ID_FOR_SEAT=video4linux-pci-0000_00_14_0-usb-0_2_1_3_1_1_0
E: COLORD_DEVICE=1
E: COLORD_KIND=camera
E: DEVLINKS=/dev/v4l/by-id/usb-Generic_USB_CAMERA_SN221101003-video-index1 /dev/hello-gripper-camera /dev/v4l/by-path/pci-0000:00:14.0-usb-0:2.1.3.1:1.0-video-index1
E: TAGS=:snap_chromium_chromium:seat:uaccess:snap_chromium_chromedriver:
It seems like INDEX is one attribute the udev rule can use to select between the two video devices. https://unix.stackexchange.com/a/581838
To fix this PR, the udev rules will need to be able to symlink to the first device instead of both of them.
UVC Cameras, such as the cameras from the Beta Teleop Kit, or popular webcams, appear as two devices in the /dev/ folder. For example, the gripper uvc camera from the teleop kit appears as /dev/video6 and /dev/video7. The first is usually a capture device and can stream imagery, and the second is usually purely for metadata and cannot stream imagery. Therefore, it's very important that UVC camera UDEV rules trigger on the first device. The critical attribute differentiating these two devices is called ID_V4L_CAPABILITIES, where video4linux seems to recognize which device can actually stream imagery and marks it as "capture:". In this commit, we use this attribute to trigger the UDEV rules on the correct device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the fix in commit 0a700ce, the two video ports issue is solved. This PR is ready to merge.
This PR adds the new tool REx_camera_set_symlink.py that allows the user create a USB symlink to any USB camera that is plugged into the robot. The symlink is assigned by generating an Udev rule that records the following USB attributes of the plugged in camera
[idVendor,idProduct,serial]
.Example Usage:
By addressing a camera port:
By addressing a camera's name pattern: