ROS 2 - ZED Mono Node

Open in ClaudeOpen in ChatGPT

The easiest way to start a ZED ROS 2 node for a monocular camera is by using the command line:

$ros2 launch zed_wrapper zed_camera.launch.py camera_model:=<camera model>

where <camera model> must be replaced with one of zedxonegs or zedxone4k.

Published Topics

The ZED node publishes data to the following topics:

  • Status

    • ~/status/heartbeat: heartbeat signal to monitor if the node is alive from other nodes (custom message).
    • ~/status/svo: status of the SVO playback (only advertised when an SVO file is used as input).
  • Image streams

    The image topic names are created using the following naming convention: ~/<sensor_type>/<color_model>/<rect_type>/image

    Starting from version 5.1.0 of the ROS 2 Wrapper the new convention replaces the previous formats such as ~/<sensor_type>/image_<rect_type>_<color_model> and ~/<sensor_type>_<rect_type>/image_<rect_type>_<color_model> (e.g., ~/left/image_rect_color, ~/rgb_raw/image_raw_gray). Please update your launch files and scripts to use the new topic names.

    • RGB channel
      • ~/rgb/color/rect/image: Color rectified image.
      • ~/rgb/color/rect/camera_info: Color camera calibration data.
      • ~/rgb/gray/rect/image: Grayscale rectified image.
      • ~/rgb/gray/rect/camera_info: Grayscale camera calibration data.
      • ~/rgb/color/raw/image: Color unrectified image.
      • ~/rgb/color/raw/camera_info: Color raw calibration data.
      • ~/rgb/gray/raw/image: Grayscale unrectified image.
      • ~/rgb/gray/raw/camera_info: Grayscale raw calibration data.
  • Sensors data

    • ~/imu/data
    • ~/imu/data_raw
    • ~/temperature
    • ~/left_cam_imu_transform

Image Transport

The ROS 2 wrapper supports the stack image_transport introduced with ROS 2 Crystal Clemmys.

Starting from version 5.3 of the ROS 2 Wrapper, image messages are published through rclcpp::TypeAdapter for more efficient handling:

  • The base raw topic is handled by a TypeAdapter publisher. Intra-process subscribers (e.g., other nodes running in the same component container) receive a StampedSlMat object — a wrapper around the native sl::Mat — directly, without any serialization overhead. Inter-process subscribers transparently receive a standard sensor_msgs/msg/Image message thanks to the automatic TypeAdapter conversion.
  • The transport-specific variants are handled by an image_transport publisher. Its raw transport is disabled to avoid publishing duplicate messages, since the raw stream is already provided by the TypeAdapter publisher described above.

To prevent silent data corruption caused by incompatible plugin/encoding combinations, the advertised image transports are filtered by topic type. Visual image topics (color and grayscale images) advertise only:

  • compressed: JPEG or PNG compressed image
  • theora: Ogg Theora compressed image
  • zstd: lossless Zstandard-compressed image (available starting with ROS 2 Jazzy Jalisco)

For proper association between images and their corresponding camera information, the ZED ROS 2 Wrapper also publishes camera_info topics for all compressed image streams:

  • ~/rgb/color/rect/image/camera_info
  • ~/rgb/gray/rect/image/camera_info
  • ~/rgb/color/raw/image/camera_info
  • ~/rgb/gray/raw/image/camera_info

When the isaac_ros_nitros package is installed and NITROS is not disabled via the debug.disable_nitros parameter, NITROS publishers take priority and neither the TypeAdapter nor the image_transport publishers are created. Please refer to the dedicated section about NVIDIA® Isaac ROS Nitros for more details.

NVIDIA® Isaac ROS Nitros

The ZED ROS 2 Wrapper supports the NVIDIA® Isaac™ ROS Nitros package for zero-copy transport of ROS messages using NVIDIA® GPUDirect® RDMA.

NVIDIA® Isaac ROS Nitros integration is enabled and used only if the required packages are manually installed. They are not added as a dependency because this is an optional feature.

Starting from version 5.3 of the ROS 2 Wrapper, Intra-Process Communication (IPC) is handled automatically: it is disabled when NITROS is enabled and enabled when NITROS is disabled. You can use the debug.disable_nitros parameter to disable NITROS and force IPC to be enabled if needed.

For more information about the installation and usage of the NVIDIA® Isaac™ ROS packages, please refer to the dedicated section of the documentation: ZED Isaac™ ROS Integration Overview.

QoS profiles

All the topics are configured by default to use the following ROS 2 QoS profile:

  • Reliability: RELIABLE
  • History (Depth): KEEP_LAST (10)
  • Durability: VOLATILE
  • Lifespan: Infinite
  • Deadline: Infinite
  • Liveliness: AUTOMATIC
  • Liveliness lease duration: Infinite

Read the official ROS 2 documentation about the QoS and the related settings for details.

The QoS settings can be modified by changing the relative parameters in the YAML files, as described in this official ROS 2 design document.

When creating a subscriber, be sure to use a compatible QOS profile according to the following tables:

Compatibility of QoS durability profiles:

PublisherSubscriberConnectionResult
VolatileVolatileYesVolatile
VolatileTransient localNo-
Transient localVolatileYesVolatile
Transient localTransient localYesTransient local

Compatibility of QoS reliability profiles:

PublisherSubscriberConnectionResult
Best effortBest effortYesBest effort
Best effortReliableNo-
ReliableBest effortYesBest effort
ReliableReliableYesReliable

In order for a connection to be made, all of the policies that affect compatibility must be compatible. For instance, if a publisher-subscriber pair has compatible reliability QoS profiles, but incompatible durability QoS profiles, the connection will not be made.

For a detailed list of all the compatibility settings, please refer to the official ROS 2 documentation.

Configuration parameters

Specify your launch parameters in the common_mono.yaml, zedxonegs.yaml, and zedxone4k.yaml files available in the folder zed_wrapper/config.

General parameters

Namespace: general

common_mono.yaml

ParameterDescriptionValue
serial_numberSelect a ZED camera by its Serial Numberint
pub_resolutionThe resolution used for output. ‘NATIVE’ to use the same general.grab_resolution - CUSTOM to apply the general.pub_downscale_factor downscale factor to reduce bandwidth in transmissionstring, ‘NATIVE’, ‘CUSTOM’
pub_downscale_factorRescale factor used to rescale image before publishing when ‘pub_resolution’ is ‘CUSTOM’double
gpu_idSelect a GPU device for image processingint
optional_opencv_calibration_fileOptional path where the ZED SDK can find a file containing the calibration information of the camera computed with OpenCV.string
publish_statusEnable publishing of the node status topicstrue, false

zedxonegs.yaml, and zedxone4k.yaml

ParameterDescriptionValue
camera_modelType of StereoLabs camerastring, zedxonegs, zedxone4k
camera_nameUser name for the camera, can be different from camera modelstring
grab_resolutionThe native camera grab resolution.string, ‘HD1200’, ‘QHDPLUS’, ‘HD1080’, ‘SVGA’, ‘AUTO’
grab_frame_rateZED SDK internal grabbing rateint, ‘15’,‘30’,‘60’,‘90’,‘100’,‘120’

SVO input parameters

Namespace: svo

common_mono.yaml

ParameterDescriptionValue
svo_pathSpecify SVO filenamestring, Note: relative file paths are not allowed
svo_encoding_preset[ZED SDK >= 5.3] SVO encoder speed/quality preset used by the start_svo_rec servicestring, ‘DEFAULT’, ‘ULTRAFAST’, ‘FAST’, ‘MEDIUM’, ‘SLOW’
decryption_key[ZED SDK >= 5.3] Optional decryption key/passphrase used when opening encrypted SVO filesstring
use_svo_timestampsUse the SVO timestamps to publish data. If false, data will be published at the system timetrue, false
publish_svo_clockWhen use_svo_timestamps is true allows you to publish the SVO clock to the /clock topic. This is useful for synchronous rosbag playbacktrue, false
svo_loopRestart the SVO if the end of the file is reachedtrue, false
svo_realtimeif true SVO will be played trying to respect the original framerate eventually skipping frames, otherwise every frame will be processedtrue, false
play_from_frameStart playing the SVO from a specific frame IDint

Streaming server parameters

Namespace: stream_server

common_mono.yaml

ParameterDescriptionValue
stream_enabledenable the streaming server when the camera is opentrue, false
codecDifferent encoding types for image streaming: ‘H264’, ‘H265’string
portPort used for streaming. Port must be an even number. Any odd number will be rejected.int
bitrateStreaming bitrate (in Kbits/s) used for streaming. See docint, [1000 - 60000]
gop_sizeThe GOP size determines the maximum distance between IDR/I-frames. Very high GOP size will result in slightly more efficient compression, especially on static scenes. But latency will increase.int, [max 256]
adaptative_bitrateBitrate will be adjusted depending on the number of packets dropped during streaming. If activated, the bitrate can vary between [bitrate/4, bitrate].true, false
chunk_sizeStream buffers are divided into X number of chunks where each chunk is chunk_size bytes long. You can lower chunk_size value if network generates a lot of packet lost: this will generate more chunks for a single image, but each chunk sent will be lighter to avoid inside-chunk corruption. Increasing this value can decrease latency.int, [1024 - 65000]
target_framerateFramerate for the streaming output. This framerate must be below or equal to the camera framerate. Allowed framerates are 15, 30, 60 or 100 if possible. Any other values will be discarded and camera FPS will be taken.int

Video parameters

Namespace: video

common_mono.yaml

ParameterDescriptionValue
saturation*Image saturationint, [0,8]
sharpness*Image sharpnessint, [0,8]
gamma*Image gammaint, [0,8]
auto_whitebalance*Enable the auto white balancetrue, false
whitebalance_temperature*White balance temperatureint [28,65]
auto_exposure*Enable or disable auto exposure control (false: manual, true: auto)true, false
exposure_time*Defines the real exposure time in microseconds. Recommended to control manual exposure (instead of video.exposure setting)int, [28,30000]
auto_exposure_time_range_min*Defines the minimum range of exposure auto control in micro secondsint
auto_exposure_time_range_max*Defines the maximum range of exposure auto control in micro secondsint
exposure_compensation*Defines the Exposure-target compensation made after auto exposure. Reduces the overall illumination target by factor of F-stops.int, [0 - 100]
auto_analog_gain*Enable or disable auto analog gain control (false: manual, true: auto)true, false
analog_gain*Defines the real analog gain (sensor) in mDB. Recommended to control manual sensor gain (instead of video.gain setting)int, [1000-16000].
auto_analog_gain_range_min*Defines the minimum range of sensor gain in automatic controlint
auto_analog_gain_range_max*Defines the maximum range of sensor gain in automatic controlint
auto_digital_gain*Enable or disable auto digital gain control (false: manual, true: auto)true, false
digital_gain*Defines the real digital gain (ISP) as a factor. Recommended to control manual ISP gain (instead of video.gain setting)int, [1-256]
auto_digital_gain_range_min*Defines the minimum range of digital ISP gain in automatic controlint
auto_digital_gain_range_max*Defines the maximum range of digital ISP gain in automatic controlint
denoising*Defines the level of denoising applied on both left and right imagesint, [0-100]
ae_antibanding*[ZED SDK >= 5.3] Auto-exposure anti-banding modeint, 0=OFF, 1=AUTO, 2=50Hz, 3=60Hz
enable_24bit_outputEnable BGR 24-bit output for images (instead of 32-bit)true, false
publish_rgbEnable publishing of RGB image streamstrue, false
publish_rawEnable publishing of raw (unrectified) image streamstrue, false
publish_grayEnable publishing of grayscale image streamstrue, false

* Dynamic parameter

zedxone4k.yaml

ParameterDescriptionValue
enable_hdrWhen set to true, the camera will be set in HDR mode if the camera model and resolution allows ittrue, false

Sensors parameters

Namespace: sensors

common_mono.yaml

ParameterDescriptionValue
publish_imu_tfEnable/disable the IMU TF broadcastingtrue, false
sensors_pub_rate*Frequency of publishing of sensors datadouble
publish_imuAdvertise the IMU topic that is published only if a node subscribes to ittrue, false
publish_imu_rawAdvertise the raw IMU topic that is published only if a node subscribes to ittrue, false
publish_cam_imu_transfAdvertise the CAMERA-IMU transformation topic that is published only if a node subscribes to ittrue, false
publish_tempAdvertise the temperature topics that are published only if a node subscribes to themtrue, false

* Dynamic parameter

Advanced parameters

Namespace: advanced

These are advanced threading parameters. Do not modify them unless you are confident of what you are doing. The SCHED_FIFO and SCHED_RR scheduling policies require running with sudo. Reference: sched(7).

common_mono.yaml

ParameterDescriptionValue
thread_sched_policyThread scheduling policystring, ‘SCHED_OTHER’, ‘SCHED_BATCH’, ‘SCHED_FIFO’, ‘SCHED_RR’
thread_grab_priorityPriority of the grab thread (only with ‘SCHED_FIFO’ and ‘SCHED_RR’)int, [1 (LOW) - 99 (HIGH)]
thread_sensor_priorityPriority of the sensors thread (only with ‘SCHED_FIFO’ and ‘SCHED_RR’)int, [1 (LOW) - 99 (HIGH)]

Debug parameters

Namespace: debug

common_mono.yaml

ParameterDescriptionValue
sdk_verboseSet the verbose level of the ZED SDKint, 0 -> disable
sdk_verbose_log_filePath to the file where the ZED SDK will log its messages. If empty, no file will be created. The log level can be set using the sdk_verbose parameter.string
use_pub_timestampsUse the current ROS time for the message timestamp instead of the camera timestamp. This is useful to test data communication latency.true, false
sdk_use_monotonic_clock[ZED SDK >= 5.3] Use MONOTONIC_CLOCK so SDK timestamps are immune to host clock steps (NTP/PTP). Process-wide; the first node in a composition winstrue, false
debug_commonEnable general debug log outputstrue, false
debug_dyn_paramsEnable dynamic parameters update debug log outputstrue, false
debug_video_depthEnable video debug log outputstrue, false
debug_camera_controlsEnable camera controls debug log outputstrue, false
debug_sensorsEnable sensors debug log outputstrue, false
debug_streamingEnable streaming debug log outputstrue, false
debug_advancedEnable advanced debug log outputstrue, false
debug_nitrosEnable Nitros debug log outputstrue, false
disable_nitrosIf available, disable NITROS usage for debugging and testing purposestrue, false

Dynamic parameters

The ZED node lets you reconfigure many parameters dynamically during the execution of the node. All the dynamic parameters are indicated with a * in the list above and with the tag [DYNAMIC] in the comments of the YAML files.

You can set the parameters using the CLI command ros2 param set, e.g.:

$ros2 param set /zed/zed_node video.exposure_time 5000

if the parameter is set successfully, you will get a confirmation message:

$Set parameter successful

In the case you tried to set a parameter that’s not dynamically reconfigurable, or you specified an invalid value, you will get this type of error:

$ros2 param set /zed/zed_node video.exposure_time 0
$Setting parameter failed: Parameter {video.exposure_time} doesn't comply with integer range.

and the ZED node will report a warning message explaining the error type:

$1538556595.265117561: [zed.zed_node] [WARN] The param 'video.exposure_time' requires an INTEGER value in the valid range

You can also use the Configuration -> Dynamic Reconfigure plugin of the rqt tool to dynamically set parameters by using a graphic interface.

image

Transform frames

The ZED ROS 2 wrapper broadcasts multiple coordinate frames that each provides information about the camera’s position and orientation. If needed, the reference frames can be changed in the launch file.

  • <camera_name>_camera_link is the current position and orientation of the ZED base center. It corresponds to the bottom central fixing hole.
  • <camera_name>_camera_center is the current position and orientation of ZED middle baseline, determined by visual odometry and the tracking module.
  • <camera_name>_camera_frame is the position and orientation of the ZED’s CMOS sensor.
  • <camera_name>_camera_frame_optical is the position and orientation of the ZED’s camera optical frame.
  • <camera_name>_imu_link is the origin of the inertial data frame (not available with ZED).

Frames

Services

The ZED node provides the following services:

  • ~/enable_streaming: enable/disable a local streaming server.

Services can be called using the rqt graphical tool by enabling the plugin Plugins -> Services -> Service caller.

It is possible to call a service also by using the CLI command ros2 service call.

For example, to start the local streaming server:

$ros2 service call /zed/zed_node/enable_streaming std_srvs/srv/SetBool "{data: True}"

and the service server will reply:

$requester: making request: std_srvs.srv.SetBool_Request(data=True)
$
$response:
$std_srvs.srv.SetBool_Response(success=True, message='Streaming Server started')

Assigning a GPU to a camera

To improve performance, you can specify the gpu_id of the graphic card that will be used for the depth computation in the common_mono.yaml configuration file. The default value (-1) will select the GPU with the highest number of CUDA cores. When using multiple ZEDs, you can assign each camera to a GPU to increase performance.