Ask Your Question
0

About Subscriber Structure and “latch” on Publisher

asked 2014-10-20 04:23:43 -0500

pcler gravatar image

Hi everyone. Recently I met a question when I read something about "latch" in Publisher. On the Publisher wiki page, "latch" is described as:(http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers)

    "Enable 'latching' on the connection. When a connection is latched, the last message published is saved and sent to any future subscribers that connect. This is useful for slow-changing or static data like a map."

Now I am so confused that [when a node subscribes a message from a topic, will this message disappears? If not, than what is "latch" for? Anyhow the last message will NOT disappear.]

PS. I have done some experiments. When several nodes subscribe a same topic, they always get the same messages content from that topic. And this can also explain how qrt_plot works.(It always subscribe messages from some topics but it never affects other nodes working)

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2014-10-20 07:51:39 -0500

dornhege gravatar image

I don't know what you mean with "disappear". The documentation doesn't use this word and it doesn't make any sense to have messages disappear on purpose.

The feature of latching makes sure that a new subscriber always gets the last message that was published even if the message was published before the subscriber was connected. Text in bold is the difference to an unlatched connection.

edit flag offensive delete link more

Comments

Thanks!!! Your answer helps a lot! Actually, I am thinking about the data structure of "topic". At first I think it is a STACK. "Subscribe" is like POP and "publish" is like PUSH. That's why I said "disappear". But now I think it is more complicated. Would you mind telling me how "topic" works?

pcler gravatar imagepcler ( 2014-10-22 11:36:45 -0500 )edit
1

This explains the misunderstanding. Topic is not a data structure at all. A topic doesn't exist anywhere on its own. As a concept it is a common name for two nodes to connect to each other. The data is only in the nodes. Therefore if a node isn't running yet it cannot send or receive data.

dornhege gravatar imagedornhege ( 2014-10-23 05:24:13 -0500 )edit

Thanks again! It helps! Best Wishes!

pcler gravatar imagepcler ( 2014-10-26 11:31:14 -0500 )edit

so , if we set latching to particular period of time , say 10 seconds , does it mean that if a new subscriber connects to this node within 10 seconds , it receives the last message from the last connection of the publisher ?

sam26 gravatar imagesam26 ( 2017-02-08 01:13:42 -0500 )edit
1

There is no time limit.

dornhege gravatar imagedornhege ( 2017-02-15 06:11:24 -0500 )edit

I have an additional question: if you start a node and publish to a latched topic but then kill the node which did the original publishing, will the data still be available for future subscribers? Thanks!

buckley.toby gravatar imagebuckley.toby ( 2018-09-11 12:38:47 -0500 )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: 2014-10-20 04:16:23 -0500

Seen: 4,149 times

Last updated: Oct 20 '14