Middleware Configuration#
ROS 2 supports multiple middleware implementations (RMW). While DDS is default, Zenoh offers significant advantages for LSA applications.
Middleware Options#
DDS (Default)#
- Fast-RTPS (ROS 2 Humble default)
- Cyclone DDS (lightweight)
- RTI Connext (commercial)
Zenoh (Recommended for LSA)#
Tier 1 middleware optimized for autonomous vehicles with: - Better wireless/cellular performance - Lower latency and resource usage - Zero configuration - Cloud-native support
Zenoh for Low Speed Autonomy#
Performance Benefits#
- Lower Latency: Up to 50% reduction in message latency compared to DDS
- Higher Throughput: Better performance with large data streams (pointclouds, images)
- Efficient Resource Usage: Lower CPU and memory footprint
- Wireless Optimization: Superior performance on WiFi and cellular networks
Operational Advantages#
- Zero Configuration: Works out-of-the-box without complex QoS tuning
- Cloud Native: Seamless operation across local networks and internet
- Cellular Support: Native unicast support for 4G/5G networks
- Simplified Debugging: Built-in tools for monitoring and troubleshooting
LSA-Specific Benefits#
- Multi-Vehicle Coordination: Efficient fleet communication
- Remote Monitoring: Native support for cloud connectivity
- Edge Computing: Optimized for distributed architectures
- Dynamic Discovery: Better handling of intermittent connections
Installation#
Prerequisites#
Complete the Getting Started guide first.
Install Zenoh RMW#
# Add the Zenoh repository
echo "deb [trusted=yes] https://download.eclipse.org/zenoh/debian-repo/ /" | \
sudo tee /etc/apt/sources.list.d/zenoh.list > /dev/null
sudo apt update
# Install RMW Zenoh
sudo apt install -y ros-humble-rmw-zenoh-cpp
Configuration#
Basic Setup#
-
Set the RMW Implementation
# Add to ~/.bashrc for permanent configuration echo 'export RMW_IMPLEMENTATION=rmw_zenoh_cpp' >> ~/.bashrc source ~/.bashrc # Or set temporarily for current session export RMW_IMPLEMENTATION=rmw_zenoh_cpp
-
Configure Zenoh Router (Optional but Recommended)
Create a Zenoh configuration file:
cat > ~/zenoh_config.json5 << EOF
{
mode: "router",
listen: {
endpoints: [
"tcp/0.0.0.0:7447",
"udp/0.0.0.0:7447"
]
},
scouting: {
multicast: {
enabled: true,
address: "224.0.0.224:7446",
interface: "auto"
}
}
}
EOF
- Start Zenoh Router
# Install Zenoh router sudo apt install -y zenoh # Run with configuration zenohd -c ~/zenoh_config.json5
Advanced Configuration#
Network-Specific Settings#
For different network environments:
# WiFi Networks
export ZENOH_MULTICAST_SCOUTING=true
export ZENOH_UNICAST_SCOUTING=false
# Cellular Networks (4G/5G)
export ZENOH_MULTICAST_SCOUTING=false
export ZENOH_UNICAST_SCOUTING=true
export ZENOH_PEERS="tcp/router-ip:7447"
# Mixed Networks
export ZENOH_MULTICAST_SCOUTING=true
export ZENOH_UNICAST_SCOUTING=true
Performance Tuning#
# Optimize for low latency
export ZENOH_CACHE_SIZE=0
export ZENOH_BATCHING_ENABLED=false
# Optimize for high throughput
export ZENOH_CACHE_SIZE=10000
export ZENOH_BATCHING_ENABLED=true
export ZENOH_BATCH_SIZE=65536
Integration with Autoware#
Launch File Configuration#
Modify your Autoware launch files to use Zenoh:
<!-- autoware_zenoh.launch.xml -->
<launch>
<!-- Set RMW implementation -->
<set_env name="RMW_IMPLEMENTATION" value="rmw_zenoh_cpp"/>
<!-- Include standard Autoware launch -->
<include file="$(find-pkg-share autoware_launch)/launch/autoware.launch.xml">
<arg name="vehicle_model" value="$(var vehicle_model)"/>
<arg name="sensor_model" value="$(var sensor_model)"/>
</include>
</launch>
Multi-Vehicle Setup#
For fleet deployments:
# Vehicle 1
export ROS_DOMAIN_ID=1
export ZENOH_SESSION_NAME="vehicle_1"
# Vehicle 2
export ROS_DOMAIN_ID=2
export ZENOH_SESSION_NAME="vehicle_2"
# Central Router (Fleet Coordinator)
zenohd --id fleet_router --listen tcp/0.0.0.0:7447
Switching Between Middleware#
You can easily switch between different RMW implementations:
# Use Zenoh
export RMW_IMPLEMENTATION=rmw_zenoh_cpp
# Switch back to Fast DDS
export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
# Use Cyclone DDS
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
Monitoring and Debugging#
Zenoh Tools#
# Install Zenoh tools
sudo apt install -y zenoh-tools
# Monitor active sessions
z_info
# Scout for Zenoh nodes
z_scout
# Monitor data flow
z_sub -k "/**"
ROS 2 Introspection#
# List active nodes
ros2 node list
# Check middleware in use
ros2 doctor --report | grep middleware
# Monitor topic bandwidth
ros2 topic bw /sensing/lidar/concatenated/pointcloud
Troubleshooting#
Common Issues#
-
Nodes not discovering each other
# Check multicast is enabled ip link show | grep MULTICAST # Verify Zenoh router is running ps aux | grep zenohd
-
High latency on WiFi
# Disable power saving sudo iw dev wlan0 set power_save off # Set WiFi to performance mode sudo iwconfig wlan0 rate 54M fixed
-
Connection issues over cellular
# Use explicit peer configuration export ZENOH_PEERS="tcp/central-server-ip:7447"
Fallback to DDS#
If issues persist, you can always fall back to DDS:
unset RMW_IMPLEMENTATION
# Or explicitly set
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
Best Practices#
- Development: Use Cyclone DDS for simplicity
- Testing: Validate with target middleware early
- Production: Deploy with Zenoh for optimal performance
- Fleet: Use centralized Zenoh routers
- Remote: Configure explicit peers for cellular
Next Steps#
- Continue to Sensor Configuration
- Review platform-specific guides: x86_64 ECUs or ARM ECUs
- Learn about Zenoh architecture