2525import launch
2626from launch .frontend import Parser
2727from launch .launch_description_sources import get_launch_description_from_any_launch_file
28+ from launch_ros .actions import SetRemap
2829
2930
3031class MultipleLaunchFilesError (Exception ):
@@ -145,7 +146,8 @@ def launch_a_launch_file(
145146 noninteractive = False ,
146147 args = None ,
147148 option_extensions = {},
148- debug = False
149+ debug = False ,
150+ remap_rules = None
149151):
150152 """Launch a given launch file (by path) and pass it the given launch file arguments."""
151153 for name in sorted (option_extensions .keys ()):
@@ -167,14 +169,19 @@ def launch_a_launch_file(
167169 parsed_launch_arguments = parse_launch_arguments (launch_file_arguments )
168170 # Include the user provided launch file using IncludeLaunchDescription so that the
169171 # location of the current launch file is set.
170- launch_description = launch .LaunchDescription ([
172+ launch_description = launch .LaunchDescription ()
173+ if remap_rules is not None :
174+ for remap_rule in remap_rules :
175+ from_name , to_name = remap_rule .split (':=' , maxsplit = 1 )
176+ launch_description .add_action (SetRemap (src = from_name , dst = to_name ))
177+ launch_description .add_action (
171178 launch .actions .IncludeLaunchDescription (
172179 launch .launch_description_sources .AnyLaunchDescriptionSource (
173180 launch_file_path
174181 ),
175182 launch_arguments = parsed_launch_arguments ,
176183 ),
177- ] )
184+ )
178185 for name in sorted (option_extensions .keys ()):
179186 result = option_extensions [name ].prelaunch (
180187 launch_description ,
0 commit comments