Skip to content

Commit 62897db

Browse files
committed
Update configure_cyclonedds.sh
1 parent f8898ab commit 62897db

File tree

1 file changed

+91
-5
lines changed

1 file changed

+91
-5
lines changed

scripts/configure_cyclonedds.sh

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,102 @@
11
#!/bin/bash
2+
# configure_cyclonedds.sh - Configure CycloneDDS middleware for ROS2
3+
#
4+
# DESCRIPTION:
5+
# This script configures Eclipse CycloneDDS as the ROS2 middleware implementation.
6+
# CycloneDDS is a high-performance, open-source DDS implementation that provides
7+
# better performance and reliability compared to the default FastDDS in many scenarios.
8+
#
9+
# The script permanently adds environment variables to ~/.bashrc to ensure
10+
# CycloneDDS is used as the RMW (ROS Middleware) implementation across all
11+
# ROS2 sessions.
12+
#
13+
# USAGE:
14+
# ./configure_cyclonedds.sh
15+
#
16+
# WHAT IT CONFIGURES:
17+
# 1. RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
18+
# - Sets CycloneDDS as the ROS2 middleware implementation
19+
# - Alternative to default FastDDS (rmw_fastrtps_cpp)
20+
#
21+
# 2. CYCLONEDDS_URI with discovery settings:
22+
# - AllowMulticast=true: Enables multicast for node discovery
23+
# - ParticipantIndex=auto: Automatic participant indexing
24+
# - MaxAutoParticipantIndex=32: Supports up to 32 participants
25+
#
26+
# REQUIREMENTS:
27+
# - CycloneDDS must be installed: sudo apt install ros-$ROS_DISTRO-rmw-cyclonedx-cpp
28+
# - Write permissions to ~/.bashrc
29+
#
30+
# PERMANENT CHANGES:
31+
# ⚠️ WARNING: This script modifies ~/.bashrc permanently
32+
# The environment variables will persist across all future shell sessions
33+
#
34+
# WHY CYCLONEDDS:
35+
# - Better performance for large message throughput
36+
# - More reliable discovery in complex network environments
37+
# - Lower CPU usage compared to FastDDS in many scenarios
38+
# - Better multicast support
39+
#
40+
# USAGE:
41+
# chmod +x scripts/configure_cyclonedds.sh
42+
# ./scripts/configure_cyclonedds.sh
43+
#
44+
# TO VERIFY CONFIGURATION:
45+
# echo $RMW_IMPLEMENTATION # Should show: rmw_cyclonedds_cpp
46+
# ros2 doctor --report # Should show CycloneDDS as middleware
247

3-
# Add environment variable exports to ~/.bashrc if they don't already exist
48+
echo "=== CycloneDDS Configuration Script ==="
49+
echo "This script will configure Eclipse CycloneDDS as your ROS2 middleware."
50+
echo ""
51+
52+
# Check if CycloneDDS is installed
53+
if ! dpkg -l | grep -q "rmw-cyclonedx-cpp"; then
54+
echo "⚠️ Warning: CycloneDDS may not be installed."
55+
echo " Install with: sudo apt install ros-\$ROS_DISTRO-rmw-cyclonedx-cpp"
56+
echo " Continuing anyway..."
57+
echo ""
58+
fi
59+
60+
echo "Configuring ROS2 middleware settings..."
61+
62+
# Configure RMW Implementation (CycloneDDS)
63+
echo ""
64+
echo "[1/2] Setting RMW_IMPLEMENTATION to CycloneDDS..."
465
if ! grep -q "export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp" ~/.bashrc; then
566
echo "export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp" >> ~/.bashrc
6-
echo "Added RMW_IMPLEMENTATION export to ~/.bashrc"
67+
echo "✓ Added RMW_IMPLEMENTATION=rmw_cyclonedds_cpp to ~/.bashrc"
68+
else
69+
echo "✓ RMW_IMPLEMENTATION already configured in ~/.bashrc"
770
fi
871

72+
# Configure CycloneDDS Discovery Settings
73+
echo ""
74+
echo "[2/2] Configuring CycloneDDS discovery settings..."
975
if ! grep -q "export CYCLONEDDS_URI=" ~/.bashrc; then
76+
# Add CycloneDDS configuration for optimal discovery
1077
echo "export CYCLONEDDS_URI='<CycloneDDS><Domain><General><AllowMulticast>true</AllowMulticast></General><Discovery><ParticipantIndex>auto</ParticipantIndex><MaxAutoParticipantIndex>32</MaxAutoParticipantIndex></Discovery></Domain></CycloneDDS>'" >> ~/.bashrc
11-
echo "Added CYCLONEDDS_URI export to ~/.bashrc"
78+
echo "✓ Added CycloneDDS discovery configuration to ~/.bashrc"
79+
echo " - Multicast discovery: enabled"
80+
echo " - Participant indexing: automatic"
81+
echo " - Max participants: 32"
82+
else
83+
echo "✓ CYCLONEDDS_URI already configured in ~/.bashrc"
1284
fi
1385

14-
# Source the bashrc file to apply changes to current session
86+
# Apply changes to current session
87+
echo ""
88+
echo "Applying configuration to current session..."
1589
source ~/.bashrc
16-
echo "Sourced ~/.bashrc - environment variables are now active"
90+
echo "✓ Configuration applied"
91+
92+
echo ""
93+
echo "=== Configuration Complete ==="
94+
echo "CycloneDDS is now configured as your ROS2 middleware."
95+
echo ""
96+
echo "To verify the configuration:"
97+
echo " echo \$RMW_IMPLEMENTATION # Should show: rmw_cyclonedds_cpp"
98+
echo " ros2 doctor --report # Should show CycloneDDS info"
99+
echo ""
100+
echo "⚠️ Note: Changes are permanent in ~/.bashrc"
101+
echo " To revert, manually remove the added lines from ~/.bashrc"
102+
echo ""

0 commit comments

Comments
 (0)