Skip to content

Commit

Permalink
docs: Add documentation on shared memory intra-process communication …
Browse files Browse the repository at this point in the history
…in ROS 2
  • Loading branch information
2b-t committed Nov 7, 2024
1 parent 39f12e0 commit 11f4da0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/Ros.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions templates/ros2/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 11f4da0

Please sign in to comment.