Skip to content

Commit 54dbb20

Browse files
Fix SLAM parameter passing (#631)
* Instead of manually remapping topics, rewrite the parameters to apply namespaces as needed * Add map_name parameter to the config so we can overwrite it correctly
1 parent d5320c9 commit 54dbb20

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

turtlebot4_navigation/config/slam.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ slam_toolbox:
1212
# ROS Parameters
1313
odom_frame: odom
1414
map_frame: map
15+
map_name: /map
1516
base_frame: base_link
1617
scan_topic: /scan
1718
use_map_saver: true

turtlebot4_navigation/launch/slam.launch.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
3030
from launch_ros.actions import PushRosNamespace, SetRemap
3131

32+
from nav2_common.launch import RewrittenYaml
33+
3234
pkg_turtlebot4_navigation = get_package_share_directory('turtlebot4_navigation')
3335
pkg_slam_toolbox = get_package_share_directory('slam_toolbox')
3436

@@ -71,22 +73,29 @@ def launch_setup(context, *args, **kwargs):
7173
launch_slam_async = PathJoinSubstitution(
7274
[pkg_slam_toolbox, 'launch', 'online_async_launch.py'])
7375

76+
rewritten_slam_params = RewrittenYaml(
77+
source_file=slam_params,
78+
root_key=namespace_str,
79+
param_rewrites={
80+
'map_name': namespace_str + '/map',
81+
'scan_topic': namespace_str + '/scan',
82+
},
83+
convert_types=True,
84+
)
85+
7486
slam = GroupAction([
7587
PushRosNamespace(namespace),
7688

7789
SetRemap('/tf', namespace_str + '/tf'),
7890
SetRemap('/tf_static', namespace_str + '/tf_static'),
79-
SetRemap('/scan', namespace_str + '/scan'),
80-
SetRemap('/map', namespace_str + '/map'),
81-
SetRemap('/map_metadata', namespace_str + '/map_metadata'),
8291

8392
IncludeLaunchDescription(
8493
PythonLaunchDescriptionSource(launch_slam_sync),
8594
launch_arguments=[
8695
('use_sim_time', use_sim_time),
8796
('autostart', autostart),
8897
('use_lifecycle_manager', use_lifecycle_manager),
89-
('slam_params_file', slam_params)
98+
('slam_params_file', rewritten_slam_params)
9099
],
91100
condition=IfCondition(sync)
92101
),
@@ -97,7 +106,7 @@ def launch_setup(context, *args, **kwargs):
97106
('use_sim_time', use_sim_time),
98107
('autostart', autostart),
99108
('use_lifecycle_manager', use_lifecycle_manager),
100-
('slam_params_file', slam_params)
109+
('slam_params_file', rewritten_slam_params)
101110
],
102111
condition=UnlessCondition(sync)
103112
)

0 commit comments

Comments
 (0)