diff --git a/wild_visual_navigation/traversability_estimator/nodes.py b/wild_visual_navigation/traversability_estimator/nodes.py index 42a9ac0b..4e998969 100644 --- a/wild_visual_navigation/traversability_estimator/nodes.py +++ b/wild_visual_navigation/traversability_estimator/nodes.py @@ -163,6 +163,14 @@ 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