From 1d7d2c1269ba162039456cf33a9986dc1fc12632 Mon Sep 17 00:00:00 2001 From: Jakub Delicat Date: Thu, 7 Sep 2023 16:23:58 +0200 Subject: [PATCH] added node destruction Signed-off-by: Jakub Delicat --- safety_master_plugin/master_plugin.py | 3 +++ safety_master_plugin/ros_master_wrapper.py | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/safety_master_plugin/master_plugin.py b/safety_master_plugin/master_plugin.py index f8c5835..b9a32aa 100755 --- a/safety_master_plugin/master_plugin.py +++ b/safety_master_plugin/master_plugin.py @@ -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() diff --git a/safety_master_plugin/ros_master_wrapper.py b/safety_master_plugin/ros_master_wrapper.py index f3e6436..0ecec0e 100644 --- a/safety_master_plugin/ros_master_wrapper.py +++ b/safety_master_plugin/ros_master_wrapper.py @@ -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