ROS : Subscribe to topic in different namespace
I just started to use ROS tonight.
What I'm trying to achieve is this:
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,
Namespace shouldn't be a problem, remap should work. Can you post output of
rostopic list
andrqt_graph
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