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

nodes and topics -like i'm 5

asked 2017-08-23 17:50:47 -0500

I am doing the ROS beginner tutorials and am on the 'understanding nodes' one. What actually is a topic? I see that a node is essentially an executable file and they communicate w eachother using topics but what is a topic?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-08-23 22:31:58 -0500

Ed Venator gravatar image

A topic is the way nodes communicate with each other. Think of it like a newsletter--the terminology for topics is exactly the same.

Say you have a node that generates images, and it wants to send them to other nodes. The node advertises that it is going to publish sensor_msgs/Image messages on a topic. The topic has a URI, which is a path like /image or /vision/image (it can be whatever you want it to be). The ROS master keeps track of what nodes have advertised what topics.

Now say you have another node that processes images, and it wants to get them from the other node. This node subscribes to sensor_msgs/Image messages on the same topic.

The ROS master sees the publisher and the subscriber, and it tells the nodes how to connect directly. Now, whenever the first node publishes an image, it gets sent (over a TCP socket) to the subscribing node. A topic can have any number of publishers and any number of subscribers; every subscriber gets every message from every publisher.

Any questions?

edit flag offensive delete link more

Comments

1

Perhaps to make it more explicit: a topic is essentially nothing more than a name (or an address). It is not a magic entity that is actually, concretely involved in the exchange of msgs, but is only used to bring producer and consumer together.

After that they will exchange information directly, ..

gvdhoorn gravatar image gvdhoorn  ( 2017-08-24 02:25:01 -0500 )edit

.. without caring about the topic or the master.

And also note that using topics (alone) is just one such way to implement a communication system such as ROS. There are also type based systems (where you get all msgs of a certain type (say the sensor_msgs/Image that @Ed Venator mentions)) ..

gvdhoorn gravatar image gvdhoorn  ( 2017-08-24 02:27:02 -0500 )edit

.. and content based systems (in which you express interest in msgs that have a certain contents, with a filter expression fi (ie: I want all msgs that have a field called field0 with a value 464)).

gvdhoorn gravatar image gvdhoorn  ( 2017-08-24 02:28:00 -0500 )edit

thank you, helpfull

moonspacedancer gravatar image moonspacedancer  ( 2017-08-24 17:07:10 -0500 )edit

If this answered your question, then you should mark it as correct.

jayess gravatar image jayess  ( 2017-08-25 14:08:43 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-08-23 17:50:18 -0500

Seen: 149 times

Last updated: Aug 23 '17