NEWAI chat: ask your fleet anything, in plain language. Chat with your fleet Read more →

How to monitor ROS 2 topic frequency and dropped messages

Measure ROS 2 topic rates where they matter, find where messages get dropped (network, queues, QoS), count the losses and alert against each robot's normal.

Illustration for "Topic rates and lost messages": a mobile robot, a camera, with the label "/scan 10 Hz → 7.4 Hz · 26% lost"

A mobile robot in a warehouse starts brushing shelf corners. Not every run, maybe twice a shift. The lidar driver is up, /scan is publishing, and when someone SSHs in and runs ros2 topic hz /scan on the robot, it shows a clean 10 Hz. Inside the local planner, though, about one scan in four never reaches the callback. Sometimes the planner goes 300 ms between scans while the robot keeps moving.

Nothing logged an error. A dropped message in ROS 2 is usually not an event. It's just a message that isn't there.

This hurts more on a robot that runs a learned policy. A policy is a living mind: it turns whatever the sensors last said into the next action, many times a second, and it has no idea how old or how thin that input was. Give it 7 scans a second instead of 10 and it doesn't fail. It decides from less, with the same confidence. Then a new model version ships, inference gets a bit slower, and the drops get worse on half the fleet without anyone touching the drivers.

We wrote about the topic that goes completely silent in an earlier post. This one is about the topic that still flows, just slower, or with holes in it.

The short answer: Run ros2 topic hz <topic> on the robot itself and read the max gap between messages, not only the average rate; then compare each topic with its own normal on that robot. To count drops, register a message-lost event callback, add a counter to messages you own, or compare the publisher's rate with how often your callback runs. Most ROS 2 drops come from the network under best-effort QoS, a subscriber queue that overflows because the callback is slow, or endpoints whose QoS never matched.

Rate depends on where you measure it

A ROS 2 topic doesn't have one rate. It has a publish rate, and then a receive rate for every subscriber, and they can all differ.

The ros2topic source says it directly: the rate ros2 topic hz prints "reflects the receiving rate on subscription, which might be affected by platform resources and QoS configuration, and may not exactly match the publisher's rate." So:

  • Run it on the robot, not on your laptop. Over Wi-Fi, ros2 topic hz /camera/image_raw from your desk measures the Wi-Fi. Useful if Wi-Fi is the question, misleading if it isn't.
  • Remember it's a different subscriber than yours. The CLI does almost nothing per message, so its queue rarely overflows. Your node's callback may run inference for 80 ms. The CLI can show a perfect 10 Hz while your callback misses a quarter of the messages. On Jazzy it always subscribes with the best-effort sensor data profile; on Kilted and Lyrical it adapts to the publishers, takes several topics at once, and has --qos-* options to match your real subscriber.
  • Read the whole line. The output is average rate, then min, max and std dev of the time between messages over the window you set with -w. A topic averaging 10 Hz with a max gap of 0.9 s has a problem the average hides.

ros2 topic hz /scan -w 200 # on the robot: rate, min/max gap, std dev

ros2 topic info -v /scan # every publisher and subscriber, with its QoS

ros2 topic bw /scan # bandwidth, before you blame the network

ros2 topic delay /scan # message age from header.stamp

As of December 2026, per the ROS 2 releases page, the supported LTS releases are Humble (to May 2027), Jazzy (to May 2029) and Lyrical Luth (to May 2031), and Kilted Kaiju has reached end of life. The CLI differs between them, so check which one you're on before trusting its defaults.

Average rate is the wrong alarm

A 30 Hz camera that sends 29 frames on time and then stalls for a second still averages close to 30 over a long window. A controller that needs a fresh frame every 33 ms just had a one-second blackout. Planners and policies feel the worst gap, not the mean.

Track three numbers per topic: the rate over a short window, the max gap in that window, and, when messages carry a header stamp, their age (receive time minus header.stamp, measured on the machine that stamped them or with synced clocks). Drops show up as a lower rate and a larger max gap. A backlog shows up as growing age.

Where ROS 2 drops messages

When a subscriber sees fewer messages than the publisher sent, it's almost always one of these. They have different fixes, so name the one you have before changing QoS settings at random. Start with ros2 topic info -v on the topic: it shows the QoS each side actually uses.

On the network, under best effort

Many sensor drivers publish with the sensor data profile. In the rmw source that profile is keep last, depth 5, best effort, volatile. Best effort means no retransmission. Whatever the network loses is gone.

On wires inside one robot this rarely matters. It matters a lot when the subscriber sits on another machine over Wi-Fi or cellular, and it hits big messages hardest. A raw image or point cloud is split into many fragments, and under best effort one lost fragment drops the whole message. Small topics look fine while the camera loses frames.

Fix: keep heavy data on the machine that produces it, send compressed images across links you don't control, and compare ros2 topic bw with what the link really carries.

In the subscriber's queue

This is the most common cause I see, and the least visible. A subscription with keep last and depth N holds at most N messages waiting for your callback. The Fast DDS documentation describes keep last as keeping "the most recent values" and discarding "the older ones". If your callback is slower than the publisher, the queue fills and the oldest messages are thrown away. No error, nothing at the default log level.

Why the callback falls behind:

  • It does real work: inference, a point cloud filter, a synchronous service call.
  • A heavy callback and a fast one share a mutually exclusive callback group (the default), so the fast one waits.
  • CPU or GPU contention from something else on the robot, often only at certain hours.
  • A model update made inference 40% slower, and now the camera callback takes longer than the frame interval.

That last one is why rates belong in your release checks, not only on dashboards. A new model can be more accurate and still make the robot see less.

Fix: keep callbacks short and hand heavy work to another thread, or put the heavy callback in its own callback group and run a multi-threaded executor. Raise depth only when you need every message and can keep up on average. For a controller that only cares about the newest value, depth 1 is the right choice: you accept drops and always act on the latest.

Reliable doesn't mean every message

A common belief is "use reliable and nothing gets lost". Reliable means the publisher retransmits samples it still holds. With keep last it only holds the last N, so a subscriber that falls far enough behind needs samples that were already overwritten. Fast DDS counts such a sample as lost when the writer reports it's no longer available.

Reliable also costs something: retransmissions on a lossy link add delay, and a slow reader can back up the publisher. For high-rate sensor data, best effort with a small depth is usually right. Use reliable for commands, goals and state you can't miss, and size the history for it.

Never connected at all

If the QoS of a publisher and a subscriber are incompatible (reliability, durability, deadline or liveliness), the QoS documentation is clear that no messages pass between them. rclcpp and rclpy do log a warning by default ("offering incompatible QoS. No messages will be sent to it"), but it lands in a node log nobody reads on a robot in the field. More on that case in how to detect a ROS 2 node that silently stopped publishing. For counting, the point is simple: a subscriber that receives zero might not be losing anything. It might not be connected.

How to count dropped messages

ros2 topic hz tells you what arrived. To know what was dropped, you need to know what was sent. Three ways, from cheapest to most exact.

1. The message-lost event. A subscription can register a callback for lost messages; it reports total_count and total_count_change since the last call. In the Rolling sources, Cyclone DDS, Fast DDS and Zenoh all implement it, each its own way (Fast DDS, for example, counts a best-effort sample as lost when a later sequence number arrives); check your distro's RMW. There's no default handler, so nothing happens unless you register one. The quality_of_service_demo package has a talker and listener that show it. In Python (Jazzy and later):

from rclpy.event_handler import SubscriptionEventCallbacks

from rclpy.qos import qos_profile_sensor_data

from sensor_msgs.msg import LaserScan

def on_lost(info):

node.get_logger().warn(f"/scan lost {info.total_count_change} (total {info.total_count})")

cbs = SubscriptionEventCallbacks(message_lost=on_lost)

node.create_subscription(LaserScan, "/scan", on_scan, qos_profile_sensor_data, event_callbacks=cbs)

On Humble, the same class is imported from rclpy.qos_event. Don't read it as a complete count: it reports what the middleware considers lost, and I wouldn't assume it includes messages your own queue discarded because your callback was slow.

2. A counter in the message. The ROS 2 std_msgs/Header has only stamp and frame_id; the ROS 1 sequence number is gone. For topics you own, add an increasing counter. On the receiving side, every jump bigger than one is a measured loss, wherever it happened, queue included. One integer per message buys the most trustworthy number you'll get.

3. Publisher rate vs callback rate. For topics you don't own, measure the rate on the publisher's machine and count how often your callback actually runs. The difference is your loss. Count inside the callback, not with a separate subscriber, which has its own queue and won't see your drops.

Two more sources. In Jazzy and Lyrical, rclcpp can publish topic statistics per subscription (message age and period, to /statistics, once a second; off by default, C++ only), but the /statistics publisher was removed from rclcpp in Rolling, so don't build long-term monitoring on it. And since Lyrical, rosbag2 publishes /events/rosbag2_messages_lost when the recorder can't keep up, which tells you the recording you plan to debug from has holes.

What to put in place on a fleet

The watcher, per-robot baselines and peer comparison are covered in how to monitor ROS 2 across a fleet of robots. For rates and drops specifically, add these:

  • Alert on drops against each robot's own normal, sustained. "Rate under 75% of this robot's normal for 2 minutes" catches real problems. "Rate under 10 Hz" fires on every robot with a different sensor and teaches people to mute it.
  • Count lost messages on the topics your planner and policy depend on. Not every topic. The handful where a missing message changes what the robot does.
  • Compare rates before and after every release. A new model or driver that lowers a camera's callback rate is a regression, even if accuracy went up.
  • Keep both sides' QoS visible. When a rate drops to zero right after an update, the first question is whether someone changed a QoS setting.

If one robot's rates are always the odd ones out, finding the robot that's different is the method.

How we do it at PhysicalFleet

The PhysicalFleet agent measures the rate and bandwidth of every ROS topic published on a robot, without joining your graph as a publisher and with nothing added to your code; heavy image and point-cloud topics are sampled for a few seconds each minute to keep it cheap. It learns each robot's normal range per hour of the day and flags a topic that runs far from the same topic on robots running the same thing. Alert suggestions for a ROS topic whose rate dropped or that stopped are ready to turn on, and the change timeline shows what changed before a rate fell. More on the observability page.

Where did your robot's missing messages turn out to go? Tell me, I collect these.

Common questions

Why does ros2 topic hz show a different rate than my node receives?

Because it measures what arrives at its own subscription. Run from another machine, it includes network loss; run on the robot, its light callback keeps up even when your node's slower callback lets its queue overflow. Count inside your own callback to know what your node really gets.

How do I know if my ROS 2 subscriber is dropping messages?

Compare what arrives in your callback with what was sent. A counter field in messages you own is the most exact way, since the ROS 2 header has no sequence number. Register a message-lost event callback for losses the middleware detects, and if your callback takes longer than the gap between messages, assume the keep-last queue is discarding the oldest ones.

Does reliable QoS guarantee that no messages are lost in ROS 2?

No. Reliable retransmits samples the publisher still holds, and with keep last it only holds the last N. A subscriber that falls far enough behind still misses messages, and retransmissions add delay on a lossy link. Use reliable for commands and state you can't miss, best effort for high-rate sensor data.

What queue depth should I use for a ROS 2 subscription?

It depends on whether you need every message or only the newest. For control and perception that act on the latest reading, a small depth (1 to 5) keeps data fresh and drops what you couldn't use anyway. For data you must process in full, use a larger depth and make sure the callback keeps up on average; a deeper queue only delays the drops if it doesn't.

How do I measure ROS 2 topic frequency in code?

In the subscription callback, record a monotonic timestamp per message and keep a short window of them. The rate is messages divided by the window's span, and the max gap is the largest difference between neighbours. Publish or log both every few seconds; measuring inside your own callback captures exactly what your node experiences.

#ROS 2#QoS#topic frequency#dropped messages#ros2 topic hz#DDS#robot monitoring
Eitan ChudnovskyCo-founder, PhysicalFleet

From the lab bench. To the entire fleet.

Connect your first machine in minutes, develop it in the lab and run your whole fleet in production from one place.

Free for up to 3 machines · Then pay as you go