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

Revision history [back]

click to hide/show revision 1
initial version

A current hacked solution we came up with: Keep "track" of the global namespace by always passing down an <arg name="ns" ...&gt;="" to="" every="" included="" launch="" file,="" and="" include="" a="" "<arg="" name="ns" default=""/>. For example, with a simple two-subnode case, being called from an upper launch file.

The upper level launch:

<launch>
  <arg name="ns" default=""/>
  <remap from="$(arg ns)/node1/chatter" to="$(arg ns)/node2/chatter"/>
  <include file="talk_sub.launch" ns="node1">
    <arg name="ns" value="$(arg ns)/node1"/>
  </include>
  <include file="listen_sub.launch" ns="node2">
    <arg name="ns" value="$(arg ns)/node2"/>
  </include>
</launch>

And then in a lower level launch:

<launch>
  <arg name="ns" default=""/>
  <node name="talker" pkg="play" type="talker.py"/>
</launch>

In this way, you are always using the global-remap method, which always works, and you can reference the global namespace without actually knowing it a priori. This allows you to build up launch files with multi-level includes, and "cleanly" remap at the appropriate points. The best place to remap then is always at the lowest namespace where two topics are common, and no higher.

A current hacked solution we came up with: Keep "track" track of the global namespace by always passing down an <arg name="ns" ...&gt;="" to="" every="" included="" launch="" file,="" and="" include="" a="" "<arg="" name="ns" default=""/>. a <arg name="ns" ...> to every included launch file, and include a <arg name="ns" default=""/>. For example, with a simple two-subnode case, being called from an upper launch file.

The upper level launch:

<launch>
  <arg name="ns" default=""/>
  <remap from="$(arg ns)/node1/chatter" to="$(arg ns)/node2/chatter"/>
  <include file="talk_sub.launch" ns="node1">
    <arg name="ns" value="$(arg ns)/node1"/>
  </include>
  <include file="listen_sub.launch" ns="node2">
    <arg name="ns" value="$(arg ns)/node2"/>
  </include>
</launch>

And then in a lower level launch:

<launch>
  <arg name="ns" default=""/>
  <node name="talker" pkg="play" type="talker.py"/>
</launch>

In this way, you are always using the global-remap method, which always works, and you can reference the global namespace without actually knowing it a priori. This allows you to build up launch files with multi-level includes, and "cleanly" remap at the appropriate points. The best place to remap then is always at the lowest namespace where two topics are common, and no higher.