From 36047f75f011d6a639e24c2d8e4343e1b13bb226 Mon Sep 17 00:00:00 2001 From: iwatake Date: Tue, 3 Dec 2024 17:00:54 +0900 Subject: [PATCH] chore: ignore rosbag recorder (#19) * chore: ignore rosbag2_recorder * chore: organize default layout Signed-off-by: iwatake2222 --------- Signed-off-by: iwatake2222 --- setting.json | 32 +++++++++++++++++------ src/dear_ros_node_viewer/dot2networkx.py | 2 ++ src/dear_ros_node_viewer/graph_manager.py | 10 +++---- src/dear_ros_node_viewer/ros2networkx.py | 10 ++++--- src/dear_ros_node_viewer/setting.json | 32 +++++++++++++++++------ 5 files changed, 61 insertions(+), 25 deletions(-) diff --git a/setting.json b/setting.json index 659cad1..58f27f0 100644 --- a/setting.json +++ b/setting.json @@ -5,7 +5,8 @@ "ignore_unconnected_nodes": true, "ignore_node_list": [ "/node_name/to_be_ignored/in_regularexpression", - "/wild_card/is/.*" + "/wild_card/is/.*", + "/rosbag2_recorder" ], "ignore_topic_list": [ "/topic_name/to_be_ignored/in_regularexpression", @@ -17,37 +18,52 @@ "group_setting": { "/sensing": { "direction": "horizontal", - "offset": [0.0, 1.0, 2.5, 2.0], + "offset": [0.0, 0.0, 2.5, 2.0], "color": [128, 0, 128] }, "/localization": { "direction": "horizontal", - "offset": [0.0, 3.5, 2.5, 2.0], + "offset": [0.0, 2.5, 2.5, 2.0], + "color": [0, 0, 128] + }, + "/map": { + "direction": "horizontal", + "offset": [0.0, 4.5, 1.0, 1.0], "color": [0, 0, 128] }, "/perception": { "direction": "horizontal", - "offset": [3.0, 3.5, 4.0, 4.0], + "offset": [3.0, 0.0, 7.0, 3.0], "color": [0, 128, 0] }, "/planning": { "direction": "horizontal", - "offset": [7.0, 0.0, 4.0, 4.0], + "offset": [3.0, 3.0, 4.0, 2.0], "color": [128, 128, 0] }, "/control": { "direction": "horizontal", - "offset": [3.0, -0.8, 3.0, 1.5], + "offset": [8.0, 3.0, 3.0, 1.5], "color": [196, 64, 0] }, "/system": { "direction": "horizontal", - "offset": [-0.5, -0.5, 1.0, 1.0], + "offset": [7.0, 6.0, 1.0, 5.0], "color": [64, 64, 128] }, + "/adapi": { + "direction": "horizontal", + "offset": [8.0, 6.0, 1.0, 5.0], + "color": [0, 64, 64] + }, + "/default_ad_api": { + "direction": "horizontal", + "offset": [9.0, 6.0, 1.0, 2.0], + "color": [0, 64, 64] + }, "__others__": { "direction": "horizontal", - "offset": [0.5, -0.5, 1.0, 1.0], + "offset": [11.0, 6.0, 2.0, 5.0], "color": [16, 64, 96] } } diff --git a/src/dear_ros_node_viewer/dot2networkx.py b/src/dear_ros_node_viewer/dot2networkx.py index ac3823d..1ddbbf9 100644 --- a/src/dear_ros_node_viewer/dot2networkx.py +++ b/src/dear_ros_node_viewer/dot2networkx.py @@ -37,6 +37,8 @@ def dot2networkx_nodeonly(graph_org: nx.classes.digraph.DiGraph, graph.add_node(label) for edge in graph_org.edges: + if 'label' not in graph_org.nodes[edge[0]] or 'label' not in graph_org.nodes[edge[1]] or 'label' not in graph_org.edges[edge]: + continue node_pub = graph_org.nodes[edge[0]]['label'] node_sub = graph_org.nodes[edge[1]]['label'] label = graph_org.edges[edge]['label'] diff --git a/src/dear_ros_node_viewer/graph_manager.py b/src/dear_ros_node_viewer/graph_manager.py index 97fc910..402fa2e 100644 --- a/src/dear_ros_node_viewer/graph_manager.py +++ b/src/dear_ros_node_viewer/graph_manager.py @@ -84,6 +84,11 @@ def filter_node(self): self.graph.remove_nodes_from(remove_node_list) logger.info('%s nodes are removed by filter', len(remove_node_list)) + if self.app_setting['ignore_unconnected_nodes']: + isolated_node_list = list(nx.isolates(self.graph)) + logger.info('%s nodes are removed due to isolated', len(isolated_node_list)) + self.graph.remove_nodes_from(isolated_node_list) + def filter_topic(self): """Remove topics which match filter setting""" remove_edge_list = [] @@ -97,11 +102,6 @@ def filter_topic(self): self.graph.remove_edges_from(remove_edge_list) logger.info('%s topics are removed by filter', len(remove_edge_list)) - if self.app_setting['ignore_unconnected_nodes']: - isolated_node_list = list(nx.isolates(self.graph)) - logger.info('%s nodes are removed due to isolated', len(isolated_node_list)) - self.graph.remove_nodes_from(isolated_node_list) - def clear_caret_path_dict(self): """ Clear CARET path dict """ self.caret_path_dict.clear() diff --git a/src/dear_ros_node_viewer/ros2networkx.py b/src/dear_ros_node_viewer/ros2networkx.py index 845ce8e..ca0d581 100644 --- a/src/dear_ros_node_viewer/ros2networkx.py +++ b/src/dear_ros_node_viewer/ros2networkx.py @@ -60,16 +60,19 @@ def save_graph(self, filename: str = None) -> str: time.sleep(5) graph = Graph(self.node_) graph.set_node_stale(5.0) + logger.info('graph.update start') graph.update() + logger.info('graph.update done') dotcode_generator = RosGraphDotcodeGenerator(self.node_) + logger.info('generate_dotcode start') dotcode = dotcode_generator.generate_dotcode( rosgraphinst=graph, - ns_filter='', + ns_filter='-/rosbag2_recorder', topic_filter='', # graph_mode='node_topic', graph_mode='node_node', - hide_single_connection_topics=True, + hide_single_connection_topics=False, hide_dead_end_topics=True, cluster_namespaces_level=0, # accumulate_actions=accumulate_actions, @@ -77,11 +80,10 @@ def save_graph(self, filename: str = None) -> str: # orientation=orientation, quiet=True, unreachable=True, - group_tf_nodes=True, hide_tf_nodes=True, - # group_image_nodes=group_image_nodes, hide_dynamic_reconfigure=True ) + logger.info('generate_dotcode done') if filename: with open(filename, encoding='UTF8', mode='w') as dot_file: diff --git a/src/dear_ros_node_viewer/setting.json b/src/dear_ros_node_viewer/setting.json index 659cad1..58f27f0 100644 --- a/src/dear_ros_node_viewer/setting.json +++ b/src/dear_ros_node_viewer/setting.json @@ -5,7 +5,8 @@ "ignore_unconnected_nodes": true, "ignore_node_list": [ "/node_name/to_be_ignored/in_regularexpression", - "/wild_card/is/.*" + "/wild_card/is/.*", + "/rosbag2_recorder" ], "ignore_topic_list": [ "/topic_name/to_be_ignored/in_regularexpression", @@ -17,37 +18,52 @@ "group_setting": { "/sensing": { "direction": "horizontal", - "offset": [0.0, 1.0, 2.5, 2.0], + "offset": [0.0, 0.0, 2.5, 2.0], "color": [128, 0, 128] }, "/localization": { "direction": "horizontal", - "offset": [0.0, 3.5, 2.5, 2.0], + "offset": [0.0, 2.5, 2.5, 2.0], + "color": [0, 0, 128] + }, + "/map": { + "direction": "horizontal", + "offset": [0.0, 4.5, 1.0, 1.0], "color": [0, 0, 128] }, "/perception": { "direction": "horizontal", - "offset": [3.0, 3.5, 4.0, 4.0], + "offset": [3.0, 0.0, 7.0, 3.0], "color": [0, 128, 0] }, "/planning": { "direction": "horizontal", - "offset": [7.0, 0.0, 4.0, 4.0], + "offset": [3.0, 3.0, 4.0, 2.0], "color": [128, 128, 0] }, "/control": { "direction": "horizontal", - "offset": [3.0, -0.8, 3.0, 1.5], + "offset": [8.0, 3.0, 3.0, 1.5], "color": [196, 64, 0] }, "/system": { "direction": "horizontal", - "offset": [-0.5, -0.5, 1.0, 1.0], + "offset": [7.0, 6.0, 1.0, 5.0], "color": [64, 64, 128] }, + "/adapi": { + "direction": "horizontal", + "offset": [8.0, 6.0, 1.0, 5.0], + "color": [0, 64, 64] + }, + "/default_ad_api": { + "direction": "horizontal", + "offset": [9.0, 6.0, 1.0, 2.0], + "color": [0, 64, 64] + }, "__others__": { "direction": "horizontal", - "offset": [0.5, -0.5, 1.0, 1.0], + "offset": [11.0, 6.0, 2.0, 5.0], "color": [16, 64, 96] } }