RobotWebTools / ros2-web-bridge

Bridging your browser to the ROS 2.0
Apache License 2.0
209 stars 68 forks source link

Topic Latching - QoS Profiles for Subscribers #134

Open mikelyndersOKCC opened 4 years ago

mikelyndersOKCC commented 4 years ago

I am trying to achieve a latching topic through the ros2-web-bridge.

In ROS1 there was a publisher option called latching:

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

This behavior would be very useful for web interfaces where topic driven data might be un-populated when the user first loads or refreshes the page, and remains un-populated until a new message is published.

In ROS2, the behavior can be achieved by using QoS profiles as described here. The trick is to have both the publisher and subscriber use the "transient local" profile. I have achieved this between two rclpy nodes and the latching behavior works. However, this behavior does not seem to work between roslibjs, ros2-web-bridge, and a "transient local" rclpy publisher. I think this is because ros2-web-bridge uses the default QoS policy where the durability is "volatile".

It seems that rclnodejs supports QoS profiles as seen here.

roslibjs does not provide a method to set the QoS policy because the rosbridge v2 protocol does not have a specification for it as someone pointed out in this issue.

I could see two ways of supporting QoS profiles other than the default in ros2-web-bridge:

minggangw commented 4 years ago

I think the first solution, adding an additional arg, is more feasible because rosbridge v2 protocol is not designed for ROS2 specifically. Of course, the ideal way is that it can be supported by the rosbridge protocol, then each connection could customize its own QoS profile.