0
$\begingroup$

Rosanswers logo

I just completed the beginner tutorial and I do not understand the difference between the publisher-subscriber (PS) way of passing messages and the server-client (SC) way of passing messages. To me they seem like two ways of doing the same thing.

If I understand correctly, with the PS method there is a queue. P pushes messages in the queue and S listens for messages coming from the queue.

In SC, there is no queue, instead C waits for S to make some sort of action and then executes.

What is the practical difference between the two ways?

In what situation should I use one and not the other?


Originally posted by gabi on ROS Answers with karma: 76 on 2018-07-25

Post score: 1


Original comments

Comment by gvdhoorn on 2018-07-25:
Almost a duplicate: #q237672.

Comment by gabi on 2018-07-26:
ok thanks, but it doesn't answer any of my questions

Comment by gvdhoorn on 2018-07-26:
The paper that is linked in #q237672 may be a bit academic, but it actually answers all your questions.

If you're happy with the explanation you received from your friend though, we're happy.

Know that there is a bit more to pub-sub vs client-server than you write in your answer below.

Comment by gabi on 2018-07-26:
True, maybe it does and yes I did not read it. I guess I expected a tl;dr helpful answer instead of 'go read this 18 page paper'

Comment by gvdhoorn on 2018-07-26:
The answer you posted below is perfectly fine for a "tl;dr" helpful answer.

I only referred you to the paper in case you wanted more insight into the differences. I don't believe "go read this 18 page paper" was said to you anywhere.

Also: the differences are explained in sections 2 and 3, ..

Comment by gvdhoorn on 2018-07-26:
.. which are 4 pages of A4 text at most.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I ended up getting the answer to my questions by asking a friend:

Q: what is the difference?

A: Pubsub tends to be for different purposes: you subscribe to something, process it and publish it. Usually at a fairly fixed rate. You can subscribe to multiple things and publish multiple things. Multiple other nodes can subscribe to the same topic. You can even have multiple nodes publishing to the same topic.

Server client tends to be more request response. Ros can also do that, see Ros services or Ros action server. In client server a client makes an explicit request for some specific data.

Q: in which scenario would I use one over the other?

A: You can do a request like structure in pubsub, but that's not really the aim. Pubsub is super flexible in that sense. But if you need to process specific requests from clients pubsub gets tricky, because all topics are global. For example, in pubsub, if client a and b make a request and you process them and output two responses, how do they know which one was for a and which one for b? That is the benefit of server client over pubsub: server client makes explicit requests, while pubsub makes information global.


Originally posted by gabi with karma: 76 on 2018-07-26

This answer was ACCEPTED on the original site

Post score: 5


Original comments

Comment by Shivam on 2021-10-03:
What does "For example, in pubsub, if client a and b make a request and you process them and output two responses, how do they know which one was for a and which one for b?" mean?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.