• +4917626969472
  • info@ur-techpartner.de

ROS Basics (04/17) – Latched Topic

Robot Operating System(ROS1/ROS2) ROS Programming

ROS Basics (04) – Latched Topics

In next section we will describe how to define our own message, and how to prepare CmakeList.txt and package.xml files for our defined message compilation.
However before moving further we will shortly discuss what are latched topics

Latched Topics

ROS messages are available temporarily. A message sent to a topic is not stored anywhere. If you are not already subscribed to the topic or if you subscribe later, you will miss the message that was publish on the topic before you subscribed. In this case, you will have to wait for the next message to receive. Sometimes, it is ok when messages are publishing on the topic frequently. However, it is not always feasible to publish the messages frequently. Sometime there is a long interval before sending another message or even for some cases the message is published only one time. In this case those nodes, which subscribe the topic late, will miss the message.
For example, in robot navigation, the map_server node publish a map (of type (nav_msgs/OccupancyGrid) on the “map” topic. This is the map of the world where robot navigates. Generally, this map does not change, and is published only once. Which means that in normal scenario if another node needs the map but starts after the map_server node has already published it, the subscriber node will never get the map.

In such problems, “latuched topics” provide an easy solution. If a topic is declared as latched, the subscriber nodes will automatically get the last published message when they subscribe to the topic. For this, the object of publisher node will be created as below, where argument “latched” is assigned a value “True”

pub = rospy.Publisher(‘map’, nav_msgs/OccupancyGrid, latched=True)

No comments