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

"get" /run_id param into an arg with roslaunch

asked 2016-05-17 11:58:49 -0500

imcmahon gravatar image

updated 2016-05-17 16:14:23 -0500

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-08-05 15:20:28 -0500

tfurf gravatar image

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)".

edit flag offensive delete link more

Comments

3

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.

gvdhoorn gravatar image gvdhoorn  ( 2016-08-13 03:52:46 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2016-05-17 11:58:49 -0500

Seen: 2,409 times

Last updated: Aug 05 '16