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

Rosparam dump from launch file

asked 2012-06-18 05:19:33 -0500

narcispr gravatar image

updated 2012-07-02 13:47:01 -0500

mjcarroll gravatar image

Hi, I'm trying to record all the parameters I'm using each time I execute a launch file. I've added the following line at the end of my launch file:

<rosparam command="dump" file="parameters_dump.yaml"/>

However, the only thing this file contains is:

roslaunch: uris: {host_my_name_mbp__45687: 'http://my_name-mbp:45687/'} run_id: 9a82c640-b958-11e1-a381-3c0754675d16

It seems like if the dump command is done before all the parameters are loaded in the param server. Any idea?

Thank you!

P.S. If I do a: $ rosparam dump parameters_dump.yam

from the command line once the vehicle has started, it works.

edit retag flag offensive close merge delete

5 Answers

Sort by ยป oldest newest most voted

answered 2012-06-18 05:56:09 -0500

If you run roslaunch with --dump-params, it will dump all of the parameters to stdout, which you can then redirect wherever you want. This won't actually start any nodes, but it will tell you what parameters they would have been started with.

edit flag offensive delete link more

answered 2012-06-18 06:47:03 -0500

Lorenz gravatar image

updated 2012-06-18 06:48:16 -0500

roslaunch first parses your launch file and all included launch files in order and creates an ordered list of parameters to set. Parameter definitions that are parsed later overwrite earlier definitions. After all parameters are parsed, they are set on the parameter server. That means, parameters cannot reference other parameters. rosparam dump will only dump parameters that have been set before you called roslaunch.

What should work though is dumping the parameters in a node since nodes are executed after the parameters are set. Try the following:

<node name="dump_parameters" pkg="rosparam" type="rosparam" args="dump parameters_dump.yaml" />

Note that the file will be created in your ROS_HOME, i.e. ~/.ros per default. If you want to change that, use an absolute path for your output file. You can also use something like $(find <ros package>)/parameters_dump.yaml to put the file into a ROS package. Of course, that package must not be a system package but a user package since you need write permissions to its directory.

edit flag offensive delete link more


It does not work for me :( Even if when everything is running I write in the command line: "$rosrun rosparam dump params.yaml" any file is created.

narcispr gravatar image narcispr  ( 2012-06-19 04:46:57 -0500 )edit

It does not work for me :( Even if when everything is running I write in the command line I write $rosrun rosparam dump params.yaml

narcispr gravatar image narcispr  ( 2012-06-19 04:47:00 -0500 )edit

Then probably the rosparam dump command doesn't work. I didn't test. Unfortunately, you cannot run a program that is in your path. For that you'd need a wrapper script. Since roslaunch --dump-params seems to work for you, I won't add an example script to my answer unless someone wants it :)

Lorenz gravatar image Lorenz  ( 2012-06-19 04:55:22 -0500 )edit

answered 2018-10-30 20:34:24 -0500

aschaefer gravatar image

updated 2018-10-31 21:06:26 -0500

As joq and dornhege pointed out, you cannot control the order in which nodes are started. When I encountered this problem, I added the following node to my launch script:

<node name="dump_rosparams" 
      args="'sleep 5; rosparam dump ~/ROS/params.yaml'"/>

It simply waits five seconds for all other nodes to start, and then dumps the parameters to the given file.

If you are interested in the last set of parameters before shutdown, save them periodically until ROS shutdown:

<node name="dump_rosparams" 
      args="'while true; do rosparam dump ~/ROS/params.yaml; sleep 5; done'"/>

For the above options to work, you need to install the aliencontrol package. And please make sure the command is enclosed in single quotes inside XML's double quotes, because aliencontrol expects the command to execute to be a single argument.

edit flag offensive delete link more



As nice as this is, it's time based, which means that the 5 seconds is a twiddle factor (ie: it may work for you, but on slower systems it may not). That is inherently fragile.

If it was state based (ie: wait for parameter initialisation and then dump them), that would be really useful.

gvdhoorn gravatar image gvdhoorn  ( 2018-10-31 02:44:40 -0500 )edit

ROS parameters are a function of time. In ROS, there is no way of telling whether a node is done uploading parameters or whether it will upload or change parameters in the future.

That said, I edited my answer to show how to obtain the most recent set of ROS parameters.

aschaefer gravatar image aschaefer  ( 2018-10-31 20:59:43 -0500 )edit

ROS parameters are a function of time

exactly. So technically what the OP asks is not possible, or at least, there is a very strong limitation in that it can never be said to write "all" parameters to a file.

gvdhoorn gravatar image gvdhoorn  ( 2018-11-01 02:06:00 -0500 )edit

answered 2012-06-18 05:47:32 -0500

joq gravatar image

The launch file is not a script. Nodes do not run in any guaranteed order.

All I can think of to suggest is writing a node of your own that waits until it looks like all the parameters have been set, then invokes the dump command.

Maybe someone else has a better idea.

edit flag offensive delete link more

answered 2012-06-18 05:44:54 -0500

dornhege gravatar image

Are you including the launch file in the generic startup launch file?

That won't work as there is no order to when things in a launch file are executed. In that case you dump launch will probably be finished before anything else is started.

edit flag offensive delete link more

Question Tools


Asked: 2012-06-18 05:19:33 -0500

Seen: 3,274 times

Last updated: Oct 31 '18