Access parent namespace from relative namespace
I am trying to create a layered architecture for controlling my robot and I need to subscribe to topics that are outside my relative namespace, but inside my parent namespace. I would like to avoid using the global namespace and/or passing arguments containing namespace info.
Example: I have a parent namespace "robot", in which are two further namespaces "layer_1" and "layer_2". Each layer has a set of nodes. The launch file looks like this:
<group ns="robot">
<group ns="layer_1">
<node type="node_1" pkg="node_1" name="node_1"/>
<node type="node_2" pkg="node_2" name="node_2"/>
</group>
<group ns="layer_2">
<node type="node_3" pkg="node_3" name="node_3"/>
<node type="node_4" pkg="node_4" name="node_4"/>
</group>
</group>
node_2 is publishing a topic "foo" that node_3 must subscribe to. The global topic name is therefore /robot/layer_1/foo
However, when node_3 subscribes to "foo" it ends up subscribing to /robot/layer_2/foo
I would like to use the relative name-spacing to avoid hard-coding the global topic name. A similar question was asked here, and the hacked solution was to use args to pass the global namespace around in the launch file and use <remap>
, but this adds a lot of overhead especially for large systems.
Is there a way to do this now? Ideally something like ../layer_2/foo
?
Thanks in advance