From 11f4da0a7a6d1a1f32cbde940379214d7f991949 Mon Sep 17 00:00:00 2001 From: Tobit Flatscher <53856473+2b-t@users.noreply.github.com> Date: Thu, 7 Nov 2024 23:20:37 +0000 Subject: [PATCH] docs: Add documentation on shared memory intra-process communication in ROS 2 --- doc/Ros.md | 4 ++++ templates/ros2/docker/docker-compose.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/doc/Ros.md b/doc/Ros.md index dcba670..5a99a26 100644 --- a/doc/Ros.md +++ b/doc/Ros.md @@ -188,6 +188,10 @@ What I generally do is define the corresponding environment variables such as [` For an example of what this configuration might look like have a look at [this folder](../templates/ros2/docker). +#### 3.1.1 Intra-process communication over shared memory + +ROS 2 introduced some design changes that are aiming at drastically improving the communication speed in between nodes on the same computational unit. One such optimization is that [**intra-process communication** is left to the underlying middleware](https://design.ros2.org/articles/intraprocess_communications.html). This means it is down to the chosen middleware to use mechanisms like shared memory communication for nodes on the same computer. E.g. [FastDDS uses shared memory communication](https://fast-dds.docs.eprosima.com/en/v3.0.0/fastdds/transport/shared_memory/shared_memory.html) by default in case the environment variable [`ROS_LOCALHOST_ONLY`](https://docs.ros.org/en/humble/Tutorials/Beginner-CLI-Tools/Configuring-ROS2-Environment.html#the-ros-localhost-only-variable) is set to `1` and [CycloneDDS](https://cyclonedds.io/docs/cyclonedds/latest/shared_memory/shared_mem_config.html) lets you configure it through manually as described [here](https://github.com/ros2/rmw_cyclonedds/blob/humble/shared_memory_support.md). In Linux `/dev/shm` is used for **shared memory communication**. Therefore when communicating in between containers that set `ROS_LOCALHOST_ONLY` (or use shared memory explicitly) one might have to **mount `/dev/shm` into the containers**. For more information about shared memory and Docker refer to [this post](https://datawookie.dev/blog/2021/11/shared-memory-docker/). + ### 3.2 Zenoh middleware configuration A new alternative to DDS-based communication in ROS 2 Iron is [Zenoh](https://zenoh.io/), implemented in [`rmw_zenoh`](https://github.com/ros2/rmw_zenoh). Similar to the `roscore` in ROS it relies on at least a single router that establishes the connection between different nodes running on different computers (it is also possible to do so without but this is not recommended). A good introduction to this can be found in this [video](https://www.youtube.com/watch?v=fS0_rbQ6KKA). I will add this configuration once `rmw_zenoh` becomes installable from Debian packages. diff --git a/templates/ros2/docker/docker-compose.yml b/templates/ros2/docker/docker-compose.yml index 7259397..0193db3 100644 --- a/templates/ros2/docker/docker-compose.yml +++ b/templates/ros2/docker/docker-compose.yml @@ -35,4 +35,6 @@ services: #- /media:/media - ../src:${AMENT_WORKSPACE_DIR}/src - ../dds:${AMENT_WORKSPACE_DIR}/dds + # Required for ROS 2 shared memory communication + #- /dev/shm:/dev/shm