Shared memory implementation available NOW in micro-ROS!

SHM transport is supported in Micro XRCE-DDS, the micro-ROS middleware implementation.

The XRCE-DDS client Shared Memory Transport (SHM) provides a way of communicating micro-ROS nodes that exist in the same MCU without the need of interacting with the micro-ROS Agent.

Some of the shared memory transport advantages are:

  • SHM allows large message support
    Network protocols need to fragment data in order to comply with the specific protocol and network stacks requirements, increasing communication overhead. SHM transport allows the copy of full messages where the only size limit is the machine’s memory capacity.

  • SHM reduces the number of memory copies
    When sending the same message to different entities, SHM transport can directly share the same memory buffer with all the destinations. Other protocols require to perform one copy of the message per endpoint.

  • SHM requires less operating system overhead
    Once initial setup is completed, shared memory transfers require much less system calls than the other protocols. Therefore, there is a performance/time consumption gain by using SHM.

The shared memory functionality is the result of a shared effort between the Client and the Agent. This approach provides the Clients with self-introspection capabilities to autonomously detect compatible publishers, subscribers or any other DDS entity, without the need to recur to the Agent. The Agent, which by default acknowledges the existence of matching entities in the same Client, blocks resending the duplicated matching information to the Client.

As a result, SHM enables fast communications between entities running in the same MCU.

This functionality, which has been repeatedly asked for by the community, is still heavily prototypical. Therefore, in order to debug and improve it, we kindly invite users to volunteer using it and provide feedback!

2 Likes

interesting :exclamation: does this work on NuttX? if so, we could probably give it a shot to share feedback. besides, any design details available where we can see? i am really interested in how shared memory is configured and used in micro-ROS.

Hello @tomoyafujita, in micro-ROS Galactic we are supporting Nuttx 10 as a standalone application, check this repo.

Regarding Shared Memory in micro-ROS, it uses the same feature in the default micro-ROS middleware: eProsima Micro XRCE-DDS Client.

You can check our code here. In order to enable it, just add:

...
        "microxrcedds_client":{
            "cmake-args":[
               ...
                "-DUCLIENT_PROFILE_SHARED_MEMORY=ON"
               ...
            ]
        },
...

to your micro-ROS colcon.meta. If you need more details or instructions, please open an issue in any of our Github repos.

Thanks for the interest!

1 Like