ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Publish/Get last message when a new subscriber subscribes to a topic

asked 2021-06-09 08:34:52 -0600

BhanuKiran.Chaluvadi gravatar image

updated 2021-06-09 08:42:30 -0600

Hi,

I have few publishers in my system, some of them publish at a pre-defined rate and other publish only when there is a change in their variable value. I was wondering if there is a way, when a new subscriber subscribes after the node has started and the subscriber should receive the last published message.

It's not related to loos of packet. It's just that the subscriber doesn't exists when the publisher published previous message.

Thank you

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-06-09 10:35:20 -0600

shonigmann gravatar image

(With the preface that I haven't actually implemented this myself yet, so I can't guarantee that it works) it seems like setting the DDS Quality of Service setting of your publisher to transient local might do the trick. More on QoS options here

This tutorial may help with modifying the default QoS for a publisher.

edit flag offensive delete link more

Comments

1

Thanks @shonigmann . I made a quick test and it is working.. But for the benefit of other people landing here: latch is the key word, Here is an example from other ros-answer

BhanuKiran.Chaluvadi gravatar image BhanuKiran.Chaluvadi  ( 2021-06-10 02:41:25 -0600 )edit

Great to hear it worked out, thanks for the update

shonigmann gravatar image shonigmann  ( 2021-06-10 11:15:11 -0600 )edit

This will also only work correctly if a reliable reliability is selected.

hacker1024 gravatar image hacker1024  ( 2023-02-26 06:38:11 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2021-06-09 08:34:52 -0600

Seen: 1,162 times

Last updated: Jun 09 '21