Skip to the content
FixTheRobot Explore Robotics / UAV / Module 7 / M7-T7

UAV Systems Engineering · Module 7

M7-T7: Jitter and deadline monitoring

You cannot manage timing you do not measure. Monitor every critical loop and set thresholds from what the controller can tolerate.

  • Lesson 7 of 19
  • Embedded Systems, Timing and System Integration
  • Established engineering
  • About 5 minutes to read

Jitter is the difference between when a periodic task should run and when it does. Control and estimation algorithms assume a sample time; jitter makes that assumption false. A timing monitor turns invisible degradation into a log entry, a warning or a safe-state transition.

Learning objectives

After this lesson, you should be able to:

  • Measure period, jitter and deadline misses from timestamps using a monotonic clock.
  • Derive a jitter and miss threshold from the control loop’s tolerance.
  • Design watchdog thresholds and actions with hysteresis.
  • Report timing statistics in percentiles and as exceedance counts.

Conceptual explanation

Established The statistics and monitor design are standard practice. The tolerance of a particular controller to jitter must come from analysis or test of that controller; the example numbers below are illustrative.

For a periodic task with nominal period TT and release times rkr_{k}, define:

  • Period error ek=(tk−tk−1)−Te_{k}=(t_{k}-t_{k-1})-T, from the actual start (or output) timestamps.
  • Jitter: the spread of eke_{k}, reported as standard deviation and as the peak-to-peak or high percentiles; sometimes defined as the deviation of tkt_{k} from the ideal grid k T+t0k\,T+t_{0}, which separates drift from jitter.
  • Deadline miss: completion later than the deadline DD (often D=TD=T); count misses and consecutive misses.
  • Execution time: measured separately, to tell overload (long execution) from scheduling delay (late start).
Timing monitorA monitor timestamps each cycle, computes the period and its deviation, counts deadline misses, and raises a warning, a degraded mode or a watchdog reset depending on the severity and duration.Timestampsmonotonic clockPeriod / jitterΔt, deviationDeadline checkmiss counterThresholdswarn, degrade, resetLog + healthto supervisorThresholds come from the control requirement, not from what the system happens to do.
The monitoring chain from timestamps to action.
Animation of a timing monitor on a 4 millisecond control task. The period error trace is calm until an overrun burst makes the task fall behind by tens of milliseconds. The monitor state strip changes from ok to warn on the first large error, to degraded after five consecutive deadline misses, and back to ok only after two hundred clean cycles; the strips show the period error, the miss indicator and the monitor state.
Measure period error and deadline misses from monotonic timestamps; thresholds come from the control requirement (error in derived quantities ≈ vv ee / TT). A three-level monitor with hysteresis (enter fast, leave slowly) avoids flapping. Synthetic log with 0.2 ms jitter and one burst of 40 overrun cycles. (Looping, about 6 seconds; drawn and computed for this course with illustrative values.)

Engineering intuition

Control laws assume a constant Δt\Delta t. Jitter turns that into a random Δt\Delta t, which adds noise to derivatives (velocity = Δx/Δt\Delta x/\Delta t) and to integration. A controller that tolerates 1 ms of jitter on a 4 ms cycle may be fine; a Kalman filter assuming 10 ms with real intervals of 6 or 14 ms integrates the IMU incorrectly unless it uses the true timestamps. So there are two responses: use true timestamps in the algorithms, and monitor the jitter to detect when the system has left its validated envelope.

Monitor the right place: at the task’s start, its end and its output publication. Timestamping inside the task shows the scheduling delay only after it has already happened.

Mathematical formulation

If the controller’s discretisation assumes TT but the true sample time is TT + ee, a derivative computed as Δx/T\Delta x/T with the nominal TT has relative error e/(TT + ee). A velocity estimate from position differences has error

Velocity error from an unmodelled sample-time error
δv≈v eT\delta v \approx \frac{v\,e}{T}
Example
v=5 m/s, T=10 ms, e=2 ms  ⇒  δv≈1 m/sv = 5\ \text{m/s},\ T = 10\ \text{ms},\ e = 2\ \text{ms} \;\Rightarrow\; \delta v \approx 1\ \text{m/s}

Hence use measured Δt\Delta t, or limit the tolerated jitter: for an error budget δvmax⁡\delta v_{\max} at speed vmax⁡v_{\max} the jitter limit is emax⁡=T δvmax⁡/vmax⁡e_{\max}=T\,\delta v_{\max}/v_{\max}. Watchdog detection time with a timeout of mm periods is mm TT plus the monitor’s own period. For miss statistics, with independent miss probability pp per cycle, the probability of kk consecutive misses is pkp^{k}; real overruns are correlated (bursty), so measure the run length of consecutive misses directly instead of inferring it from pp.

ee
period (or timing) error of one cycle.
δv\delta v_max, vmax⁡v_{\max}
velocity error budget and the maximum speed.
mm
number of missed periods before the watchdog fires.

Architecture and data flow

Each critical task records a monotonic timestamp at start and end of every cycle into a lock-free ring buffer. A low-priority monitor task reads it, computes the statistics over a sliding window and publishes a health topic (period, jitter percentiles, miss count, consecutive-miss maximum). A supervisor consumes the health topic and the heartbeat and decides on warnings, degraded modes or a controlled stop. Statistics are also logged with the flight log for post-flight analysis.

Real-world UAV applications

  • Validating that a custom control module meets its timing before flight.
  • Detecting thermal throttling or overload in flight.
  • Setting watchdog thresholds for a companion-computer link.
  • Comparing timing before and after a software change.

Implementation example

This runs as shown. A timing analyser on a synthetic cycle log (a 4 ms task with Gaussian jitter and a burst of overruns): period error statistics, percentiles, consecutive deadline misses and a three-level monitor with hysteresis.

import numpy as np
rng = np.random.default_rng(6)
T = 0.004; n = 20000
start = np.arange(n) * T + 0.0002 * rng.standard_normal(n)                       # start times with 0.2 ms jitter
burst = slice(12000, 12040); start[burst] += np.cumsum(np.full(40, 0.0008))      # overrun burst: the task falls behind by up to 32 ms
exec_t = 0.0006 + 0.0001 * rng.random(n); end = start + exec_t
deadline = np.arange(n) * T + T                                                  # D = T relative to the ideal release
miss = end > deadline                                                            # a miss: completion after the next ideal release
period_err = np.diff(start) - T
def max_run(b):
    best = cur = 0
    for v in b: cur = cur + 1 if v else 0; best = max(best, cur)
    return best
print(f"period error: std {period_err.std() * 1e3:.3f} ms, p99.9 {np.percentile(np.abs(period_err), 99.9) * 1e3:.3f} ms; misses {miss.sum()}, longest run {max_run(miss)}")
# three-level monitor with hysteresis: warn if |period error| > 1 ms, degrade after 5 consecutive misses, recover after 200 clean cycles
state = 'ok'; clean = 0; consec = 0; transitions = []
for k, (e, m) in enumerate(zip(np.r_[0, period_err], miss)):
    consec = consec + 1 if m else 0; clean = clean + 1 if (not m and abs(e) < 0.001) else 0
    new = state
    if consec >= 5: new = 'degraded'
    elif state == 'degraded' and clean >= 200: new = 'ok'
    elif state == 'ok' and abs(e) > 0.001: new = 'warn'
    elif state == 'warn' and clean >= 50: new = 'ok'
    if new != state: transitions.append((k, new)); state = new
print("transitions:", transitions[:6])
assert max_run(miss) >= 5 and any(s == 'degraded' for _, s in transitions)
assert abs(5.0 * 0.002 / 0.010 - 1.0) < 1e-12      # the velocity-error example of the maths section: v e / T = 1 m/s
Timing statistics and a three-level monitor with hysteresis on a synthetic log with an overrun burst.

Common engineering mistakes

Using the wall clock for timing

It can jump with synchronisation; use a monotonic clock.

Timestamping the output only

You cannot tell scheduling delay from execution time.

Thresholds copied from another project

Derive them from your controller’s tolerance.

Reporting mean and standard deviation only

Jitter distributions are heavy-tailed; report percentiles and maxima.

No hysteresis

The system flaps between states and floods the log.

Failure modes

Failure modes, symptoms and causes
Failure modeHow it shows upLikely cause
Control quality degrades with loadMore oscillation at busy timesJitter increases with CPU load
Watchdog resets in flightUnexpected rebootThreshold too tight or a long, rare stall
Hidden overrunsNo indication in the logsMonitor only on the mean
Clock jump confusionNegative Δt\Delta tWall clock used instead of monotonic

Debugging approach

  1. Log the start, end and execution time per cycle for the critical tasks.
  2. Plot period error histograms with a log axis to show the tail.
  3. Correlate overruns with other activity (logging, GC, thermal throttling).
  4. Run the monitor offline on recorded logs to tune thresholds.

Practical exercises

  1. Compute the jitter limit for a 0.2 m/s velocity error budget at 8 m/s with a 5 ms cycle.
  2. Measure the period error histogram of a node of yours and report p50, p99, p99.9 and the maximum.
  3. Add a hold-off so a single miss does not trigger the warning, and justify its length.
  4. Write the watchdog policy (thresholds, actions, recovery) for the estimator.

Interview questions

Write an answer in your own words, then reveal the model answer. Nothing is sent anywhere.

Question 1

How do you measure jitter?

Model answer

Record monotonic timestamps at the start (and end) of each cycle, compute the period error against the nominal period or the ideal grid, and report percentiles and the maximum alongside deadline misses and the longest run of consecutive misses.

Question 2

How do you choose a jitter threshold?

Model answer

From the control requirement: the tolerated error in derived quantities (for example velocity error = vv ee / TT) fixes the allowed timing error, with margin.

Question 3

Why hysteresis in a timing monitor?

Model answer

Without it a borderline condition toggles states repeatedly, flooding logs and causing mode flapping; thresholds for entering and leaving a state should differ.

References and further reading

Primary papers, official documentation and standards. Each claim above that is specific to a tool or version points here.

What’s next

Mark this lesson

Saved in this browser and synced to your account when you are signed in.

Next lesson

M7-T8: Camera, IMU and LiDAR synchronization

Align camera, IMU and LiDAR clocks by triggering or estimation, and measure the residual time offset from data.