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

Revision history [back]

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.