Skip to main content
🤝

이 가이드는 인류와 AI가 함께 만드는 지식입니다.

이 콘텐츠는 Human + AI Partnership 철학 아래 모든 사람이 로봇·AI를 배울 수 있도록 무료로 제공됩니다. 당신의 질문과 기여가 다음 학생의 미래를 바꿉니다.

ROS 2 Networking & Distributed Systems Guide 2026

Scale ROS 2 across multiple machines and networks. Master DDS discovery, network configuration, and multi-machine coordination for distributed robotics systems.

1. DDS Domain Configuration

Configure DDS domains for multi-machine networks:

# Set ROS domain ID (0-232)
export ROS_DOMAIN_ID=0

# Each domain is isolated
# Robot A: ROS_DOMAIN_ID=0
# Robot B: ROS_DOMAIN_ID=1
# Both can run on same network without interference

# Launch nodes in different domains
export ROS_DOMAIN_ID=0
ros2 run my_robot_app robot_a_node &

export ROS_DOMAIN_ID=1
ros2 run my_robot_app robot_b_node &

2. Multi-Machine ROS 2 Setup

Coordinate robots across multiple machines:

# Robot A (192.168.1.100)
export ROS_DOMAIN_ID=0
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
export CYCLONEDDS_URI=file:///etc/cyclonedds.xml
ros2 launch robot_a bringup.launch.py

# Robot B (192.168.1.101)
export ROS_DOMAIN_ID=0
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
export CYCLONEDDS_URI=file:///etc/cyclonedds.xml
ros2 launch robot_b bringup.launch.py

# Both robots now share topics on same DDS network
# ros2 topic list shows all topics from both robots
# ros2 node list shows nodes from both machines

3. DDS Discovery Configuration

Control DDS discovery behavior:

<?xml version="1.0" encoding="UTF-8"?>
<CycloneDDS>
  <Domain>
    <Id>0</Id>
    <Discovery>
      <ParticipantIndex>auto</ParticipantIndex>
      <MaxAutoParticipantIndex>120</MaxAutoParticipantIndex>
    </Discovery>
    <General>
      <AllowMulticast>default</AllowMulticast>
      <MulticastRecvBufSize>1M</MulticastRecvBufSize>
      <MulticastSendBufSize>512k</MulticastSendBufSize>
    </General>
    <Internal>
      <HeartbeatInterval>100ms</HeartbeatInterval>
      <ParticipantListInterval>1s</ParticipantListInterval>
    </Internal>
  </Domain>
</CycloneDDS>

4. Network Optimization

Optimize communication across networks:

# Disable multicast for WAN (use unicast instead)
export RMW_USE_LOCALHOST_ONLY=0
export CYCLONEDDS_URI=file:///etc/cyclonedds-unicast.xml

# cyclonedds-unicast.xml
<?xml version="1.0" encoding="UTF-8"?>
<CycloneDDS>
  <Domain>
    <Id>0</Id>
    <General>
      <AllowMulticast>false</AllowMulticast>
    </General>
    <Discovery>
      <Peers>
        <Peer address="192.168.1.100"/>
        <Peer address="192.168.1.101"/>
      </Peers>
    </Discovery>
  </Domain>
</CycloneDDS>

# Tune socket buffer sizes for bandwidth
sudo sysctl -w net.core.rmem_max=134217728
sudo sysctl -w net.core.wmem_max=134217728

5. Bridging Isolated Networks

Connect robots across separate networks:

// DDS Bridge between networks
#include <rclcpp/rclcpp.hpp>

class DDS_Bridge : public rclcpp::Node {
 public:
  DDS_Bridge() : Node("dds_bridge") {
    // Subscribe to local topics
    local_sub_ = create_subscription<std_msgs::msg::String>(
      "local_topic", 10,
      [this](const std_msgs::msg::String::SharedPtr msg) {
        bridge_topic(*msg);
      });

    // Publish to remote network
    remote_pub_ = create_publisher<std_msgs::msg::String>(
      "remote_topic", 10);
  }

 private:
  void bridge_topic(const std_msgs::msg::String& msg) {
    // Re-publish to remote network
    remote_pub_->publish(msg);
  }

  rclcpp::Subscription<std_msgs::msg::String>::SharedPtr local_sub_;
  rclcpp::Publisher<std_msgs::msg::String>::SharedPtr remote_pub_;
};

6. Clock Synchronization

Synchronize time across distributed robots:

# Use NTP for time synchronization
sudo apt-get install -y chrony
sudo systemctl start chrony

# Configure NTP server
# /etc/chrony/chrony.conf
server ntp.ubuntu.com iburst

# Verify synchronization
chronyc tracking
chronyc sources

# Use rosgraph time provider
export ROS_DISABLE_RPC=true
export ROS_USE_RTC=true

# Nodes use synchronized system time
auto now = rclcpp::Clock().now()  // Synchronized across network

7. Latency & Bandwidth Monitoring

Monitor network performance:

# Measure latency between robots
ping -c 100 robot_b.local | awk '{sum+=$7} END {print "Avg latency:", sum/NR, "ms"}'

# Monitor bandwidth usage
ros2 run rmw_dds_common listener --max-count=100 /robot_topic |   awk '{size += length($0)} END {print "Bandwidth:", size/100, "bytes/msg"}'

# DDS statistics
ros2 run rmw_fastrtps_cpp dds_stats /robot_node

# Network interface statistics
iftop -i eth0  # Real-time bandwidth monitoring
ss -s          # Socket statistics

8. Fault Tolerance & Redundancy

Handle network failures gracefully:

// Heartbeat-based health monitoring
class NetworkHealthMonitor : public rclcpp::Node {
 public:
  NetworkHealthMonitor() : Node("health_monitor") {
    health_sub_ = create_subscription<std_msgs::msg::Bool>(
      "robot_health", 10,
      [this](const std_msgs::msg::Bool::SharedPtr msg) {
        last_heartbeat_ = now();
      });

    monitor_timer_ = create_wall_timer(
      std::chrono::seconds(5),
      [this]() { check_health(); });
  }

 private:
  void check_health() {
    auto elapsed = now() - last_heartbeat_;
    if (elapsed.nanoseconds() > 10e9) {  // 10 seconds
      RCLCPP_ERROR(get_logger(), "Network failure detected!");
      trigger_failover();
    }
  }

  void trigger_failover() {
    // Switch to backup robot or local fallback
  }

  rclcpp::Time last_heartbeat_;
  rclcpp::Subscription<std_msgs::msg::Bool>::SharedPtr health_sub_;
  rclcpp::TimerBase::SharedPtr monitor_timer_;
};

9. Edge Computing & Hierarchical Systems

Implement hierarchical robot networks:

# Central command center (cloud)
# ↓ ROS bridge (unicast, encrypted)
# Regional hub (edge)
# ↓ Local network (multicast)
# Robot fleet (local area network)

# Cloud node (ROS_DOMAIN_ID=10)
export ROS_DOMAIN_ID=10
ros2 launch command_center bringup.launch.py

# Regional hub (bridges domain 10 to domain 0)
ros2 run ros2_dds_bridge bridge_node   --local-domain 0 --remote-domain 10

# Robot A, B, C (ROS_DOMAIN_ID=0)
export ROS_DOMAIN_ID=0
ros2 launch fleet bringup.launch.py

10. Best Practices

Key Takeaways

Scale ROS 2 across multiple machines using DDS domain configuration and network optimization. Implement clock synchronization, monitor performance, and handle network failures gracefully. Design hierarchical systems for edge computing and cloud coordination.