From be876c4108248c2910fac41a327436107fb385cc Mon Sep 17 00:00:00 2001 From: Piotr Libera Date: Sat, 21 Dec 2024 22:25:55 +0100 Subject: [PATCH 1/2] Check if the debug image has not been deleted before publishing --- wild_visual_navigation/traversability_estimator/nodes.py | 4 ++++ wild_visual_navigation_ros/scripts/wvn_learning_node.py | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/wild_visual_navigation/traversability_estimator/nodes.py b/wild_visual_navigation/traversability_estimator/nodes.py index 42a9ac0b..894f30e7 100644 --- a/wild_visual_navigation/traversability_estimator/nodes.py +++ b/wild_visual_navigation/traversability_estimator/nodes.py @@ -163,6 +163,10 @@ def clear_debug_data(self): print(e) pass # Image already removed + def has_debug_data(self): + return hasattr(self, "_image") and self._image is not None and \ + hasattr(self, "_supervision_mask") and self._supervision_mask is not None + def change_device(self, device): """Changes the device of all the class members diff --git a/wild_visual_navigation_ros/scripts/wvn_learning_node.py b/wild_visual_navigation_ros/scripts/wvn_learning_node.py index 67882da1..84367872 100644 --- a/wild_visual_navigation_ros/scripts/wvn_learning_node.py +++ b/wild_visual_navigation_ros/scripts/wvn_learning_node.py @@ -831,7 +831,7 @@ def visualize_image_overlay(self): vis_node = self._traversability_estimator.get_mission_node_for_visualization() # Publish reprojections of last node in graph - if vis_node is not None: + if vis_node is not None and vis_node.has_debug_data(): cam = vis_node.camera_name torch_image = vis_node._image torch_mask = vis_node._supervision_mask @@ -841,6 +841,9 @@ def visualize_image_overlay(self): image_out = self._visualizer.plot_detectron_classification(torch_image, torch_mask, cmap="Blues") self._camera_handler[cam]["debug"]["image_overlay"].publish(rc.numpy_to_ros_image(image_out)) + elif vis_node is not None: + rospy.logwarn(f"[{self._node_name}] No visualization data available for node") + def pause_learning_callback(self, req): """Start and stop the network training""" prev_state = self._traversability_estimator.pause_learning From 0b767e6a0df52a390930eac0b404c02070226d09 Mon Sep 17 00:00:00 2001 From: Piotr Libera Date: Sun, 22 Dec 2024 17:02:41 +0100 Subject: [PATCH 2/2] Fix formatting --- wild_visual_navigation/traversability_estimator/nodes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wild_visual_navigation/traversability_estimator/nodes.py b/wild_visual_navigation/traversability_estimator/nodes.py index 894f30e7..4e998969 100644 --- a/wild_visual_navigation/traversability_estimator/nodes.py +++ b/wild_visual_navigation/traversability_estimator/nodes.py @@ -164,8 +164,12 @@ def clear_debug_data(self): pass # Image already removed def has_debug_data(self): - return hasattr(self, "_image") and self._image is not None and \ - hasattr(self, "_supervision_mask") and self._supervision_mask is not None + return ( + hasattr(self, "_image") + and self._image is not None + and hasattr(self, "_supervision_mask") + and self._supervision_mask is not None + ) def change_device(self, device): """Changes the device of all the class members