ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
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 -0500

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 image gvdhoorn  ( 2018-06-22 03:05:22 -0500 )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 image hongkedavid  ( 2018-06-22 11:34:21 -0500 )edit

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

pengjiawei gravatar image pengjiawei  ( 2018-06-23 04:29:05 -0500 )edit

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

hongkedavid gravatar image hongkedavid  ( 2018-06-26 11:23:13 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

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

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 image hongkedavid  ( 2018-06-26 11:24:06 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-06-22 02:55:41 -0500

Seen: 428 times

Last updated: Jun 23 '18