A ROS2 package for publishing camera streams with support for multiple cameras and UITM topics.
cd ~/ros2_ws/src
git clone https://github.com/HelloWorldRobotics/camera_publisher.gitInstall all required dependencies using rosdep:
cd ~/ros2_ws
rosdep install --from-paths src --ignore-src -r -yTo ensure consistent camera device naming, it is convenient to set up UDEV rules for each camera.
Create a new UDEV rules file:
sudo nano /etc/udev/rules.d/99-usb-cameras.rulesTo find the correct UDEV rule for each camera:
- Unplug all USB cameras
- Plug in one camera at a time
- Note the new
/dev/video*device that appears - Run this command to get the camera's ID_PATH:
udevadm info -q property -p $(udevadm info -q path -n /dev/video0) | grep ID_PATH- Create a UDEV rule using this format:
SUBSYSTEM=="video4linux", ENV{ID_PATH}=="pci-0000:03:00.0-usb-0:1.1:1.0", KERNEL=="video*", SYMLINK+="buggy_cam_back"
- Repeat for each camera, using appropriate symlinks:
buggy_cam_frontbuggy_cam_backbuggy_cam_leftbuggy_cam_right
Apply the new rules:
sudo udevadm control --reload-rules
sudo udevadm triggerThe launch file (camera_publisher.launch.py) supports multiple cameras with configurable parameters. If udev rules are not used, the camera device paths must be updated in the launch file. To disable launching a camera, simply comment out the corresponding camera in the return LaunchDescription. Eg:
return LaunchDescription([
back_camera,
left_camera,
right_camera,
#front_camera
])| Parameter | Type | Description |
|---|---|---|
| frame_id | string | TF frame ID for the camera |
| parent_frame_id | string | Parent TF frame ID |
| camera_device | string | Camera device path (e.g., /dev/buggy_cam_back) |
| calibration_file | string | Path to camera calibration YAML file |
| flip_image | bool | Whether to flip the image 180 degrees |
| publish_compressed | bool | Enable compressed image publishing |
| uitm_topics | bool | Enable UITM topic publishing |
| uitm_calibration_file | string | Path to UITM calibration YAML file |
| Topic | Type | Description |
|---|---|---|
~/image/raw |
sensor_msgs/Image | Raw camera image (1280x720) |
~/image/compressed |
sensor_msgs/CompressedImage | JPEG compressed image |
~/camera_info |
sensor_msgs/CameraInfo | Camera calibration information |
| Topic | Type | Description |
|---|---|---|
~/uitm/image/raw |
sensor_msgs/Image | Raw UITM image (640x480) |
~/uitm/image/compressed |
sensor_msgs/CompressedImage | JPEG compressed UITM image |
~/uitm/camera_info |
sensor_msgs/CameraInfo | UITM camera calibration info |
Place your camera calibration files in:
- Main calibration:
config/*.yaml - UITM calibration:
config/uitm/*.yaml
Build with symlink:
cd ~/ros2_ws
colcon build --symlink-install --packages-select camera_publisherSource workspace:
source ~/ros2_ws/install/setup.bashRun the publisher:
ros2 launch camera_publisher camera_publisher.launch.py