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

Revision history [back]

There is no guarantee in ROS that callbacks are not executed in parallel. This is desired behavior. If you want to avoid this kind of race condition, you need to use locks in your program code, i.e. when entering a callback a lock is acquired and when returning the lock is released again. That way, you get exclusive execution of callbacks. For python, you can use the threading.Lock class (tutorial). For C++ I suggest to use boost::scoped_lock.