From 7ab4ab11d5a3175bf8b6da9856e9ad3e7d6b9b3c Mon Sep 17 00:00:00 2001 From: Chris Iverach-Brereton Date: Tue, 2 Sep 2025 12:11:20 -0400 Subject: [PATCH 1/4] Instead of manually remapping topics, rewrite the parameters to apply namespaces as needed --- turtlebot4_navigation/launch/slam.launch.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/turtlebot4_navigation/launch/slam.launch.py b/turtlebot4_navigation/launch/slam.launch.py index da36780..2a02a35 100644 --- a/turtlebot4_navigation/launch/slam.launch.py +++ b/turtlebot4_navigation/launch/slam.launch.py @@ -29,6 +29,8 @@ from launch.substitutions import LaunchConfiguration, PathJoinSubstitution from launch_ros.actions import PushRosNamespace, SetRemap +from nav2_common.launch import RewrittenYaml + pkg_turtlebot4_navigation = get_package_share_directory('turtlebot4_navigation') pkg_slam_toolbox = get_package_share_directory('slam_toolbox') @@ -71,14 +73,21 @@ def launch_setup(context, *args, **kwargs): launch_slam_async = PathJoinSubstitution( [pkg_slam_toolbox, 'launch', 'online_async_launch.py']) + rewritten_slam_params = RewrittenYaml( + source_file=slam_params, + root_key=namespace_str, + param_rewrites={ + 'map_name': namespace_str + '/map', + 'scan_topic': namespace_str + '/scan', + }, + convert_types=True, + ) + slam = GroupAction([ PushRosNamespace(namespace), SetRemap('/tf', namespace_str + '/tf'), SetRemap('/tf_static', namespace_str + '/tf_static'), - SetRemap('/scan', namespace_str + '/scan'), - SetRemap('/map', namespace_str + '/map'), - SetRemap('/map_metadata', namespace_str + '/map_metadata'), IncludeLaunchDescription( PythonLaunchDescriptionSource(launch_slam_sync), @@ -86,7 +95,7 @@ def launch_setup(context, *args, **kwargs): ('use_sim_time', use_sim_time), ('autostart', autostart), ('use_lifecycle_manager', use_lifecycle_manager), - ('slam_params_file', slam_params) + ('slam_params_file', rewritten_slam_params) ], condition=IfCondition(sync) ), @@ -97,7 +106,7 @@ def launch_setup(context, *args, **kwargs): ('use_sim_time', use_sim_time), ('autostart', autostart), ('use_lifecycle_manager', use_lifecycle_manager), - ('slam_params_file', slam_params) + ('slam_params_file', rewritten_slam_params) ], condition=UnlessCondition(sync) ) From 71fd1b7f91951b89ccb39c4755a86bff1368d055 Mon Sep 17 00:00:00 2001 From: Chris Iverach-Brereton Date: Tue, 2 Sep 2025 12:23:20 -0400 Subject: [PATCH 2/4] Add map_name parameter to the config so we can overwrite it correctly --- turtlebot4_navigation/config/slam.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/turtlebot4_navigation/config/slam.yaml b/turtlebot4_navigation/config/slam.yaml index eac796b..5489004 100644 --- a/turtlebot4_navigation/config/slam.yaml +++ b/turtlebot4_navigation/config/slam.yaml @@ -12,6 +12,7 @@ slam_toolbox: # ROS Parameters odom_frame: odom map_frame: map + map_name: /map base_frame: base_link scan_topic: /scan use_map_saver: true From 8b9a9a7af7cb23ec27273ea14e34f0ca284b0af0 Mon Sep 17 00:00:00 2001 From: Chris Iverach-Brereton Date: Tue, 2 Sep 2025 12:35:29 -0400 Subject: [PATCH 3/4] Remap the diagnostics topic too --- turtlebot4_navigation/launch/slam.launch.py | 1 + 1 file changed, 1 insertion(+) diff --git a/turtlebot4_navigation/launch/slam.launch.py b/turtlebot4_navigation/launch/slam.launch.py index 2a02a35..8f9044a 100644 --- a/turtlebot4_navigation/launch/slam.launch.py +++ b/turtlebot4_navigation/launch/slam.launch.py @@ -88,6 +88,7 @@ def launch_setup(context, *args, **kwargs): SetRemap('/tf', namespace_str + '/tf'), SetRemap('/tf_static', namespace_str + '/tf_static'), + SetRemap('/diagnostics', namespace_str + '/diagnostics'), IncludeLaunchDescription( PythonLaunchDescriptionSource(launch_slam_sync), From f5ffbcc33a88323162db19e57d1b434ff964fe91 Mon Sep 17 00:00:00 2001 From: Chris Iverach-Brereton Date: Tue, 2 Sep 2025 12:37:28 -0400 Subject: [PATCH 4/4] Revert "Remap the diagnostics topic too" This reverts commit 8b9a9a7af7cb23ec27273ea14e34f0ca284b0af0. --- turtlebot4_navigation/launch/slam.launch.py | 1 - 1 file changed, 1 deletion(-) diff --git a/turtlebot4_navigation/launch/slam.launch.py b/turtlebot4_navigation/launch/slam.launch.py index 8f9044a..2a02a35 100644 --- a/turtlebot4_navigation/launch/slam.launch.py +++ b/turtlebot4_navigation/launch/slam.launch.py @@ -88,7 +88,6 @@ def launch_setup(context, *args, **kwargs): SetRemap('/tf', namespace_str + '/tf'), SetRemap('/tf_static', namespace_str + '/tf_static'), - SetRemap('/diagnostics', namespace_str + '/diagnostics'), IncludeLaunchDescription( PythonLaunchDescriptionSource(launch_slam_sync),