How to Configure ROS2 with Cyclone DDS for Ouster Lidar

How to Configure ROS2 with Cyclone DDS for Ouster Lidar

Introduction

Many ROS 2 users working with Ouster lidar sensors encounter an issue where they can only achieve a 5Hz point cloud update rate, even though the sensor is capable of 10Hz (as frequently reported in Ouster support tickets). This problem is often related to the default DDS (Data Distribution Service) implementation used in ROS 2. Switching to Cyclone DDS can improve performance and resolve this bottleneck, allowing users to achieve the full 10Hz point cloud data rate.

Note: By default, ROS 2 uses eProsima’s Fast DDS. Fast DDS imposes strict resource limits for large messages (e.g., max_message_size, history_memory_policy, max_samples_per_instance). Without manual tuning, Fast DDS may throttle or drop large PointCloud2 messages, causing a reduced update rate.

This document guides you through configuring ROS 2 to use Cyclone DDS, avoiding the need for time-consuming fine-tuning of Fast DDS.

Understanding the Issue

ROS 2 relies on DDS as the middleware for communication between nodes.
The default DDS implementation (Fast DDS) may not always be optimized for the high data rates and large message sizes produced by Ouster lidar sensors. This can lead to:

  • Dropped packets

  • Reduced update rates

  • Increased latency

Cyclone DDS is an alternative DDS implementation known for its high performance and efficiency, particularly in high-bandwidth and large message scenarios.

 

Using Cyclone DDS

By configuring ROS2 to use Cyclone DDS, you can often overcome these performance limitations and achieve the full data rate from your Ouster lidar. Here's how to do it:

Step 1: Install Cyclone DDS

Open a terminal and install Cyclone DDS using the following commands:

sudo apt update sudo apt install ros-humble-rmw-cyclonedds-cpp # Replace "rolling" with your ROS 2 distribution if needed
  • Replace "humble" with your ROS 2 distribution name (e.g., "foxy", "iron") if you are not using ROS 2 Humble.

Step 2: Configure ROS2 to Use Cyclone DDS

To make ROS2 use Cyclone DDS, you need to set the ROS_DOMAIN_ID environment variable and the RMW_IMPLEMENTATION environment variable. The ROS_DOMAIN_ID is not strictly required for using Cyclone DDS, but it's good practice to set it, especially if you have multiple ROS 2 networks running on the same physical network. Here's how to set these variables:

Temporary (for the current terminal session):

export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

Persistent (recommended, across all terminal sessions):

Add the following lines to your ~/.bashrc file:

echo "export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp" >> ~/.bashrc source ~/.bashrc
  • It is recommended to use the persistent method, so the variables are automatically set every time you open a new terminal.

  • The ROS_DOMAIN_ID variable is used to isolate different ROS 2 networks. If you only have one ROS 2 network, you can use the default value of 0. If you have multiple ROS 2 networks running on the same physical network, you should use different ROS_DOMAIN_ID values for each network to prevent interference.

  • The RMW_IMPLEMENTATION variable tells ROS 2 which DDS implementation to use. Setting it to rmw_cyclonedds_cpp tells ROS 2 to use Cyclone DDS.

  1. is being used.

Step 3: Relaunch the Ouster Lidar Driver

After completing the above steps, relaunch the Ouster lidar driver node. This will ensure that the node is using Cyclone DDS for communication.

Expected Results

After switching to Cyclone DDS, you should observe:

  • Increased point cloud update rate (e.g., from 5Hz to 10Hz).

By following these simple steps, you can effectively resolve common performance issues encountered when using Ouster lidar sensors with ROS 2, without the need for complex Fast DDS tuning.