A ROS 2 camera driver using Video4Linux2 (V4L2).
image_transport- makes it possible to set up compressed transport of the images, as described below.
The ROS 2 port of
image_commonrepository is needed inside of your workspace:
git clone --branch ros2 https://github.com/ros-perception/image_common.git src/image_common
image_transportonly supports raw transport by default and needs additional plugins to actually provide compression; see below how to do this.
v4l2_camera_node interfaces with standard V4L2 devices and
publishes images as
The device the camera is on.
The encoding to use for the output image. Currently supported: "rgb8" or "yuv422".
Width and height of the image.
Camera Control Parameters
Camera controls, such as brightness, contrast, white balance, etc, are automatically made available as parameters. The driver node enumerates all controls, and creates a parameter for each, with the corresponding value type. The parameter name is derived from the control name reported by the camera driver, made lower case, commas removed, and spaces replaced by underscores. So
White Balance, Automaticbecomes
image_transport only supports raw transfer, plugins are
required to enable compression. Standard ones are available in the
repository. These depend on the OpenCV facilities provided by the
vision_opencv repository. You can clone these into your workspace to
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
The following packages are required to be able to build the plugins:
sudo apt install libtheora-dev libogg-dev libboost-python-dev
To get the plugins compiled on Arch Linux, a few special steps are needed:
- Arch provides OpenCV 4.x, but OpenCV 3.x is required
- Arch provides VTK 8.2, but VTK 8.1 is required
boost-pythonis used, which needs to be linked to python libs explicitly:
colcon build --symlink-install --packages-select cv_bridge --cmake-args "-DCMAKE_CXX_STANDARD_LIBRARIES=-lpython3.7m"
If the compression plugins are compiled and installed in the current
workspace, they will be automatically used by the driver and an
/image_raw/compressed topic will be available.
Neither Rviz2 or
image_transport (yet). Therefore, to
be able to view the compressed topic, it needs to be republished
image_transport comes with the
republish node to do
ros2 run image_transport republish compressed in/compressed:=image_raw/compressed raw out:=image_raw/uncompressed
The parameters mean:
compressed- the transport to use for input, in this case 'compressed'. Alternative:
raw, to republish the raw
in/compressed:=image_raw/compressed- by default,
republishuses the topics
in/compressedfor example if the input transport is 'compressed'. This parameter is a ROS remapping rule to map those names to the actual topic to use.
raw- the transport to use for output. If omitted, all available transports are provided.
out:=image_raw/uncompressed- remapping of the output topic.