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

I know it's been over a year but I just had this same problem and found this post. Just make sub_once a global variable.

def cb_once(msg):
   #do processing here
   sub_once.unregister()

global sub_once
sub_once = rospy.Subscriber('my_topic,', MyType, cb_once)