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

No, there is no spin_once in rospy. In rospy the subscriber's callbacks are executed in separate threads. Google quickly produces these old questions including answers:

  • http://ros-users.122217.n3.nabble.com/rospy-version-of-spinOnce-td180442.html
  • http://ros-users.122217.n3.nabble.com/ros-spinOnce-equivalent-for-rospy-td2317347.html
  • http://answers.ros.org/question/30490/rospy-suscriber-run-a-callback-once-using-rospyspin/

To translate your loop from C++ you could either check periodically in a loop in the main thread, or check in each of the callbacks. Either way you likely need some thread synchronization.