Robotics StackExchange | Archived questions

Latching doesn't work in ROS2

Simple example:

In one window: ros2 topic pub -r 0.0001 --qos-durability=transient_local /foo std_msgs/msg/String '{data: hello}'

Then in another window: ros2 topic echo --qos-durability=transient_local /foo

I get nothing in the 2nd window. What's wrong?

I tried all the examples in the similar questions and they don't work either.

Ubuntu 20.04, Galactic

Asked by dheeranet on 2021-07-15 20:44:56 UTC

Comments

I also have the same problem on ROS2 galactic using cyclonedds

Asked by canderson on 2021-07-20 21:00:05 UTC

In foxy on ubuntu 20.04, I am able to get latching working but only if the subscriber and publisher have matching settings for durability and reliability. According to the documentation, this isn't the case. For example, I should be able to have a subscriber with a best effort / volatile QoS connect to a publisher that is reliable / transient local. Unfortunately, this does not work in reality, at least with the standard rmw.

Asked by pionex on 2021-10-06 22:25:10 UTC

I have just switched to using Galactic as it offers some debug tools for QoS issues and uses a different middleware by default. I am still unable to get a besteffort / volatile subscriber to get data from a reliable / transient local publisher. ros2 doctor / rqt graph show no problems, and I have confirmed that the settings are what I think using ros2 topic info --verbose. Right now my workaround is to subscribe to the same topic with multiple QoS, and that works. It also seems like Galactic offers some new apis that allow me to query the QoS of the publisher and subscribe appropriately. That is great, but my understanding is that I should be able to create a volatile / besteffort subscriber that is compatible with any publisher QoS.

The answer below regarding publication rate when using a latched topic makes me curious. Isn't the whole point of having a transient local (latched) publisher to avoid having to manually republish the cloud?

Asked by pionex on 2021-10-07 16:20:23 UTC

Answers

Please set appropriate rate of publication. Currently it is 0.0001 which is too low. Set it to 1. It works.

ros2 topic pub -r 1 --qos-durability=transient_local /foo std_msgs/msg/String '{data: hello}'

Asked by prince on 2021-07-15 23:16:51 UTC

Comments

The word latching has a very specific meaning in ros1. Unless they changed this for ros2, then your answer misses the point.

Asked by Mike Scheutzow on 2021-07-17 07:25:31 UTC

Right, the idea is that one message should be enough, the second subscriber should see the last message it missed when it subscribes. This kind of latching mechanism is documented in ROS2 as "transient_local" QoS but it's not working as expected.

Asked by dheeranet on 2021-07-17 11:42:11 UTC