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.