Welcome to RDK S100(P) Board repository
2.8 Using USB Camera
Using USB Camera
Using USB Camera1. Environment Preparation2.Execution MethodUsage instructions (default usb_pixel_format is mjpeg)3. Expected Results
To achieve environmental awareness capabilities, robotic products typically include cameras to acquire image information. USB cameras are easy to obtain, convenient to use, and highly versatile. TogetheROS.Bot adds support for USB cameras and supports standard ROS2 image messages.
Note:
To run this section, you need to first learn the TogetheROS.Bot vision application chapter and install the TROS environment.
1. Environment Preparation
- Connect the power supply.
- Connect the USB camera to the development board and ensure that the
/dev/video8device node is created. - Connect the development board to the monitor using an HDMI cable.
- Log in to the RDK S100(P) via MobaXterm or other SSH tools.
- Confirm that your USB camera is working correctly and connect it to the RDK's USB slot.
- The RDK has been flashed with the Ubuntu 20.04/Ubuntu 22.04 system image.
- tros.b has been successfully installed on the RDK.
- Confirm that your PC can access the RDK via the network.
2.Execution Method
Usage instructions (default usb_pixel_format is mjpeg)
Log in to RDK via SSH and confirm the USB camera device name (e.g.,
/dev/video0).Then, start the USB camera using the following command.
x
# Configure the tros.b environmentsource /opt/tros/humble/setup.bashx
# Launch method:ros2 launch hobot_usb_cam hobot_usb_cam.launch.py usb_video_device:=/dev/video0If the program outputs the following information, it means the node has started successfully.
xxxxxxxxxx[INFO] [launch]: All log files can be found below /root/.ros/log/2024-01-18-19-44-39-419588-ubuntu-3951[INFO] [launch]: Default logging verbosity is set to INFO[INFO] [hobot_usb_cam-1]: process started with pid [3953][hobot_usb_cam-1] [WARN] [1705578280.808870437] [hobot_usb_cam]: framerate: 30[hobot_usb_cam-1] [WARN] [1705578280.809851560] [hobot_usb_cam]: pixel_format_name: mjpeg[hobot_usb_cam-1] [WARN] [1705578280.936697507] [hobot_usb_cam]: This devices supproted formats:[hobot_usb_cam-1] [WARN] [1705578280.936858791] [hobot_usb_cam]: Motion-JPEG: 640 x 480 (30 Hz)[hobot_usb_cam-1] [WARN] [1705578280.936912830] [hobot_usb_cam]: Motion-JPEG: 1920 x 1080 (30 Hz)[hobot_usb_cam-1] [WARN] [1705578280.936960328] [hobot_usb_cam]: Motion-JPEG: 320 x 240 (30 Hz)[hobot_usb_cam-1] [WARN] [1705578280.937007285] [hobot_usb_cam]: Motion-JPEG: 800 x 600 (30 Hz)[hobot_usb_cam-1] [WARN] [1705578280.937053241] [hobot_usb_cam]: Motion-JPEG: 1280 x 720 (30 Hz)[hobot_usb_cam-1] [WARN] [1705578280.937098906] [hobot_usb_cam]: Motion-JPEG: 1024 x 576 (30 Hz)[hobot_usb_cam-1] [WARN] [1705578280.937144528] [hobot_usb_cam]: YUYV 4:2:2: 640 x 480 (30 Hz)[hobot_usb_cam-1] [WARN] [1705578280.937190068] [hobot_usb_cam]: YUYV 4:2:2: 1920 x 1080 (5 Hz)[hobot_usb_cam-1] [WARN] [1705578280.937235858] [hobot_usb_cam]: YUYV 4:2:2: 320 x 240 (30 Hz)[hobot_usb_cam-1] [WARN] [1705578280.937282064] [hobot_usb_cam]: YUYV 4:2:2: 800 x 600 (20 Hz)[hobot_usb_cam-1] [WARN] [1705578280.937328020] [hobot_usb_cam]: YUYV 4:2:2: 1280 x 720 (10 Hz)[hobot_usb_cam-1] [WARN] [1705578280.937373518] [hobot_usb_cam]:
3. Expected Results
View the USB camera image on the web interface; open another terminal:
xxxxxxxxxx# Configure the tros.b environmentsource /opt/tros/humble/setup.bashxxxxxxxxxx# Start the websocketros2 launch websocket websocket.launch.py websocket_image_topic:=/image websocket_only_show_image:=trueOn your PC, open a web browser (Chrome/Firefox/Edge), enter IP:8000 (where IP is the RDK's IP address), and click on the "Web Display" option in the upper left corner to view the live feed from the USB camera.
