Skip to content
Physical AI
All experiments

Latency, jitter and stale observations

Why the observation a controller uses is always older than the moment it is used, how fixed latency, jitter and the ratio between sensor and controller rates set that age, and how jitter can reorder packets.

Loading simulation…

What it demonstrates

Why the observation a controller uses is always older than the moment it is used, how fixed latency, jitter and the ratio between sensor and controller rates set that age, and how jitter can reorder packets.

How it works

A sensor samples a 3 Hz gyro signal and sends a timestamped packet at a fixed rate. Each packet's delay is the fixed latency plus a uniform random jitter. An event-driven model processes sends, arrivals and controller reads in time order.

At every controller tick, the controller uses the packet its receiver currently holds and records its age: read time minus send time. With the 'newest sequence' policy, a packet that arrives after a newer one is discarded; with 'last arrival', it replaces the newer value and the controller briefly goes backwards in time.

Adjustable parameters

  • Sensor rate (50–1000 Hz)
  • Fixed latency (0–30 ms)
  • Jitter (0–20 ms)
  • Controller rate (50/100/200 Hz)
  • Receiver policy
  • Playback speed

Known limitations

  • Jitter is uniform and independent per packet; real networks and buses have bursty, correlated delays.
  • Sensor and controller clocks are perfectly synchronised; real systems also drift.
  • All numbers are illustrative.

Equations

dk=L+J uk,uk∼U(0,1)d_k = L + J\,u_k,\quad u_k \sim \mathcal{U}(0,1)
age(t)=t−tj∗(t)send,j∗=arg⁡max⁡j{ seqj:tjsend+dj≤t }\text{age}(t) = t - t^{send}_{j^*(t)},\quad j^* = \arg\max_j \{\,\text{seq}_j : t^{send}_j + d_j \le t\,\}
L  ≤  age  ≲  L+J+1/fsendL \;\le\; \text{age} \;\lesssim\; L + J + 1/f_{send}

Core update rule

// next event in time order: arrival, send or read (lib/sim/ch05-link.ts)
if (arrival) {
  if (pk.seq > current.seq || receiver === "arrival") current = pk;
} else if (send) {
  inFlight.push({ seq: seq++, tSend: now, tArrive: now + latency + jitter * rng() });
} else {
  reads.push({ t: now, age: now - current.tSend, value: current.value });
}

Explained in Chapter 5: Communication & Firmware