1
$\begingroup$

Rosanswers logo

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.


Originally posted by narcispr on ROS Answers with karma: 307 on 2012-06-18

Post score: 2


$\endgroup$

3 Answers 3

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Dan Lazewatsky with karma: 9115 on 2012-06-18

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by Lorenz with karma: 22731 on 2012-06-18

This answer was NOT ACCEPTED on the original site

Post score: 6


Original comments

Comment by narcispr on 2012-06-19:
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.

Comment by narcispr on 2012-06-19:
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

Comment by Lorenz on 2012-06-19:
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 :)

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by aschaefer with karma: 41 on 2018-10-30

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by gvdhoorn on 2018-10-31:
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.

Comment by aschaefer on 2018-10-31:
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.

Comment by gvdhoorn on 2018-11-01:\

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.