From 7b5c426160bd6e80c9204a1e632a27bbbfba41cf Mon Sep 17 00:00:00 2001 From: Giulio Romualdi Date: Fri, 6 Oct 2023 12:43:54 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20Fix=20the=20loading=20of=20t?= =?UTF-8?q?he=20text=20logging=20when=20the=20message=20is=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- robot_log_visualizer/file_reader/signal_provider.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/robot_log_visualizer/file_reader/signal_provider.py b/robot_log_visualizer/file_reader/signal_provider.py index 41ee3b1..18de7c4 100644 --- a/robot_log_visualizer/file_reader/signal_provider.py +++ b/robot_log_visualizer/file_reader/signal_provider.py @@ -73,11 +73,18 @@ def __populate_text_logging_data(self, file_object): # New way to store the struct array in robometry https://github.com/robotology/robometry/pull/175 if text_ref.shape[0] == len(data[key]["timestamps"]): + # If len(value[text[0]].shape) == 2 then the text contains a string, otherwise it is empty + # We need to manually check the shape to handle the case in which the text is empty data[key]["data"] = [ TextLoggingMsg( text="".join(chr(c[0]) for c in value[text[0]]), level="".join(chr(c[0]) for c in value[level[0]]), ) + if len(value[text[0]].shape) == 2 + else TextLoggingMsg( + text="", + level="".join(chr(c[0]) for c in value[level[0]]), + ) for text, level in zip(text_ref, level_ref) ] From 480ad8356702ebb5b3c67de010d8b9d35496b54d Mon Sep 17 00:00:00 2001 From: Giulio Romualdi Date: Fri, 6 Oct 2023 12:44:27 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20Avoid=20to=20return=20an=20e?= =?UTF-8?q?rror=20if=20the=20model=20is=20not=20correctly=20loaded?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- robot_log_visualizer/ui/gui.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/robot_log_visualizer/ui/gui.py b/robot_log_visualizer/ui/gui.py index 120cbd2..8bb0f16 100644 --- a/robot_log_visualizer/ui/gui.py +++ b/robot_log_visualizer/ui/gui.py @@ -463,7 +463,6 @@ def plotTabBar_currentChanged(self, index): # select the item in the tree from the path item = self.ui.variableTreeWidget.topLevelItem(0) for subpath in path[1:-1]: - # find the item given its name for child_id in range(item.childCount()): if item.child(child_id).text(0) == subpath: @@ -558,17 +557,14 @@ def __load_mat_file(self, file_name): if not self.meshcat_provider.load_model( self.signal_provider.joints_name, self.signal_provider.robot_name ): + # if not loaded we print an error but we continue msg = "Unable to load the model: " if self.meshcat_provider.custom_model_path: msg = msg + self.meshcat_provider.custom_model_path else: msg = msg + self.signal_provider.robot_name - self.logger.write_to_log( - "Unable to load the model from: " - + self.meshcat_provider.custom_model_path - ) - return + self.logger.write_to_log(msg) # populate tree root = list(self.signal_provider.data.keys())[0]