ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

[ros2] Including a launch file in a launch file with parameter overrides

asked 2021-01-19 08:20:15 -0600

updated 2021-01-19 11:40:54 -0600

gvdhoorn gravatar image

I have two launch files and The B launch file has a set of parameters with default values. I want to include the B launch file in A so that launching A also launches B.

So far this works fine and I have no problems.

However, now I want to specify some parameter values in A that override the default values specified in B. How do I do this? It was pretty straightforward to do this in ROS 1 with the XML syntax, but I can't find any straightforward way to do in ROS 2 with the python launch file syntax.

My question is basically this one, but for ROS 2: #q62949.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-01-19 12:41:18 -0600

I believe I've answered my own question. I got it to work by adding a launch_arguments argument to the IncludeLaunchDescription command:


ld = IncludeLaunchDescription(
        os.path.join(pkg_prefix, '')))


ld = IncludeLaunchDescription(
        os.path.join(pkg_prefix, '')),
        'parameter_name1': 'parameter_value1',
        'parameter_name2': 'parameter_value2'

Note that both parameter name and value are strings. The value can also be a launch.Substitution, but I don't know how those work. The string value works for my purposes.

edit flag offensive delete link more


how do you then parse the launch arguments in

morten gravatar image morten  ( 2021-09-29 07:09:25 -0600 )edit

Instead of calling them 'parameters', it would be better to call them launch file arguments. What I imagine the questioner is doing in is declaring some launch file arguments which are then being used to set parameters. So to answer your question @morten, you would just declare a launch file argument in

swiz23 gravatar image swiz23  ( 2021-10-04 23:33:26 -0600 )edit

Question Tools



Asked: 2021-01-19 08:20:15 -0600

Seen: 731 times

Last updated: Jan 19 '21