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

Run .launch file with arg from .launch file

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

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

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

Comments

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 -0500 )edit

I am not quite sure what you mean by this.

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

2 Answers

Sort by ยป oldest newest most voted
12

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

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:

<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.

edit flag offensive delete link more

Comments

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 -0500 )edit
1

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

dornhege gravatar image

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

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

edit flag offensive delete link more

Comments

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 -0500 )edit

Question Tools

2 followers

Stats

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

Seen: 8,823 times

Last updated: Dec 09 '14