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

How to remap topic's name?

asked 2019-09-23 07:41:21 -0600

kane_choigo gravatar image

updated 2019-09-23 07:43:17 -0600

Hi! I'm using ROS kinetic on Ubuntu 16.04.

My 2D Lidar sensor Hokuyo requires urg_node to publish laser-scanned topic (its name is "/scan")

And I want to remap the name of this topic from "/scan" to "laser".

In detail, what I want to get is sensor_msgs/LaserSacn topic, whose name is "laser", and I also wish this laser topic should be in namespace of "/spencer/perception_internal/people_detection/laser_front" .

I heard that <remap> command should change it. But unfortunately, I run urg_node by rosrun, not roslaunch which means I can't modify it in launch file.

In this case, should I modify it in source node file(urg_node.cpp)?

And, once I change the topic's name to "/spencer/perception_internal/people_detection/laser_front/laser ", it this laser-scanned topic could be in namespace of "/spencer/perception_internal/people_detection/ laser_front" ? (The namespace "/spencer/perception_internal/people_detection/laser_front" comes from other package.)

edit retag flag offensive close merge delete

Comments

why not create a launch file for the node? Its only few lines and makes remapping and passing parameters way easier and cleaner.

pavel92 gravatar image pavel92  ( 2019-09-23 07:51:36 -0600 )edit

Here is an example of a launch file for the urg_node that you can use. Then all you need is to add the remap:

<remap from="scan" to="/spencer/perception_internal/people_detection/laser_front/laser"/>

Of course you can make this way cleaner by using an arguments and launch the node within a namespace

pavel92 gravatar image pavel92  ( 2019-09-23 07:54:59 -0600 )edit

Thank you for your quick answer. Then, by doing according to your advice, would the laser-scanned topic from urg_node be in namespace of /spencer/perception_internal/people_detection/laser_front? Anyway, thanks for your really really quick feedback. :)

kane_choigo gravatar image kane_choigo  ( 2019-09-23 08:24:50 -0600 )edit

You can check the answer bellow, it contains an example launch file

pavel92 gravatar image pavel92  ( 2019-09-23 09:23:29 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2019-09-23 09:23:05 -0600

pavel92 gravatar image

Here is an example launch file that you can use:

<launch>
  <arg name="my_namespace"           default="spencer/perception_internal/people_detection/laser_front" />
  <node ns="$(arg my_namespace)" name="urg_node" pkg="urg_node" type="urg_node" output="screen">
    <remap from="scan" to="laser"/>
  </node>
</launch>

The output (remapped) topic should have the namespace appended like this:

/spencer/perception_internal/people_detection/laser_front/laser
edit flag offensive delete link more

Comments

Note that this will remap the scan to namespace/laser topic which means the scan topic will not exist any more under that name. In case you need to have both topics up and running check the relay node.

Also all other topics/parameters from urd_node will be now under the new namespace

pavel92 gravatar image pavel92  ( 2019-09-23 09:26:57 -0600 )edit

Thank you so much and really sorry for my late check. Though I didn't follow as it was, your advice was very helpful to me and I got the form of topics I want. I'll write about how I did below. Anyway, I really really appreciate you.

kane_choigo gravatar image kane_choigo  ( 2019-10-01 05:11:47 -0600 )edit
0

answered 2019-10-01 05:18:10 -0600

kane_choigo gravatar image

updated 2019-10-01 05:45:41 -0600

pavel92 gravatar image

Below is what I did.

To be honest, I'm using Hokuyo sensor so I added following line in [urg_lidar.launch] ,

<remap from="scan" to="/spencer/sensors/laser_front/echo0"/>

And I also changed like,

<launch>

  <arg name="my_namespace"           default="spencer/perception_internal/people_detection/laser_front" />
  <node ns="$(arg my_namespace)" name="urg_node" pkg="urg_node" type="urg_node" output="screen">
    <param name="ip_address" value=""/>
    <param name="serial_port" value="/dev/ttyACM0"/>
    <param name="serial_baud" value="115200"/>
    <param name="frame_id" value="laser"/>
    <param name="calibrate_time" value="true"/>
    <param name="publish_intensity" value="false"/>
    <param name="publish_multiecho" value="false"/>
    <param name="angle_min" value="-1.5707963"/>
    <param name="angle_max" value="1.5707963"/>
    <remap from="scan" to="/spencer/sensors/laser_front/echo0"/>
  </node>

</launch>

Just so you know, I've NEVER modified any spencer files, and it works.

I'd like to say thanks to pavel92 for his really really helpful advice :)

(I'm not familliar with ROS wiki AnS page sorry for my poor writting style, but I didn't mean it)

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-09-23 07:41:21 -0600

Seen: 1,603 times

Last updated: Oct 01 '19