"get" /run_id param into an arg with roslaunch

I would like to grab the rosmaster parameter /run_id inside the launchfile that brings up a rosbag node, in order to add it to the rosbag file's name. run_id is the session id associated with this particular instance of a rosmaster, and is in fact available from the parameter server when the rosbag node comes up. I know this because I can dump the run_id parameter uuid value into a yaml file during the launch. Unfortunately, I cannot find a way in the documentation to get access to this value from within the roslaunch script.
For instance, here is the output of the rosmaster as it is being brought up by roslaunch:

PARAMETERS
* /rosdistro: indigo

NODES

auto-starting new master
process[master]: started with pid [1751]
ROS_MASTER_URI=http://Threepio:11311/

setting /run_id to c297c6dc-1c35-11e6-bff7-cc3d821b2187
process[rosout-1]: started with pid [1769]
started core service [/rosout]


The run_id uuid is set and displayed right there.
Here is my roslaunch file (used to bring up the above master) where I can grab the parameter, but have no mechanism for transferring this parameter value into an arg or param to be substituted in the launch syntax:

<launch>
<arg name="run_id" default="abc"/>
<rosparam command="dump" param="/run_id" file="/tmp/foobar.yaml"/>
<node name="record" pkg="rosbag" type="record" args="-e /rosout --bz2 --split --size=20 -o
/data/users/foobar/ros_ws/src/bag_pkg/launch/bagfile_$(arg run_id)_$(env USER)"/>
</launch>


As you can see, the rosparam dump to a file works fine:

   $cat /tmp/foobar.yaml c297c6dc-1c35-11e6-bff7-cc3d821b2187 ...  tl;dr: Is it possible to "get" the rosparam /run_id with the ROS Indigo roslaunch xml syntax? edit retag close merge delete 1 Answer Sort by » oldest newest most voted I'm also trying the do the same thing. My currently, ugly, workaround is this: test.launch just expects an argument:  <launch> <arg name="run_id"/> ... <param name="run_id" value="$(arg run_id)"/> </launch> 

and from the command line, the gross part:

 $roscore & COREPID=$! ; sleep 1; roslaunch test.launch run_id:=$(roslaunch-logs | rev | cut -d/ -f1 | rev) ; kill$COREPID 

You might also use the $(eval script) syntax, though it's only available in Kinetic. There should be a better 'official' way to do this, like value="$(run_id)".

more

2

There should be a better 'official' way to do this, like value="\$(run_id)".

You could consider opening an enhancement request over at github.com/ros/ros_comm.

( 2016-08-13 03:52:46 -0600 )edit