How to set arg in launch file via code/command/rosparam?

asked 2018-11-20 09:43:15 -0500

bluenote gravatar image

Let's assume I have an arg in a launch file:

<arg name="date" />

My problem: I want to set the value of the arg dymically via code. The following ideas came to my mind:

Idea 1: Use command like it is possible with param:

<arg name="date" command="date -I" />

Unfortunately, arg doesn't support command, only value is allowed.

Idea 2: Set it via eval running an external command:

<arg name="date" value="$(eval os.system('date -I')" />

Unfortunately, os isn't imported and I can't find a way to run an external program within eval.

Idea 3: Inherit the value from a param:

<param name="date" command="date -I" />
<arg name="date" value="..." />

The first line works, but so far I haven't found a way to convert the ros param date into the arg though. I was assuming that there must be something like $(eval param("date")) similar to $(eval arg("date")).

This seems like a very basic problem, but I can't figure out a solution. Is it possible to make any of these 3 ideas work, or is there a different solution?


  • I make use of the arg in various other places in the launch file in expressions like $(arg date) or $(eval arg('date') + '_suffix'), which is why I had to make date an arg in the first place. If Idea 3 has a solution, I could make use a param in general.
  • I cannot depend on external launch bash files to pass in the data, because the launch file should be self-contained.
edit retag flag offensive close merge delete


Maybe my roslaunch2 package can help you:

CodeFinder gravatar image CodeFinder  ( 2020-06-23 17:58:30 -0500 )edit