From 9b194f680d681cf13a98be7f60a000ac1c67a708 Mon Sep 17 00:00:00 2001 From: YuxuanLiuTier4Desktop <619684051@qq.com> Date: Fri, 1 Nov 2024 14:12:31 +0900 Subject: [PATCH] fix a bug in launch xml parser that cause error when getting same launch file in different name-space Signed-off-by: YuxuanLiuTier4Desktop <619684051@qq.com> --- .../launch_file_analyse/launch_xml_parser.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/autoware_debug_tools/autoware_debug_tools/topic_connection_checker/launch_file_analyse/launch_xml_parser.py b/common/autoware_debug_tools/autoware_debug_tools/topic_connection_checker/launch_file_analyse/launch_xml_parser.py index fd253d94..22db3869 100644 --- a/common/autoware_debug_tools/autoware_debug_tools/topic_connection_checker/launch_file_analyse/launch_xml_parser.py +++ b/common/autoware_debug_tools/autoware_debug_tools/topic_connection_checker/launch_file_analyse/launch_xml_parser.py @@ -231,7 +231,7 @@ def process_include_tag( if included_file: context["__tree__"].add_child( context["__current_launch_name_"], - os.path.basename(included_file), + f"{group_base_namespace}/{os.path.basename(included_file)}", path=included_file, ) if included_file.startswith("/opt/ros/humble") and (not FLAG_CHECKING_SYSTEM_PROJECTS): @@ -289,12 +289,12 @@ def parse_group_tag( if parent_file_space is None: parent_file_space = base_namespace # find the push-ros-namespace tag inside the children - group_base_namespace = deepcopy(base_namespace) + group_base_namespace = deepcopy(parent_file_space) for child in group_tag: if child.tag == "push-ros-namespace": if child.get("namespace").strip() == "/": continue - group_base_namespace = f"{base_namespace}/{child.get('namespace').strip('/')}" + group_base_namespace = f"{group_base_namespace}/{child.get('namespace').strip('/')}" # print(f"Setting ROS namespace to {group_base_namespace} inside group") # find all other children @@ -329,7 +329,7 @@ def process_tag( elif tag.tag == "let": context = parse_let_tag(tag, base_namespace, context, local_context) elif tag.tag == "group": - context = parse_group_tag(tag, base_namespace, context, local_context) + context = parse_group_tag(tag, base_namespace, context, local_context, group_base_namespace) elif tag.tag == "include": context = process_include_tag( tag, context, local_context, base_namespace, group_base_namespace @@ -347,7 +347,7 @@ def parse_xml(file_path: str, namespace: str = "", context: dict = {}): """Recursively parse XML files, handling tags. For each file, the namespace should be the same.""" full_path = os.path.join(file_path) context["__current_launch_file__"] = full_path - context["__current_launch_name_"] = os.path.basename(full_path) + context["__current_launch_name_"] = f"{namespace}/{os.path.basename(full_path)}" if "__tree__" not in context: context["__tree__"] = LaunchTree() if context["__tree__"].root is None: