Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Do the default subscription constructors block?

Please forgive me if documentation on this issue is the proverbial snake that should have bit me, but based on some initial explorations it looks like the

ros::NodeHandle::subscribe()

family and their rospy equivalents don't block. That is: it appears that the statement will return before the corresponding object/thread creation/spin-up is complete and actually ready to receive messages. Is this indeed the case? If so, what's the preferred way to confirm that the Subscriber object is ready?

To give (example) context, suppose I want to write (pseudo)code like this:

def handler(msg):
  pub(/topic,msg++)
subscribe(/topic,handler)
pub(/topic,0)

that creates a pub/sub loop without there being any timing issues for that first crucial message reception.

_Trevor