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

Latching more than one message

asked 2019-10-28 09:07:23 -0500

knxa gravatar image

I have a latched topic that publishes a kind of log messages. When a client connect, he will get the latest log message, however this is often too limited, since the client needs to know what has happened in the past as well as what is happening right now. Ideally I would want to be able to define the number of messages to be latched.

  1. Is there any way that I can - with just one topic - provide a new client the latest N messages?

  2. Or do I have to create a dedicated service to provide the latest N messages, which the client then will have to carefully synchronize with the ongoing publishing of log messages?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2019-10-28 09:39:52 -0500

gvdhoorn gravatar image

updated 2019-10-28 09:41:28 -0500

Is there any way that I can - with just one topic - provide a new client the latest N messages?

No, this is not supported (but with a trick you may be able to get close, see below).

Latching is a very limited implementation of the "late joiner gets history" concept (essentially a history depth/length of 1). There is no way to configure the depth in ROS 1.

It is however a depth of 1 per publisher IIRC. So if creating multiple publishers would be ok, you could create a publisher per message, make them all latched and late joiners would get all of them (note: it could be that multiple publishers in the same node to the same topic share the queue, which would make this not work again). That's not very nice though.

Or do I have to create a dedicated service to provide the latest N messages, which the client then will have to carefully synchronize with the ongoing publishing of log messages?

you seem to present somewhat of a false dilemma here: it isn't either-or I'd say. It's unfortunate ROS 1's latching isn't configure (as ROS 2's is, with DDS QoS as a back-end), but there are probably various other alternative approaches that could be used. Your idea with a service being one of them.

edit flag offensive delete link more

Comments

I did hope for a trick I had not yet discovered and you provided one. However I think that using multiple publishers is too odd and not very scalable.

knxa gravatar image knxa  ( 2019-10-29 15:19:39 -0500 )edit
1

Well as I wrote: latching is really only meant for receiving the last message. It was never meant to support receiving the last-n-messages. It could be added, but considerations such as memory usage could come up (I can see people trying to use this with pointclouds).

gvdhoorn gravatar image gvdhoorn  ( 2019-10-29 22:15:23 -0500 )edit
0

answered 2019-10-28 13:25:06 -0500

duck-development gravatar image

updated 2019-10-29 02:52:16 -0500

You cloud publish a vector of you topic and implement a deque. Insert on the back, pop out on the front. And republish it

edit flag offensive delete link more

Comments

Interesting idea. But if the desired number of historic items is large then this quickly becomes a traffic heavy solution.

knxa gravatar image knxa  ( 2019-10-29 15:14:48 -0500 )edit

You right, but if you like to get something for speed, acceleration, jerk compution. Out of one message you can do it so.

duck-development gravatar image duck-development  ( 2019-10-31 02:35:58 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-10-28 09:07:23 -0500

Seen: 439 times

Last updated: Oct 29 '19