Ask Your Question
0

ROS : Subscribe to topic in different namespace

asked 2017-09-22 02:49:45 -0500

Rorororororo gravatar image

I just started to use ROS tonight.

What I'm trying to achieve is this:

enter image description here

This is what I have already done :

  • publish and subscribe to topic_b.

  • publish to ns1/topic_a (I checked with rostopic echo /ns1/topic_a)

  • publish to ns2/topic_a (I checked with rostopic echo /ns2/topic_a)

  • subscribe to ns2/topic_a (ros::Subscriber sub = n.subscribe("topic_a", 1000, callback);)

What I don't know how to do :

  • subscribe to ns1/topic_a from node_b.

After reading the tutorial, I tried this :

1/ In node_b.cpp, I subscribed to /topic_a_temp.

2/ In the launch file, inside the node_b tags, I added <remap from="topic_a_temp" to="ns1/topic_a">

But it doesn't work.

It may be very basic since I'm a beginner but I don't know how to read the ns1 topic from the ns2 node.

Thank you for your help,

edit retag flag offensive close merge delete

Comments

Namespace shouldn't be a problem, remap should work. Can you post output of rostopic list and rqt_graph

bvbdort gravatar image bvbdort  ( 2017-09-22 05:16:16 -0500 )edit

The rqt_graph looks like this : https://i.imgur.com/MC3GzwD.jpg My remap looks litke this : https://i.imgur.com/TOWCf8i.png rostopic list shows ns1/topic_a and ns2/topic_a (which are correctly filled when I echo). ns2/topic_a_temp is also shown but echo says, it says topic does not appear to be publ

Rorororororo gravatar image Rorororororo  ( 2017-09-22 12:49:32 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-09-22 19:27:25 -0500

Rorororororo gravatar image

Ok. I resolved my issue. I missed a '/' at the beginning of the name in the remap. I should have written : to="/ns1/topic_a". Thanks !

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-09-22 02:49:45 -0500

Seen: 963 times

Last updated: Sep 22 '17