Ask Your Question

Run .launch file with arg from .launch file

asked 2014-12-09 03:28:51 -0600

updated 2014-12-09 03:33:03 -0600

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:

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


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 flag offensive close merge delete


Can't you copy the openni launch file to your own folder and pass that argument inside it?

hiro64 gravatar image hiro64  ( 2014-12-09 05:10:41 -0600 )edit

I am not quite sure what you mean by this.

sealguy77 gravatar image sealguy77  ( 2014-12-09 12:31:05 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2014-12-09 06:48:25 -0600

Thomas D gravatar image

You are close, but what should work is the following small change to how you pass an argument tag inside of an include tag:

  <arg name="Kinect" value="1"/>
  <group if="$(arg Kinect)">
    <include file="$(find openni_launch)/launch/openni.launch">
      <arg name="camera" value="openni"/>

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.

edit flag offensive delete link 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.

sealguy77 gravatar image sealguy77  ( 2014-12-09 12:47:47 -0600 )edit

answered 2014-12-09 06:45:55 -0600

dornhege gravatar image

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

edit flag offensive delete link more


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

sealguy77 gravatar image sealguy77  ( 2014-12-09 12:19:28 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2014-12-09 03:28:51 -0600

Seen: 5,761 times

Last updated: Dec 09 '14