added node destruction

Signed-off-by: Jakub Delicat <jakub.delicat@pwr.edu.pl>
This commit is contained in:
Jakub Delicat 2023-09-07 16:23:58 +02:00
parent a136c86ba1
commit 1d7d2c1269
2 changed files with 8 additions and 3 deletions

View File

@ -122,3 +122,6 @@ class MasterPlugin(Plugin):
def restrictions_changed(self, restrictions):
self._master_info.restrictions = restrictions
self._ros_wrapper.restrictions_changed(restrictions)
def shutdown_plugin(self):
self._ros_wrapper.unregister_node()

View File

@ -113,15 +113,17 @@ class ROSWrapper(Node):
self.master_stop_publisher.publish(stop_msg)
def cancel_subscribers_and_publishers(self):
self.when_robots_disabled()
self.unregister_publisher(self.master_stop_publisher)
self.unregister_publisher(self.restrictions_publisher)
for key, value in self.robot_info_subscribers.iteritems():
self.unsubscribe(value)
for subscriber in self.robot_info_subscribers.values():
self.unsubscribe(subscriber)
def unregister_node(self):
self.cancel_subscribers_and_publishers()
rospy.signal_shutdown("Closing safety master plugin")
# rospy.signal_shutdown("Closing safety master plugin")
def setup_get_master_stop_state_function(self, function):
self.get_master_stop_state = function