I am lost :) Here is the problem (ROS2). Say, I have
params_file = LaunchConfiguration('params_file')
declare_params_file_cmd = DeclareLaunchArgument(
'params_file',
default_value=def_nav2_params_path
if robots[0]['name']=='' else def_nav2_params_path_multi,
description='Full path to the ROS2 parameters file to use for all launched nodes')
Now I have access to this command line parameter in some node:
params_file = LaunchConfiguration('params_file')
So far so good.
But let's say I want to modify the file in a "calling" code:
namespaced_params = ReplaceString(
source_file=params_file, replacements={
"namespace" : (namespace), # /robot1
"robot_name" : (robot['name']), # robot1
}
)
Now I want the node to use that modified file:
robot_localization_node = Node(
package='robot_localization',
executable='ekf_node',
name='ekf_filter_node',
namespace=namespace,
output='screen',
parameters=[namespaced_params, {'use_sim_time': use_sim_time }]
)
It works fine. However, we also have LaunchDescriptions, so I can call one launch file from another:
IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(def_launch_dir, 'bringup_launch.py')),
condition=LaunchConfigurationNotEquals('mode', 'simple'),
launch_arguments={
'namespace': namespace,
'use_namespace': 'True',
'slam': slam,
'map': map_yaml_file,
'keepout_mask': keepout_mask,
'use_sim_time': use_sim_time,
'params_file': namespaced_params,
'default_bt_xml_filename': default_bt_xml_filename,
'autostart': 'True' }.items()),
])
Here, I have passed namespaced_params to launch file, but I have no idea how to use it! Because in that launch file I see the already familiar
params_file = LaunchConfiguration('params_file')
which reads a command line argument, so I assume, it will get an initial, non-modifier params file. So how can I access namespaced_params?
Thank you.
=================
I'll try to rephrase it shorter: if in a "main" launch file I have
params_file = LaunchConfiguration('params_file')
declare_params_file_cmd = DeclareLaunchArgument(
'params_file',
default_value=def_nav2_params_path
if robots[0]['name']=='' else def_nav2_params_path_multi,
description='Full path to the ROS2 parameters file to use for all launched nodes')
and then I do this:
namespaced_params = ReplaceString(
source_file=params_file, replacements={
"namespace" : (namespace), # /robot1
"robot_name" : (robot['name']), # robot1
}
)
and pass namespaced_params as one of launch_arguments:
IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(def_launch_dir, 'bringup_launch.py')),
condition=LaunchConfigurationNotEquals('mode', 'simple'),
launch_arguments={
'namespace': namespace,
'use_namespace': 'True',
'slam': slam,
'map': map_yaml_file,
'keepout_mask': keepout_mask,
'use_sim_time': use_sim_time,
'params_file': namespaced_params,
'default_bt_xml_filename': default_bt_xml_filename,
'autostart': 'True' }.items()),
])
Then which of the two will I get inside bringup_launch.py, when I issue params_file = LaunchConfiguration('params_file') ?
In other words, how can I access launch_arguments that I passed to bringup_launch.py?