How to prevent ROS namespace from overwriting topic names?
I am now working on the simulation with multiple robots and I want to use namespaces to organize the nodes better. However, I am also trying some information exchange among robots so they are also subscribing to topics from others' namespaces.
Here is the part in my launch file I start the node send_follow_waypoints
<node pkg="uuv_control_utils" type="send_follow_waypoints.py" name="$(anon name)">
<param name="uuv_name" value="$(arg uuv_name)" />
<param name="follow_name" value="$(arg follow_name)" />
<param name="max_forward_speed" value="$(arg max_forward_speed)" />
<param name="heading_offset" value="$(arg heading_offset)" />
<param name="use_fixed_heading" value="$(arg use_fixed_heading)" />
<param name="radius_of_acceptance" value="$(arg radius_of_acceptance)" />
<param name="start_time" value="$(arg start_time)" />
<param name="x_shift" value="$(arg x_shift)" />
<param name="y_shift" value="$(arg y_shift)" />
<param name="z_shift" value="$(arg z_shift)" />
<param name="success_rate" value="$(arg success_rate)" />
</node>
And here is my subscriber inside send_follow_waypoints.py
:
rospy.Subscriber('/%s/pose_gt' % follow_name,
Odometry,
follow_pose_callback)
I want the robot with uuv_name
to subscribe to the topic /follow_name/pose_gt
, but if I add an ns="$(arg uuv_name)"
tag to the node, it would try to subscribe to /uuv_name/follow_name/pose_gt
. Is there some way to stop the namespaces from changing the topic names?
yes, of course. But in order to tell you how we'd need to see your code and potentially launch files.