I'm new setting up ros2 modules and I have the following problem:I can't connect two ros2 nodes running insde docker from my host (mac) to a raspberry pi.
my local machine is a macOS I'm running the following docker compose:
services: ros2_ws: image: osrf/ros:humble-desktop-full network_mode: host ipc: host volumes: - .:/workstation working_dir: /workstation container_name: workstation_container tty: true
Inside this container I can run the basic ros2 node talker and listener then I have a second docker compose on a Raspberry PI like this:
services: ros2: build: . network_mode: host ipc: host volumes: - .:/robot_ws working_dir: /robot_ws container_name: robot_ws_container tty: true
and this is the dockerfile I use
# This is an auto generated Dockerfile for ros:ros-base# generated from docker_images_ros2/create_ros_image.Dockerfile.emFROM ros:humble-ros-core-jammy# install bootstrap toolsRUN apt-get update && apt-get install --no-install-recommends -y \ build-essential \ git \ python3-colcon-common-extensions \ python3-colcon-mixin \ python3-rosdep \ python3-vcstool \&& rm -rf /var/lib/apt/lists/*# bootstrap rosdepRUN rosdep init && \ rosdep update --rosdistro $ROS_DISTRO# setup colcon mixin and metadataRUN colcon mixin add default \ https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml && \ colcon mixin update && \ colcon metadata add default \ https://raw.githubusercontent.com/colcon/colcon-metadata-repository/master/index.yaml && \ colcon metadata update# install ros2 packagesRUN apt-get update && apt-get install -y --no-install-recommends \ ros-humble-ros-base=0.10.0-1* \&& rm -rf /var/lib/apt/lists/*
I can ping correctly from my Mac to the RPi and RPi to Mac but when I start the talker from my Mac and the listener from my RPi, the messages don't go throw.
What sudgestions do you have?
I tried setting up export ROS_DOMAIN_ID=5
on both machines but still not working.
I also tried setting up a network like this but no luck:
services: ros2_ws: image: osrf/ros:humble-desktop-full ports: - "11311:11311" volumes: - /Users/ricardmarsalcastan/Documents/Projects/workstation:/workstation working_dir: /workstation container_name: workstation_container tty: true networks: - robot_ws_networknetworks: robot_ws_network: name: robot_ws_network external: true