From 96870a9affb5ed19886f7eee57f0ae6e3858a5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=BB=E5=B9=B3=E9=9D=99=EF=BC=88ren=5Fpingjing?= =?UTF-8?q?=EF=BC=89?= <95092734+jiujiujiur0000@users.noreply.github.com> Date: Fri, 22 May 2026 23:06:12 +0800 Subject: [PATCH 1/2] fix(gazebo): fix duplicate TF tree issue by removing unexpected trailing slash in frame_prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description In ROS 2, frame_ids do not start with a forward slash `/`. However, in `robot_state_publisher.launch.py`, `PythonExpression(["'", frame_prefix, "/'"])` forces `frame_prefix` to become `/` when no namespace is provided (since the default is `''`). This causes `robot_state_publisher` to broadcast frames with an unexpected leading slash (e.g., `/base_link`), resulting in unconnected double TF trees and warnings in visualization tools like Foxglove Studio, and potential `tf2::LookupException` in Nav2. ###🗣️ Fix Modified the `frame_prefix` evaluation to avoid appending the trailing slash when `frame_prefix` is empty. Signed-off-by: 任平静(ren_pingjing) <95092734+jiujiujiur0000@users.noreply.github.com> --- turtlebot3_gazebo/launch/robot_state_publisher.launch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/turtlebot3_gazebo/launch/robot_state_publisher.launch.py b/turtlebot3_gazebo/launch/robot_state_publisher.launch.py index a4827da0..75b255da 100644 --- a/turtlebot3_gazebo/launch/robot_state_publisher.launch.py +++ b/turtlebot3_gazebo/launch/robot_state_publisher.launch.py @@ -56,7 +56,7 @@ def generate_launch_description(): parameters=[{ 'use_sim_time': use_sim_time, 'robot_description': robot_desc, - 'frame_prefix': PythonExpression(["'", frame_prefix, "/'"]) +                'frame_prefix': PythonExpression(["'", frame_prefix, "' + '/' if '", frame_prefix, "' != '' else ''"]) }], ), ]) From 9bfc0ca2f1af17d9655028d2f3984f8486546e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=BB=E5=B9=B3=E9=9D=99=EF=BC=88ren=5Fpingjing?= =?UTF-8?q?=EF=BC=89?= <95092734+jiujiujiur0000@users.noreply.github.com> Date: Fri, 22 May 2026 23:11:22 +0800 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: 任平静(ren_pingjing) <95092734+jiujiujiur0000@users.noreply.github.com> --- turtlebot3_gazebo/launch/robot_state_publisher.launch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/turtlebot3_gazebo/launch/robot_state_publisher.launch.py b/turtlebot3_gazebo/launch/robot_state_publisher.launch.py index 75b255da..b07eacad 100644 --- a/turtlebot3_gazebo/launch/robot_state_publisher.launch.py +++ b/turtlebot3_gazebo/launch/robot_state_publisher.launch.py @@ -56,7 +56,7 @@ def generate_launch_description(): parameters=[{ 'use_sim_time': use_sim_time, 'robot_description': robot_desc, -                'frame_prefix': PythonExpression(["'", frame_prefix, "' + '/' if '", frame_prefix, "' != '' else ''"]) + 'frame_prefix': PythonExpression(["'", frame_prefix, "' + '/' if '", frame_prefix, "' != '' else ''"]) }], ), ])