0
$\begingroup$

Rosanswers logo

I am aiming to write a bag recording launch script for two same robots with different storage configuration, hence the stored location for the robots will be different.
The robots name are in rosparam. How do I read the publishing /robot_name in a launch script and then do a if statement to change my current recording node .

 <group if="$(eval arg('robot_name') == robot_name_rosparam)">
      <node pkg="rosbag" type="record" args="record -o /directory /topics">
 <group>

Originally posted by chaoshydra on ROS Answers with karma: 3 on 2019-12-04

Post score: 0


Original comments

Comment by Choco93 on 2019-12-05:
#q213145 is dealing with something similar, take a look and see if that's what you are trying to do.

Comment by chaoshydra on 2019-12-05:
@Choco93, I did check that answer when I was searching. It is for loading yaml file to set rosparameter. In my case, the rosparam is already set, I wish to read its value.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Here is one way that can be done.

<arg name="foo"/>
<arg name="bar"/>
<arg name ="dir1" value="directory1"/>

<node pkg="rosbag" type="record" name="recorder" args="-o $(arg dir1)/($arg foo)"/>

and you launch this file like roslaunch my_pkg my_launch.launch foo:=$(rosparam get foo).


Originally posted by Choco93 with karma: 685 on 2019-12-06

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by gvdhoorn on 2019-12-06:
Pedantic, but this is using args, which are not the same as ROS parameters.

Comment by Choco93 on 2019-12-06:
Yeah, have to get that param into launchfile somehow. Might be possible to do it directly in launchfile but couldn't find a way for that.

Comment by gvdhoorn on 2019-12-06:
I don't believe it's actually supported.

Comment by Choco93 on 2019-12-06:
What my answer suggests works, don't know about doing same within launchfile.

Comment by gvdhoorn on 2019-12-06:
Yes, it works, but it doesn't actually use ROS parameters.

But perhaps this is already what the OP was asking for. Let's wait and see.

Comment by chaoshydra on 2019-12-09:
Yes, I have done something like that by passing a variable in the launch file.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.