
A ROS 2 LiDAR stream can look intermittent even when the sensor is publishing continuously. A deadline event callback helps answer a narrower question: did a publisher fail to provide a sample within its offered deadline, or did a subscription fail to receive one within its requested deadline? Treat these as endpoint observations, then correlate them with timestamps and recorder evidence; a callback alone does not identify every network or driver fault.
Start by recording the actual endpoint QoS and ROS distribution. The ROS 2 QoS documentation defines deadline as the expected maximum interval between messages. It also distinguishes offered and requested deadline-missed status. The two callbacks therefore answer different questions and should not be collapsed into a single “LiDAR dropped data” alarm.
This guide shows how to set a measurable deadline, register callbacks in rclcpp, and interpret them alongside the site’s guides to publisher-rate troubleshooting, QoS compatibility, and stale-data watchdogs.

What a deadline event tells you
Deadline is a QoS policy, not a guarantee that a sensor, operating system, DDS implementation, or network will meet a chosen period. A publisher’s offered deadline describes its contract to publish often enough. A subscription’s requested deadline describes the interval it expects to observe. If the configured durations are incompatible, the endpoints can also be unable to communicate; inspect compatibility events and graph state before diagnosing a missed deadline.
The useful diagnostic distinction is location. An offered deadline-missed event points toward the publisher side of the boundary: driver scheduling, acquisition, conversion, publication timer, or a stalled callback. A requested deadline-missed event says the subscription did not observe samples at the expected interval. The cause may be upstream publication, discovery or QoS compatibility, transport, executor scheduling, or subscriber work. Neither event by itself proves packet loss.
ROS 2 exposes status callbacks through event handlers. The rclcpp event handler interface is implementation documentation; verify the exact callback types and supported policies in the distribution you build. The rolling branch can differ from a released distribution. A practical starting point for the wider system is the QoS deadline, liveliness, and lifespan design note.
Choose a deadline from the application, not a guess
First measure the sensor’s expected publication interval under representative operating conditions. Use message header stamps where their clock semantics are known, receipt timestamps from the subscriber, and a monotonic clock for local elapsed-time measurements. Keep sensor time and host receipt time separate: clock offset, synchronization error, driver buffering, and timestamp assignment can make them disagree.
Then select a deadline that represents a meaningful service expectation. If a sensor nominally emits at a steady cadence, the threshold should allow ordinary variation while still detecting a gap early enough for the consumer’s safety or planning logic. There is no universal LiDAR deadline. A threshold that is too tight will produce noisy events; one that is too loose can delay fault detection. State the rationale and revisit it when scan mode, resolution, transport, or compute load changes.
Use a bounded observation window and record the chosen QoS on both endpoints. ROS 2’s QoS override guide explains node-level policy overrides for supported policies. Do not assume all policies can be changed dynamically or that a runtime parameter change retroactively alters an already-created endpoint.
The generated rclcpp PublisherEventCallbacks reference lists the offered-deadline callback type. It is a convenient API index, while the installed ROS headers remain the source to compile against; generated API mirrors can lag a branch.
Register publisher and subscriber callbacks separately
In rclcpp, create event callback options for the publisher and subscription, then attach the appropriate deadline-missed callback to each endpoint. The exact member names and callback signatures vary with ROS distribution and API version, so use the headers shipped with the target installation rather than copying a rolling-branch snippet blindly. The callback should do minimal work: capture the status change, a local monotonic timestamp, endpoint identity, and a counter or status field, then return.
Avoid formatting large logs, writing files, blocking on a service, or rebuilding a point cloud inside the event callback. Those actions can perturb the very scheduling behavior being observed. Hand off a compact event record to a diagnostics queue or a non-real-time logging path. Include a startup record that states the topic, endpoint role, requested/offered deadline, reliability, durability, depth, ROS distribution, and RMW implementation.
Keep separate counters for publisher-side offered misses and subscriber-side requested misses. If the application reports a cumulative total, make the reset or delta semantics explicit. Preserve the event timestamp and the period since the previous sample so later analysis can align it with driver logs, CPU load, and bag data.
Correlate status with messages before assigning a cause
Build a timeline from at least three views: publisher production, subscriber receipt, and recorder observation. Compare message header stamps, publisher sequence numbers if available, host-side receipt times, and the deadline event time. Sequence gaps can reveal missing samples only when sequence assignment and restart behavior are understood. A process restart, counter wrap, or clock-domain change can resemble a loss event.
Record a short reproduction with the relevant topics and endpoint QoS. The site’s reproducible support bundle checklist is useful for preserving software versions, launch configuration, logs, and sample data. When using rosbag2 for late-subscriber durability checks, remember that recording and playback create their own endpoints; their QoS and timestamps are additional evidence, not a direct copy of the live publisher’s callback state.
For a controlled test, log a publisher counter immediately before publish and a subscriber counter after callback receipt. Add a recorder observation if the bag matters. Compare the resulting counts over a defined interval, note starts and stops, and preserve raw timestamps. This establishes where the observable gap first appears. It still does not isolate whether a delay came from sensor acquisition, executor scheduling, middleware, operating-system load, or storage unless those layers are measured independently.
Separate deadline misses from other QoS and transport events
Deadline, liveliness, lifespan, and reliability describe different conditions. A deadline event means an interval expectation was missed. Liveliness concerns whether an endpoint is considered active. Lifespan governs whether old samples remain valid for delivery. Reliability affects delivery semantics, but a missed deadline callback is not a packet-loss counter. ROS 2’s QoS overview documents these policies and their compatibility rules; test the actual endpoint pair rather than inferring from a launch file alone.
Check for incompatible-QoS events and graph discovery before treating silence as a deadline miss. Confirm that topic names and namespaces match, that both nodes use the intended RMW, and that security or domain configuration does not split the graph. If the publisher callback remains quiet while subscriber callbacks fire, compare their timestamps and then inspect transport-level evidence. If the publisher callback fires first, investigate acquisition and publisher scheduling before changing downstream QoS.
Field checklist
| Check | Record | What it helps distinguish |
|---|---|---|
| Endpoint contract | Requested and offered QoS at runtime | Configuration and compatibility issues |
| Deadline rationale | Measured cadence and acceptable gap | Noisy threshold versus delayed detection |
| Callback event | Endpoint role, timestamp, cumulative status | Publisher-side versus subscriber-side observation |
| Message timeline | Header stamp, receipt time, sequence if available | Production gap versus later delivery delay |
| Reproduction | ROS distro, RMW, load, bag and launch config | Repeatability across systems |

Keep raw observations before changing several settings at once. Alter one variable, repeat the same capture, and compare the event timeline. A change that removes a callback but also changes sensor mode, executor layout, and QoS does not identify which factor mattered.
FAQ
Does a deadline callback prove a LiDAR packet was lost?
No. It reports that an endpoint did not meet its configured interval expectation. It does not identify the layer or prove packet loss. Correlate publisher production, subscriber receipt, and transport or recorder evidence.
Should publisher and subscription use the same deadline?
The endpoint contracts need to be compatible, and the chosen values should match the application’s service expectation. Inspect both runtime profiles and the target ROS distribution’s compatibility rules rather than assuming equality is always sufficient.
Can I set the deadline to the sensor’s advertised rate?
Use observed cadence and allowed jitter, not only a nominal rate. Include startup behavior, sensor modes, scheduling variation, and the time the consumer can tolerate missing data. Document the basis so future changes can be evaluated.
The reliable workflow is to observe both endpoint boundaries, keep callbacks lightweight, and correlate event timestamps with actual message flow. That turns “the point cloud looks uneven” into a bounded investigation without claiming more than the evidence shows.


