Ask Your Question
0

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:

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 -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">
  <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 imagedavidem ( 2019-11-27 08:28:18 -0600 )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 imagegvdhoorn ( 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 imageChoco93 ( 2019-11-27 08:41:22 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 15 times

Last updated: Nov 27