0
$\begingroup$

Rosanswers logo

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?


Originally posted by max11gen on ROS Answers with karma: 164 on 2019-01-24

Post score: 0


Original comments

Comment by gvdhoorn on 2019-01-24:
I believe this is a duplicate of (at least) #q199152.

Comment by max11gen on 2019-01-24:
@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?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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" />
    

Originally posted by Delb with karma: 3907 on 2019-01-24

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by max11gen on 2019-01-24:
Works perfect. Thanks a lot for the hint with the default bag, too :)

$\endgroup$

Your Answer

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