# Run .launch file with arg from .launch file

I would like to use a master .launch file to run another .launch file, but with an arg.

Specifically, I am attempting to create a .launch file which would be equivalent to running:

roslaunch openni_launch openni.launch camera:=openni


This is what I am currently attempting for my .launch file:

<launch>
<!-- Defining the arguments -->
<arg name="Kinect" value="1"/>

<!-- Start the Kinect (openni_camera) -->
<group if="$(arg Kinect)"> <include file="$(find openni_launch)/launch/openni.launch" arg="$camera:=openni" /> </group> </launch>  The .launch file runs correctly and openni.launch works fine, but it does not seem to be running the arg camera:=openni. I can tell because I cannot view the tf topics in Rviz from openni_tracker. I am currently using catkin in ROS Hydro with Ubuntu 12.04. I appreciate your help. Thank you. edit retag close merge delete ## Comments Can't you copy the openni launch file to your own folder and pass that argument inside it? ( 2014-12-09 05:10:41 -0600 )edit I am not quite sure what you mean by this. ( 2014-12-09 12:31:05 -0600 )edit ## 2 Answers Sort by » oldest newest most voted You are close, but what should work is the following small change to how you pass an argument tag inside of an include tag: <launch> <arg name="Kinect" value="1"/> <group if="$(arg Kinect)">
<include file="\$(find openni_launch)/launch/openni.launch">
<arg name="camera" value="openni"/>
</include>
</group>
</launch>


Also, you can use true instead of 1 in the value for your Kinect arg, and it is nice when you use default instead of value, like they did in openni.launch, since it makes it easier for launch files that include your launch file to modify the arguments.

more

You are a life saver. Thank you very much. As you can probably tell, I am very new to this.

The source for this information can be found at roslaunch given by Dornhege below.

( 2014-12-09 12:47:47 -0600 )edit

Your syntax is completely wrong. Check out the docs for correct examples:

http://wiki.ros.org/roslaunch/XML/arg

more

Thanks. Good to have the source. Had I found that page, I wouldn't have asked the question.

( 2014-12-09 12:19:28 -0600 )edit