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

Rosparam dump from launch file

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

narcispr gravatar image

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

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
1

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

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
6

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

Lorenz gravatar image

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

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

Comments

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.

narcispr gravatar image narcispr  ( 2012-06-19 04:46:57 -0600 )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

narcispr gravatar image narcispr  ( 2012-06-19 04:47:00 -0600 )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 -0600 )edit
1

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

aschaefer gravatar image

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

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.

edit flag offensive delete link more

Comments

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.

gvdhoorn gravatar image gvdhoorn  ( 2018-10-31 02:44:40 -0600 )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 -0600 )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 -0600 )edit
0

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

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
0

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

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

Question Tools

Stats

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

Seen: 3,435 times

Last updated: Oct 31 '18