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

launch file parameters that have curly braces

asked 2019-11-26 11:48:16 -0600

davidem gravatar image

I am using ROS Melodic.
How can I set a parameter in a launch file that resembles a yaml syntax like this:

scan: {sensor_frame: base_scan, data_type: LaserScan, topic: scan, marking: true, clearing: true}

I know that generally, when there are parameters like:

  key: value
  foo: bar

it's sufficient to do <param name="SOMETHING/key" value="value" />, but I don't think it's the same for the curly braces, or is it?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-11-27 08:18:16 -0600

Choco93 gravatar image

updated 2019-11-27 08:21:54 -0600

You can use something like this,

<node pkg="my_pkg" name="my_node" type="my_node">
    key: value
    foo: bar


You can also make a yaml file and load it in your launch file like <rosparam file="$(find my_pkg)/config/my_params.yaml" />

edit flag offensive delete link more


does this work with curly braces too? being

    key: {a: $(arg foo)/value, b: $(arg foo)/value}
    foo: bar

EDIT: no, I'm sorry but it doesn't. The error says it clearly: RLException: error loading <rosparam> tag: Error within YAML block: mapping values are not allowed here

davidem gravatar image davidem  ( 2019-11-27 08:28:18 -0600 )edit

Everything in a rosparam tag is pure yaml. So dictionaries (what you call "curly braces") are fully supported. See the documentation.

Edit: o, you want to replace parts based on roslaunchargs? You'll have to enable substitution for that (ie: set subst_value to True).

Again: refer to the documentation.

gvdhoorn gravatar image gvdhoorn  ( 2019-11-27 08:31:34 -0600 )edit

Never tried it but probably key/a: should work too. And if you want to use a dictionary, I have used it and it works. key: {'a': $(arg foo)/value, 'b': $arg(foo)/value} should work I guess.

Choco93 gravatar image Choco93  ( 2019-11-27 08:41:22 -0600 )edit

Question Tools

1 follower


Asked: 2019-11-26 11:48:16 -0600

Seen: 316 times

Last updated: Nov 27 '19