# Rosparam dump from launch file

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 close merge delete ## 5 Answers Sort by » oldest newest most voted 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. more 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.

more

It does not work for me :( Even if when everything is running I write in the command line: "$rosrun rosparam rosparam.py dump params.yaml" any file is created. ( 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 rosparam.py dump params.yaml

( 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 :)

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

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"
pkg="aliencontrol"
type="aliencontrol"
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"
pkg="aliencontrol"
type="aliencontrol"
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.

more

1

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.

( 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.

( 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.

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

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.

more

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.

more