Nodelet topic remapping not working inside namespace
I have a launch script that launches multiple instances of the same nodelet, which share the same nodelet manager (to allow zero-copy messaging). When I run launch file I get the following error, presumably as a consequence of each nodelet using the same parameter names in the same namespace:
Tried to advertise a service that is already advertised in this node
I think the solution to this is to place the nodelets in different namespaces, however I am struggling to get it to work. Hopefully the following toy example - using point_cloud_xyz for simplicity (I'm using a custom nodelet in my actual launch file) - outlines the problem I'm facing.
This code runs fine:
<launch>
<arg name="nodelet_manager_name" default="camera_nodelet_manager" />
<node pkg="nodelet" type="nodelet" name="$(arg nodelet_manager_name)" args="manager"/>
<node pkg="nodelet" type="nodelet" name="point_cloud_xyz"
args="load depth_image_proc/point_cloud_xyz $(arg nodelet_manager_name) --no-bond"
respawn="true>
<remap from="camera_info" to="/depth/camera_info" />
<remap from="image_rect" to="/depth/image_rect" />
<remap from="points" to="/depth/points" />
</node>
</launch>
And if I run it with the "--screen" flag I see that the topics are remapped as expected:
[ INFO] [1592917605.947825944]: Loading nodelet /point_cloud_xyz of type depth_image_proc/point_cloud_xyz to manager camera_nodelet_manager with the following remappings:
[ INFO] [1592917605.948422793]: /camera_info -> /depth/camera_info
[ INFO] [1592917605.948437110]: /image_rect -> /depth/image_rect
[ INFO] [1592917605.948446947]: /points -> /depth/points
And the nodelet successfully runs and publishes points to the topic.
However if I try to put the nodelet into a namespace (called "camera"):
<launch>
<arg name="nodelet_manager_name" default="camera_nodelet_manager" />
<node pkg="nodelet" type="nodelet" name="$(arg nodelet_manager_name)" args="manager"/>
<group ns="camera">
<node pkg="nodelet" type="nodelet" name="point_cloud_xyz"
args="load depth_image_proc/point_cloud_xyz $(arg nodelet_manager_name) --no-bond"
respawn="true">
<remap from="camera_info" to="/depth/camera_info" />
<remap from="image_rect" to="/depth/image_rect" />
<remap from="points" to="/depth/points" />
</node>
</group>
</launch>
The remapping looks like I would expect, with the topics for the nodelet now within the "camera" namespace, but the target remappings remaining the same (since I have defined them as global with the preceeding "/"):
[ INFO] [1592917948.909617098]: Loading nodelet /camera/point_cloud_xyz of type depth_image_proc/point_cloud_xyz to manager camera_nodelet_manager with the following remappings:
[ INFO] [1592917948.910396273]: /camera/camera_info -> /depth/camera_info
[ INFO] [1592917948.910409509]: /camera/image_rect -> /depth/image_rect
[ INFO] [1592917948.910415959]: /camera/points -> /depth/points
But this doesn't work because now there are no points published to any topic.
Of course, it will work if I move the nodelet manager into the "camera" namespace too, but as I note at the start, I need to run multiple instances of the same nodelet under a single nodelet manager without the parameters colliding with each other.
I have been through a multitude of other answers on here, and feel like I've tried all manner of alternatives, all with no success. So I can only assume I am fundamentally misunderstanding something. Any help would be gratefully received!
Any update?
Following this answer try replacing
args="manager"
byargs="/manager"
When using nodelets to connect to a manager outside of the nodelet namespace it seems that it is necessary to provide global path to thee manager using "/" character.
I had the same problem this afternoon and your question was the first i found so I'm answering here