# roslaunch - namespace substitution within group tags

I'm working on a multiple robot application and am trying to develop a clean launch file. I have multiple blocks of XML in my launch file that look like...

<group ns="r1">
<include file="$(find mypack)/launch/robot.launch"> <arg name="namespace" value="r1" /> </include> </group>  I need to pass the namespace to the robot.launch file explicitly (long story). I don't like it that I have to input the "r1" value twice. It would be more pleasing if I could use substitution to assign a value to the namespace argument so that I only had to define the "r1" value once. Something like... <group ns="r1"> <include file="$(find mypack)/launch/robot.launch">
<arg name="namespace" value="$(arg ns)" /> </include> </group>  I tried to have an argument before the group tag that I reassigned each time, but that caused errors. Evidently I can't reassign arguments. Any creative thoughts much appreciated. edit retag close merge delete ## 1 Answer Sort by » oldest newest most voted Well, what should work is the following: • have your robot.launch as it is • a robot_ns.launch with the following in it: <arg name="my_ns"/> <group ns="$(arg my_ns)">
<include file="$(find mypack)/launch/robot.launch"> <arg name="namespace" value="$(arg my_ns)" />
</include>
</group>

• and then, in the top-level launch file, do the following:

<include file="$(find mypack)/launch/robot_ns.launch"> <arg name="my_ns" value="r1" /> </include> <include file="$(find mypack)/launch/robot_ns.launch">
<arg name="my_ns" value="r2" />
</include>


You then don't reassign arguments (which you actually cannot) and you only have to write the namespaces out once.

I guess you could also have this in just one launch file, if your robot.launch could handle an empty namespace argument with the group tags correctly.

more