Ask Your Question
0

Can we ensure subscribing order same as publishing order in ROS given multiple publishers on a same topic?

asked 2018-06-22 02:55:41 -0600

hongkedavid gravatar image

Suppose I have two publishers P1 and P2 that publish a same topic M, which is received by two other subscribers S1 and S2, is there a way to ensure that both subscribers will receive M messages in a same order as published from P1 and P2? For example, if P1 publishes a M message and after some time P2 publishes another M message, is it possible to guarantee that both S1 and S2 will receive the M message from P1 and then the one from P2? My understanding is that this can be generally hard to ensure in a message-passing based distributed system. Thanks for any answering or clarification!

edit retag flag offensive close merge delete

Comments

This reads a little like a homework question.

Can you give a little more context and clarify why you are asking this?

gvdhoorn gravatar imagegvdhoorn ( 2018-06-22 03:05:22 -0600 )edit

I am a PhD student working on autonomous vehicle (AV) security. I used this example to simplify my question for ease of understanding. I am working on a ROS-based autonomous vehicle system that relies on ROS pub-sub messaging model to interact between self-driving modules, including P1, P2, S1, S2

hongkedavid gravatar imagehongkedavid ( 2018-06-22 11:34:21 -0600 )edit

does "a same topic M" means that the name and type of topic is same?

pengjiawei gravatar imagepengjiawei ( 2018-06-23 04:29:05 -0600 )edit

Yes, "a same topic M" means that the name and type of topic are same.

hongkedavid gravatar imagehongkedavid ( 2018-06-26 11:23:13 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-06-23 11:23:29 -0600

tfoote gravatar image

There is no guarantee for inorder delivery from multiple publishers to one or more subscribers. Nor is the order guaranteed to be the same for the two subscribers. Each publisher and subscriber pair has a separate communication channel open.

You're right that in a distributed system this is generally hard. Knowing the order of who published first is no really even known. Generally I'd recommend making sure that you put timestamps in your messages and make your algorithm robust to out of order delivery. As well as making sure that your system clocks are well synchronized.

If you want guaranteed ordering and confirmed delivery I'd recommend using services which provide confirmation of delivery. There's more overhead and they block, but that's the trade-off for the guarantees.

edit flag offensive delete link more

Comments

Got it. Thanks very much for your detailed explanation!

hongkedavid gravatar imagehongkedavid ( 2018-06-26 11:24:06 -0600 )edit

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: 2018-06-22 02:55:41 -0600

Seen: 110 times

Last updated: Jun 23 '18