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

launch file parameters that have curly braces

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

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:

SOMETHING:
  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
0

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

Choco93 gravatar image

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

You can use something like this,

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

EDIT:

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

Comments

does this work with curly braces too? being

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

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 -0500 )edit
1

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 -0500 )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 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 321 times

Last updated: Nov 27 '19