Skip to content

WarriorHanamy/ros2_docker

Repository files navigation

ROS 2 Docker Compose

A stable and reliable Docker Compose setup for ROS 2 Humble nodes, providing efficient communication and modular composition through Fast DDS configuration.

Overview

This project provides a containerized ROS 2 environment using Docker Compose with pre-configured Fast DDS settings for optimal inter-node communication. Each ROS 2 node runs in an isolated container with a fixed IP address, enabling reliable and efficient message passing across the distributed system.

Architecture

  • Base Image: osrf/ros:humble-desktop - Official ROS 2 Humble desktop environment
  • Network: Isolated bridge network (172.20.0.0/24) for container-to-container communication
  • Transport: Fast DDS with UDPv4 and shared memory transport for high-performance messaging
  • Nodes: 3 pre-configured containers (ros_1, ros_2, ros_3) with static IPs

Features

  • Static IP Assignment: Each container has a predictable IP address for reliable discovery
  • Fast DDS Configuration: Pre-tuned transport descriptors for low-latency communication
  • Shared Memory Support: SHM transport enabled for same-host performance
  • Modular Design: Easily scale by adding more containers to the compose file
  • Isolated Network: Internal-only bridge network prevents external interference

Quick Start

Prerequisites

  • Docker
  • Docker Compose
  • Just (command runner)

Commands

# Start all ROS 2 containers
just up

# Stop all containers (keep state)
just stop

# Stop and remove all containers
just down

# View logs from all containers
just logs

# Enter a specific container
just enter_ros_1   # or enter_ros_2, enter_ros_3

Container Layout

Container IP Address Purpose
ros_1 172.20.0.10 ROS 2 node
ros_2 172.20.0.11 ROS 2 node
ros_3 172.20.0.12 ROS 2 node

Adding More Nodes

To add additional ROS 2 nodes, extend docker-compose.yml:

  ros_4:
    image: osrf/ros:humble-desktop
    container_name: ros_4
    networks:
      ros_internal:
        ipv4_address: 172.20.0.13
    volumes:
      - ./fastdds.xml:/fastdds.xml:ro
    environment:
      - FASTRTPS_DEFAULT_PROFILES_FILE=/fastdds.xml
    command: tail -f /dev/null

Then add the new IP to fastdds.xml and create a corresponding just command.

Fast DDS Configuration

The fastdds.xml file configures:

  • UDPv4 Transport: For network communication between containers
  • SHM Transport: For high-performance same-host communication
  • Interface Whitelist: Restricts communication to the internal network only

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •