tier4 / ros2_v4l2_camera

Forked from https://gitlab.com/boldhearts/ros2_v4l2_camera
Apache License 2.0
39 stars 14 forks source link

v4l2_camera

A ROS 2 camera driver using Video4Linux2 (V4L2).

Installation

This article details how to build and run this package. It focuses on Raspberry Pi OS with the Raspberry Pi Camera Module V2 but should generalise for most systems.

Building from source

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.

$ git clone --branch galactic https://github.com/tier4/ros2_v4l2_camera.git
$ colcon build

Most users will also want to set up compressed transport using the dependencies below.

Usage

Publish camera images, using the default parameters:

    ros2 run v4l2_camera v4l2_camera_node

Preview the image (open another terminal):

    ros2 run rqt_image_view rqt_image_view

Dependencies

Nodes

v4l2_camera_node

The v4l2_camera_node interfaces with standard V4L2 devices and publishes images as sensor_msgs/Image messages.

Published Topics

Parameters

Compressed Transport

By default image_transport only supports raw transfer, plugins are required to enable compression. Standard ones are available in the image_transport_plugins repository. These depend on the OpenCV facilities provided by the vision_opencv repository. You can clone these into your workspace to get these:

cd path/to/workspace
git clone https://github.com/ros-perception/vision_opencv.git --branch ros2 src/vision_opencv
git clone https://github.com/ros-perception/image_transport_plugins.git --branch ros2 src/image_transport_plugins

Building: Ubuntu

The following packages are required to be able to build the plugins:

sudo apt install libtheora-dev libogg-dev libboost-python-dev

Building: Arch

To get the plugins compiled on Arch Linux, a few special steps are needed:

Usage

If the compression plugins are compiled and installed in the current workspace, they will be automatically used by the driver and an additional /image_raw/compressed topic will be available.

Neither Rviz2 or showimage use image_transport (yet). Therefore, to be able to view the compressed topic, it needs to be republished uncompressed. image_transport comes with the republish node to do this:

ros2 run image_transport republish compressed in/compressed:=image_raw/compressed raw out:=image_raw/uncompressed

The parameters mean: