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

To only run the callback once, you can do something similar to:

class Example:

    def __init__(self):
        self.sub = rospy.Subscriber(..., self.cb, ...)

    def cb(self, msg):
        # do something with msg
        self.sub.unregister()

To only run the callback once, you can do something similar to:

class Example:
     def __init__(self):
        self.sub = rospy.Subscriber(..., self.cb, ...)

    def cb(self, msg):
        # do something with msg
        self.sub.unregister()

To only run the callback once, you can do something similar to:

class Example:
    def __init__(self):
        self.sub = rospy.Subscriber(..., self.cb, ...)

    def cb(self, msg):
        # do something with msg
        self.sub.unregister()

To only run the callback once, you can do something similar to:The easiest way is to use: msg = rospy.wait_for_message('/example_topic', ExampleMsg).

class Example:
    def __init__(self):
        self.sub = rospy.Subscriber(..., self.cb, ...)

    def cb(self, msg):
        # do something with msg
        self.sub.unregister()

The In rospy, the easiest way is to use: use (as gvdhoorn suggests): msg = rospy.wait_for_message('/example_topic', ExampleMsg).

In rospy, the easiest way is to use (as gvdhoorn suggests): suggests):

msg = rospy.wait_for_message('/example_topic', ExampleMsg).