ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
@stevemartin 's answer is incorrect.
roscpp Single Threaded Spinning is thread safe.
However, your question is on rospy. rospy subscribers have their own threads. I'm not clear if each subscriber runs on a separate thread, or if all subscribers for a given topic runs on a single thread and subscribers on different topics run on separate threads. Haven't been able to find that in documentation.
Bottom line, you can't assume thread safety in rospy. Use mutual exclusion to access shared resources in callback functions.