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

Passing command line argument between multiple launch-files

asked 2019-01-24 05:08:17 -0500

max11gen gravatar image

updated 2019-01-24 05:37:09 -0500

I'm using a launch file master.launch that includes global_config.launch. In master.launch I define a command line argument using

<arg name="config_argument" />

and then I include global_config.launch

<include file="$(find package_name)/launch/global_config.launch" />

But I will need the argument to be available in global_config.launch. Is it possible pass the argument from the master.launch to the global_config.launch?

Thanks to gvdhoorn for linking that question. I changed my launchfiles as follows:
master.launch

  <arg name="rosbag_name" />  
  <include file="$(find neuromorphic_stereo)/launch/global_config.launch">  
    <arg name="rosbag_name" value="$(arg rosbag_name)" />  
  </include>

global_config.launch

<node pkg="rosbag" type="play" name="event_publisher" args="$(find neuromorphic_stereo)/rosbag_simulator/$(arg rosbag_name)_merged.bag" required="true" />

but now ros tells me

unused args [rosbag_name] for include of global_config.launch

even though I'm actually using it. What am I still doing wrong?

edit retag flag offensive close merge delete

Comments

I believe this is a duplicate of (at least) #q199152.

gvdhoorn gravatar image gvdhoorn  ( 2019-01-24 05:14:37 -0500 )edit

@gvdhoorn Thanks for linking the question gvdhoorn. It indeed seems to be a duplicate. Anyway I run in to problems using the suggested solution. I edited my question. Can you help me with that?

max11gen gravatar image max11gen  ( 2019-01-24 05:36:27 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
4

answered 2019-01-24 07:42:13 -0500

Delb gravatar image

You just have to define the arg in both launch files since you could be able to launch global_config without the master. By definning the arg in all the launch files, you still have the possibility to launch them individually (i.e. standalone). I would also advise to add a default value to avoid typing arguments if they are not changing too often :

  • master.launch :

    <arg name="rosbag_name" default="a_default_bag_file.bag" />  
    <include file="$(find neuromorphic_stereo)/launch/global_config.launch">  
        <arg name="rosbag_name" value="$(arg rosbag_name)" />  
    </include>
    
  • global_config.launch :

    <arg name="rosbag_name" default="a_default_bag_file.bag" /> 
    <node pkg="rosbag" type="play" name="event_publisher" args="$(find neuromorphic_stereo)/rosbag_simulator/$(arg rosbag_name)_merged.bag" required="true" />
    
edit flag offensive delete link more

Comments

1

Works perfect. Thanks a lot for the hint with the default bag, too :)

max11gen gravatar image max11gen  ( 2019-01-24 09:24:27 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-01-24 05:08:17 -0500

Seen: 624 times

Last updated: Jan 24 '19