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

How to prevent ROS namespace from overwriting topic names?

asked 2020-12-05 16:20:13 -0600

MakinoharaShouko gravatar image

updated 2020-12-05 19:30:59 -0600

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?

edit retag flag offensive close merge delete

Comments

yes, of course. But in order to tell you how we'd need to see your code and potentially launch files.

chfritz gravatar image chfritz  ( 2020-12-05 18:31:31 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-12-06 10:23:17 -0600

tryan gravatar image

Since you have the follow_name argument in the launch file already, I would just remap the topic there:

<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)" />  # Still needed?
  <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)" />

  <remap from="follow_name/pose_gt" to="/$(arg follow_name)/pose_gt" />  # Leading slash denotes global namespace.
</node>

And in your node:

rospy.Subscriber('follow_name/pose_gt', Odometry, follow_pose_callback)
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-12-05 16:20:13 -0600

Seen: 341 times

Last updated: Dec 06 '20