subscribe old message

asked 2019-09-13 09:30:26 -0500

Terence gravatar image

When I created multiple nodes, and all subscribers will subscribe from one publisher which publish message frequently. I want the publisher to make sure that all the subscribers receive its message then it publishes next message, otherwise, some subscribers will miss the message been published before. thanks!

edit retag flag offensive close merge delete

Comments

There is no built in method on a topic for that level of tracking.

Maybe consider using a service instead?

I would be curious to understand why this required, if you're willing to share. Maybe we can help you in a different way if we understand the application better.

billy gravatar image billy  ( 2019-09-15 13:44:09 -0500 )edit

yep, so basically, I'm building a multi-robot system in which robots can communicate with each other, e.g. there are three robots for three tasks, robots communicate with each other to decide who go to which task. So one robots needs to receive other robots' message then it can update its local information based on some algorithm. But because of some time issues, for example, robot A subscribes robot B's message 1 and updates its local information and publishes a new message 2, but robot B hasn't subscribed robot A's message 1, which is dropped off by message 2, then the algorithm will fail. To be short, the assignment algorithm bases on synchronous communication, but real world doesn't have ideal synchronous communication.

Terence gravatar image Terence  ( 2019-09-15 18:20:06 -0500 )edit

thanks for explaining. It sounds complicated. A custom service may be better than using topics, but it could be done using topics. I can't help you much on this one.

billy gravatar image billy  ( 2019-09-16 09:59:46 -0500 )edit

Do you have to implement it like this, or can you make a separate node that determines who does what whilst monitoring all robots? If you can have a separate scheduler that just monitors the state of your robots it can send commands to the robots using something like http://wiki.ros.org/actionlib where the robots give feedback on how their task is going and will confirm when they finished something. This way you can just implement a simple state-machine that controls all robots (actionlib also allows you to interrupt or cancel tasks).

MCornelis gravatar image MCornelis  ( 2019-09-23 04:35:38 -0500 )edit

If the 3 robots together have to come to a conclusion about who does what, you could maybe have a look at ROS2 where you can use QoS settings to ensure reliable connection. Where you make sure a message that is send is actually received. The switch from ROS1 to ROS2 is not that easy though (same base concepts, but a lot of API changes).

MCornelis gravatar image MCornelis  ( 2019-09-23 04:38:42 -0500 )edit