Clarifications on ROS Messages, Topics (Publishers & Subscribers), Services & Actions

I am also a bit confused regarding the 3 types of communication:
1 - Topics - Publisher/Subscriber
2 - Services- Server / Client
3 - Action - Server / Client

I do not understand why the course ROS in “5” days divides in this way. Because If I am not wrong (Correct me please if I be), the Topics are and can be used inside a ROS service or ROS action script.
So I cannot assume a topic such as a different kind of communication, but I should assume that the topic is a structure contained inside a ROS service or ROS action communication?

I mean to say, the topic is like the “air”, is the place which the communication in ROS take place, and I can communicate with other person in different ways, such as talking (=service communication for example) or by hand gestures (=action communication for example). But the “environment”, the pipeline, the link of how this communication takes place is always the same (through publisher/subscriber in ROS topics).

Please could you clarify this for me, because I am confused about these concepts:
I also have read some analogies with UDP and TCP connection here… And I understood what they meaning to say UDP= Topics = Continuous and TCP = Service or Action = Synchronous…but
I am really confused in how to make the distinction of Topic-Service-Action. Because in my point of view the Topics are in same way inside the Service or Action, while the inverse (Action or service inside a Topic) can not happen. So this is my provisory conclusion, the topics communication can be used inside a service or action communication to read a sensor data for example ( can be a subpiece of a piece communication system) BUT the service and action cannot be used inside a topic communication…Should I take this conclusion?

1 Like

@bayodesegun could you please send me on rqt_graph such as this one provided by this video explanation.
But instead of rqt_graph of just topics concept, one graphic displaying when a service and when an action is running in ROS. I think in this visual way, I could better comprehend the differences.

Let me try to summarize:

  • Messages are the life-blood of ROS. It’s the “speech” of communications.
  • Topics are the channels on which messages are sent or received.
  • Publishers send messages, Subscribers receive messages. A topic is involved in both cases.
  • Services and Actions show the client/server approach to writing ROS code. They may use Topics (via a publisher or a subscriber).

Publishers & Subscribers are treated directly under topics because those are the primary ways to work with topics. Services & Actions can make use of publishers and/or subscribers.

Therefore, you need to know about topics, publishers and subscribers before you can use services and actions effectively. Calculus is an advanced maths concept, but it’s based on simple concepts of add, subtract, multiply and divide.

I hope this clarifies now.


Thanks Mr. @bayodesegun so let me see if I got the idea. I could compare that I have a problem to calculate the area of a regular square. So the simple multiplication operation L*L returns me this area. This simple operation could be compared in analogy to the topics function (limited to calculate regular geometry areas).
But when I need to calculate the area of a nonuniform area (spatial shape 3D geometry), such a rectangle cut and fulfilled with a spline, so I should use the Integral framework to calculate it accurately, and inside the Integral I could use a multiplication or/and addition operation.
So in summarize the “Integral” more sophisticated operation would work as (service or action) and the “Multiplication” would work as the topic inside the “Integral” (service) operation. The publisher/subscriber could be the way I put or extract the numbers inside this Multiplication operation (which is inside the Integral Operation)
Could I face like that?

Hi @marcusvini178,

More or less. But let me clarify further:

  • You can hardly do anything meaningful in ROS without using topics (via publishers or subscribers) in some way. If you have to communicate with the robot, it’s a must. So it’s so basic.
  • For this reason, your service or action will most likely use topics, but they don’t have to. You might create a service or action that will just process an image for example. A service or action is just like a reusable function, using the client/server approach, not an advanced concept of working with topics per se.
  • Services and actions are just to make working with ROS less pain, the way classes and functions make life easier in programming. You may choose not to use them, but you can imagine what life would be then…
1 Like

Hi again mr @bayodesegun.
I was getting dep in comprehend ROS Action concept, and reading this

Well regarding this material I would like to better understand some things:

1- When I have an Action server, this action server can be requested simultaneously by different action clients? And execute them separately, without crash? I did not understand if one client overwrites the previous client goal…(it seems that is this what happens, is it?)

2 - If the same Action client send a new goal to the Action server, what happens? The previous goal is preempted and the new one goal is sent to pending-current goal queue, or the Action server finishes to execute the first goal and later start the second one (Which was sent during the first goal operation)?

3- In Client-Server Services does this happen too? I mean the server stops to work on a node1 request if the node2 or/and node3 sent a new request to it simultaneously (During the node 1 request execution) or the it executes the requests separately simultaneously?

And for last but not less important

4 - I understand that in a topic, a publisher send a message type through it (topic).
But in a service connection, the request message type (int, double or whatever type) and the response type (boolean for example) are sent in a different type of connection framework (wifi for example) or also through the Topic frameworks (pipeline for example)
I am in doubt of this because the Action server and Action client use the Topic frameworks to send message Types: Feedback, status, Result, Goal, Cancel - All the messages types defined in these features are sent through Topics, isn’t it? Ant the Service server-Client also use topic to send their messages types or not?

5- The connection between a Publisher/Subscriber is through a pipeline (Topic). But the connection between an Server of an Action/Service node and the client of an Aciont/Service node is done through what framwork (TCP/IP or UDP - Proxy…?or through their messages types objects which are written and defined in .srv and .msg files in CmakeLists/Package XML? )

Thanks in advance

1 Like