A ROS 2 camera driver using Video4Linux2 For Canlab (V4L2).
Requirements:
- CANLAB CLEB-G-Series (GUIDE)
- CANLAB CLV-G-Series (GUIDE)
- CANLAB CLMU-G-Series (GUIDE)
- ROS 2 Foxy
If you need to modify the code or ensure you have the latest update you will need to clone this repo then build the package.
$ mkdir -p ~/ros_v4l2_camera/src
$ cd ~/ros_v4l2_camera/src
$ git clone --branch foxy https://github.com/canlab-co/ros_v4l2_camera.git
$ cd ~/ros_v4l2_camera
$ colcon build
$ source ~/ros_v4l2_camera/install/setup.bash
Publish camera images, using the default parameters:
# launch the v4l2_camera executable
CLEB-G-01A : ros2 launch v4l2_camera v4l2_camera_cleb_launch.py
CLV-G-01A : ros2 launch v4l2_camera v4l2_camera_clv_launch.py
CLMU-G-01A : ros2 launch v4l2_camera v4l2_camera_clmu_launch.py
# run the executable with default settings:
1CH : ros2 run v4l2_camera v4l2_camera_node (default : /dev/video0)
Preview the image (open another terminal):
ros2 run rqt_image_view rqt_image_view
For better image transport performance over DDS, we recommend using FastDDS with Shared Memory Transport enabled.
First copy the the fastdds.xml
config file to a suitable directory, eg. $HOME/fastdds.xml
cd ~/ros_v4l2_camera
cp fastdds.xml ~/
Next add these two lines to your ~/.bashrc
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
export FASTRTPS_DEFAULT_PROFILES_FILE=$HOME/fastdds.xml
Make sure to source ~/.bashrc
first on all terminals before launching any ROS 2 nodes including the driver.
The v4l2_camera_node
interfaces with standard V4L2 devices and
publishes images as sensor_msgs/Image
messages.
-
/image_raw
-sensor_msgs/Image
The image.
-
video_device
-string
, default:"/dev/video0"
The device the camera is on.
-
pixel_format
-string
, default:"UYVY"
The pixel format to request from the camera. Must be a valid four character 'FOURCC' code supported by V4L2 and by your camera. The node outputs the available formats supported by your camera when started.
Currently supported:"UYVY"
-
output_encoding
-string
, default:"yuv422"
The encoding to use for the output image.
Currently supported:"rgb8", "rgba8", "bgr8", "bgra8", "mono16", "yuv422"
.
Defaults to yuv422. Note that encodings other than yuv422 incurs conversion overhead. -
image_size
-integer_array
, default:[1920, 1080]
Width and height of the image.
-
Camera Control Parameters
Not Support