How to set arg in launch file via code/command/rosparam?
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?
Notes:
- 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 makedate
anarg
in the first place. If Idea 3 has a solution, I could make use aparam
in general. - I cannot depend on external launch bash files to pass in the data, because the launch file should be self-contained.
Maybe my roslaunch2 package can help you: https://github.com/CodeFinder2/roslau...