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

Revision history [back]

You need to use a different method to receive just a single message without a callback as you're trying to in your code. The rospy.wait_for_message() will do what you expect, blocking execution until a message is received and returning that message.

A rospy.Subscriber object is used when you want to register a callback function to receive messages whenever the arrive on a topic. You normally create it once when your node is created and destroy it when it closes. This is described in the tutorial here.

Hope this helps.