ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You could probably destroy the subscriber in the callback like this :
import rospy
from std_msgs.msg import Int8
class SomeClass:
def __init__(self):
self.data = None
self.sub = None
def get_data_callback(self, data):
self.data = data
del self.sub
def run(self):
rospy.init_node('myNodeName', anonymous=True)
rospy.Subscriber('/sometopic', Int8, self.get_data_callback)
print self.data
rospy.spin()
if __name__ == "__main__":
foo = SomeClass()
foo.run()
Though I haven't yet tested if it works. I don't now any other means using topics.
2 | No.2 Revision |
You could probably destroy the subscriber in the callback like this :
import rospy
from std_msgs.msg import Int8
class SomeClass:
def __init__(self):
self.data = None
self.sub = None
def get_data_callback(self, data):
self.data = data
del self.sub
delete(self.sub)
def run(self):
rospy.init_node('myNodeName', anonymous=True)
rospy.Subscriber('/sometopic', Int8, self.get_data_callback)
print self.data
rospy.spin()
if __name__ == "__main__":
foo = SomeClass()
foo.run()
Though I haven't yet tested if it works. I don't now any other means using topics.
3 | No.3 Revision |
You could probably destroy the subscriber in the callback like this :
import rospy
from std_msgs.msg import Int8
class SomeClass:
def __init__(self):
self.data = None
self.sub = None
def get_data_callback(self, data):
self.data = data
print self.data
delete(self.sub)
def run(self):
rospy.init_node('myNodeName', anonymous=True)
rospy.Subscriber('/sometopic', Int8, self.get_data_callback)
print self.data
rospy.spin()
if __name__ == "__main__":
foo = SomeClass()
foo.run()
Though I haven't yet tested if it works. I don't now any other means using topics.
4 | No.4 Revision |
You could probably destroy the subscriber in the callback like this :
import rospy
from std_msgs.msg import Int8
class SomeClass:
def __init__(self):
self.data = None
self.sub = None
def get_data_callback(self, data):
self.data = data
print self.data
delete(self.sub)
del self.sub
def run(self):
rospy.init_node('myNodeName', anonymous=True)
rospy.Subscriber('/sometopic', Int8, self.get_data_callback)
print self.data
rospy.spin()
if __name__ == "__main__":
foo = SomeClass()
foo.run()
Though I haven't yet tested if it works. I don't now any other means using topics.
5 | No.5 Revision |
You could probably can also destroy the subscriber in the callback use unregister
fonction like this :
import rospy
from std_msgs.msg import Int8
class SomeClass:
def __init__(self):
self.data = None
self.sub = None
def get_data_callback(self, data):
self.data = data
print self.data
del self.sub
self.sub.unregister()
def run(self):
rospy.init_node('myNodeName', anonymous=True)
rospy.Subscriber('/sometopic', self.sub.rospy.Subscriber('/sometopic', Int8, self.get_data_callback)
print self.data
rospy.spin()
if __name__ == "__main__":
foo = SomeClass()
foo.run()
Though I haven't yet tested if it works. I don't now any other means using topics.
6 | No.6 Revision |
You could can also destroy use the unregister
fonction like this :
import rospy
from std_msgs.msg import Int8
class SomeClass:
def __init__(self):
self.data = None
self.sub = None
def get_data_callback(self, data):
self.data = data
print self.data
self.sub.unregister()
def run(self):
rospy.init_node('myNodeName', anonymous=True)
self.sub.rospy.Subscriber('/sometopic', Int8, self.get_data_callback)
print self.data
rospy.spin()
if __name__ == "__main__":
foo = SomeClass()
foo.run()
7 | No.7 Revision |
You could can also destroy use the unregister
fonction like this :
import rospy
from std_msgs.msg import Int8
class SomeClass:
def __init__(self):
self.data = None
self.sub = None
def get_data_callback(self, data):
self.data = data
print self.data
self.sub.unregister()
def run(self):
rospy.init_node('myNodeName', anonymous=True)
self.sub.rospy.Subscriber('/sometopic', self.sub = rospy.Subscriber('/sometopic', Int8, self.get_data_callback)
print self.data
rospy.spin()
if __name__ == "__main__":
foo = SomeClass()
foo.run()
8 | No.8 Revision |
You could can also destroy use the unregister
fonction like this :
import rospy
from std_msgs.msg import Int8
class SomeClass:
def __init__(self):
self.data = None
self.sub = None
def get_data_callback(self, data):
self.data = data
print self.data
self.sub.unregister()
def run(self):
rospy.init_node('myNodeName', anonymous=True)
self.sub = rospy.Subscriber('/sometopic', Int8, self.get_data_callback)
print self.data
rospy.spin()
if __name__ == "__main__":
foo = SomeClass()
foo.run()
9 | No.9 Revision |
You could can also destroy use the unregister
fonction like this :
import rospy
from std_msgs.msg import Int8
class SomeClass:
def __init__(self):
self.data = None
self.sub = None
def get_data_callback(self, data):
self.data = data
print self.data
self.sub.unregister()
def run(self):
rospy.init_node('myNodeName', anonymous=True)
self.sub = rospy.Subscriber('/sometopic', Int8, self.get_data_callback)
rospy.spin()
if __name__ == "__main__":
foo = SomeClass()
foo.run()