Build file path from parameters in ROS2 Foxy launchfile

asked 2022-02-08 16:36:25 -0500

Mackou gravatar image

updated 2022-02-08 16:41:01 -0500

Hello, I am struggling with ROS2 launchfiles, I would like to do something that was very simple in ROS1 :

  <node pkg="lidar_fake_perception" type="lidar_fake_perception_node" name="lidar_fake_perception" output="screen">
    <param name="config_path" value="/root/$(arg my_arg).yaml"/>
  </node>

Here you can see that I build the path from from my_arg and I append .yaml at the end to create the filename. Somehow I'm totally unable to do the same in ROS2 python launchfile.

To create the path, it seems that using PathJoinSubstitution is the way to go, but how do I concatenate my LaunchArgument my_arg with .yaml to create the launchfile ?

I tried this but it doesn't work :

my_arg = DeclareLaunchArgument("my_arg", default_value='config_file_name')
config_path = DeclareLaunchArgument("config_path", default_value=PathJoinSubstitution([
    '/root/config',
    TextSubstitution(LaunchConfiguration(my_arg), TextSubstitution(text='.yaml'))
]))

I intend to give the path to a node as a parameter later.

Thanks a lot for your help !

edit retag flag offensive close merge delete