ECLIPTIC Protocols — the seams ZTHREAT frames

Protocols · the seams

ZTHREAT — zvision to tablets

One UDP datagram is exactly one frame of contacts. This is not NMEA: no leading $, no checksum, and a numeric grammar pinned explicitly on both sides — because a wire format must not inherit its host language's parser.

Frame format

ZTHREAT;<id>:<relAzDeg>:<size>:<collision>;<id>:<relAzDeg>:<size>:<collision>;...

A bare ZTHREAT with no contacts is an explicit all-clear, and is what the runner emits on shutdown.

ZTHREAT;1:-12.0:0.300:0;2:4.5:0.900:1
FieldTypeMeaning
idintegerTrack id. 0 is the “unidentified” id and never latches the tracker light. Ids are namespaced per camera as camera_index × 1000 + local_id.
relAzDegfixed-point, 1 decimalBearing relative to the vehicle's nose. Negative = left, positive = right. Full circle: ±180.
sizefixed-point, 3 decimalsApparent size, 0 = far → 1 = near. A sensor prominence proxy for range, not a distance.
collision0 or 1Constant-bearing-while-growing collision flag

There is no leading $ and no checksum — UDP already carries a checksum, and the frame is validated structurally.

Limits

ConstantValue
HeaderZTHREAT
Frame separator;
Field separator:
Fields per contact4
Max absolute azimuth180.0
Max contacts per frame32
Azimuth decimals1
Size decimals3

The 32-contact cap keeps a frame inside one MTU — a fragmented multicast datagram over lossy WiFi essentially never arrives. When a frame would exceed the cap the producer sorts by collision first, then size descending and truncates, so the contacts that survive are the ones that matter.

Bearings past ±180 are garbage rather than rear contacts, and are dropped. size is clamped into 0–1 by the consumer. A malformed collision flag never costs the driver a contact — the body is still drawn, just not in collision red; anything that is not exactly "1" is false.

The numeric grammar is pinned, deliberately

id      -?[0-9]{1,9}
number  -?[0-9]{1,9}(\.[0-9]{1,6})?

Both sides check these patterns explicitly rather than delegating to toFloatOrNull / float(). A wire format must not inherit its host language's parser quirks. [0-9] rather than \d, because Python's \d also matches Unicode digits and Java's does not.

Framing whitespace is spelled out as exactly " \t\n\r\v\f" on both sides, because Kotlin's trim() and Python's strip() disagree about which Unicode code points count, and a wire contract cannot depend on that.

Nine integer digits keeps an id inside Int32 and keeps every value far below 32-bit float range, so no parsed number can be NaN or infinite.

Producer rules

  • Contacts with a non-finite azimuth or size are dropped at the producer. A NaN would serialise as the literal nan, which both parsers reject anyway — but a producer must keep its own frames well-formed rather than leaning on the consumer's guard being there.
  • Fixed-point formatting rounds half-to-even on both sides. The Kotlin side uses BigDecimal, which is locale-independent by construction — String.format would follow the device locale and emit 0,300.
  • The Kotlin side restores the sign of -0.0 from the raw float bits, because BigDecimal has no negative zero and would spell it 0.0 — and a contact a hair to the left of the nose is exactly where that shows up.

What the consumer does with a frame

NetworkThreatSource publishes the parsed contacts and marks the feed alive. A 1.5 s silence watchdog clears both. RoutedThreatSource derives an explicit feed state:

StateMeaningShown as
LIVEFrames arrivingn CONTACTS   CLEAR (or an alert), solid ring rim
DEMONo frames, synthetic source enabledn CONTACTS   DEMO, dotted grey rim
ABSENTNo frames, no synthetic sourceNO VISION, dotted red rim
An empty-but-live frame is a real all-clear

It must never trigger the demo fallback. On a deployed vehicle the demo source is disabled, so a dead feed reads ABSENT rather than inventing pedestrians. The word CLEAR may only appear when the feed is LIVE.

ZCOVER — camera coverage

A dead camera stops producing contacts for its arc, and on the wire that is identical to “that arc is clear”. ZCOVER is the low-rate companion channel that lets the surround ring tell blind from clear. It rides the same group, port and socket as ZTHREAT, so an old tablet's ThreatProtocol.parse() simply returns null for it, and an old Jetson never sends one.

ZCOVER;<start>:<end>;<start>:<end>;...
ZCOVER;-64.0:64.0
  • Covered arcs ride the wire, not blind ones, so the degenerate empty message fails blind: a bare ZCOVER means the whole ring is blind, and is sent on exit.
  • At most 16 arcs, degrees off the nose to one decimal, swept clockwise; the numeric grammar and 32-bit rounding are shared with ZTHREAT.
  • Producer (zvision/coverage_protocol.py): the union of arcs whose camera delivered a frame within 3.0 s, emitted at 1 Hz plus immediately on any change.
  • Consumer (core/vision/CoverageProtocol.kt → NetworkThreatSource): its own 5 s staleness timer, and it never marks the threat feed alive, so coverage alone cannot resurrect a dead ZTHREAT feed. Stale or missing coverage falls back to the static SurroundRing.COVERED_ARCS (±64°).
  • Its own golden corpus, protocol/coverage-protocol-golden.json, generated by jetson/tools/gen_coverage_golden.py and read by both suites.

Two hand-written implementations, neither authoritative

FileRole
Producerjetson/zvision/threat_protocol.pyformat_frame runs on the vehicle
Consumerapp/…/core/vision/ThreatProtocol.ktparse runs on the vehicle

Each also carries the other direction (parse_frame / format) purely as a mirror. Nothing on the vehicle exercises those halves — which is exactly why they drifted for months without anyone noticing. A cross-language contract rots in whichever direction nobody executes.

The shared truth is a measured corpus that both test suites read. The golden corpus →

The bearing reference is settled

Settled 2026-08-10

Bearings on this channel are computed by zvision's pixel_to_bearing, fed by --fov-ref, which now defaults to d (diagonal). The tablet assumes the forward thermal camera covers ±64°, and the Python side now computes the same ±64° by default, so the two sides agree without anyone remembering a flag — confirmed by measurement. Read the full argument →

Converted from
docs/PROTOCOLS.md §3 · protocol/README.md · jetson/DEPLOY.md