ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ROS doesn't provide any mutex classes; those are provided by the Python standard library, the C++ standard library (in C++11 and newer), or pthreads, boost, or another threading library. (For example, boost has https://www.boost.org/doc/libs/1_67_0/doc/html/interprocess.html ).

I have written and used mutexes across processes like this as part of my day job, and it took me about a week to build a well-tested, inter-process mutex using the available primitives from posix and pthreads. It is _possible_, but it's a lot of work and NOT a beginner project.

Instead, all of the ROS nodes that I've seen that need to do this write a single node that handles the mutexing internally, and publishes and subscribes to multiple topics. If you have two devices on the same I2C bus, you should write (or combine) the ROS nodes into a single node.