Tracking cameras¶
TL;DR. The four OV7251 tracking cameras run on V4L2 through CAMSS; the station configures them and pulses their frame sync. Frames come in sets of one pulse, scene and controller-LED exposures alternating, each dated by the CSID's hardware start of frame.
How they work¶
The four OV7251s (640×480 mono, global shutter, RAW10) run on V4L2 through CAMSS (pico4_cam.c, kernel.md): per slot CSIPHY, CSID, VFE RDI at 640×481 Y10, multi-planar buffers in a ring, Y10P unpacked to 16 bits. A frame's time is the CSID's hardware start of frame from its buffer. The sensors' control port belongs to the station, which configures them over its own I2C:
- Metadata line. One embedded line precedes the 480 scene rows, so the capture is 640×481 as on
PICO OS (with 480 lines the bottom scene row is lost). Its 10-bit samples carry gain (word 4),
exposure (words 6, 7) and the exposure phase (word 82: 1 scene, 2 controller LEDs), decoded by
pico4_cam_meta_decode. Scene and LED exposures alternate. - Sets of one pulse. The sensors centre their exposures on the sync pulse, so frames are grouped by start of frame less half the exposure (lines of 19.07 µs), within 4 ms. Grouped by start of frame alone, per-camera exposures break the sets.
- Stalls. When no scene set completes for a second while frames arrive, the driver logs each
camera's state. On a stuck camera, or 3 s without a set, or 1 s without any frame, the camera thread
restarts the capture (sync off, sessions reopened, sync on, exposure set; at most once in 5 s); the
station takes the sync start only after a second stop. Frames return within 1–2 s.
PICO4_CAPTURE_RESTART_TEST_S=Nrestarts every N s (test only). PICO OS restarts its cameras the same way on finer triggers (a frame over 500 ms old, under 80% of the expected frames in 2 s).
pico4-cam capture tests the cameras alone: it resets the station, streams
until each camera delivered N frames, saves a scene frame per camera (8-bit PGM and 16-bit raw) and
prints per-camera JSON (frames, rate, monotonicity, statistics, exposure phases). --stats-log FILE
logs every frame; --exposure LINES --gain G sets the station exposure; --record-leds,
--record-scene and --record-imu record LED frames, scene frames and the controllers' radio packets
for replays. pico4-cam rgb tests the IMX471.
Frame times¶
The tracker, Basalt and the controller tracker take each frame's time from its buffer: the CSID's
hardware start of frame (the kernel commit “media: camss: the hardware start of frame as a buffer's time”) on CLOCK_MONOTONIC, carried in QTimer ns onto the
IMU's clock. The frame's time is the middle of its exposure: start of frame minus 52 µs, seven lines
(133.5 µs) and half the exposure in lines of 19.07 µs, from its metadata line, as PICO OS computes it.
Trap: re-take the clock offset. systemd-timesyncd steers CLOCK_MONOTONIC against the QTimer
(16.6 ppm here, 1 ms a minute), so the QTimer offset is taken again every second on the IMU and camera
threads. Taken once, it is 0.3 s off after five hours: poses look older than 200 ms and every motion
overshoots and springs back.
Running it¶
The cameras on their own (stop the Monado service first):
pico4-cam capture --frames 1500 --out /tmp/cams # all four at 50 Hz, JSON summary, one scene frame each
pico4-cam capture --exposure 300 --gain 32 --stats-log /tmp/frames.txt
Verified results¶
On the headset on Valve's kernel.
| Check | Result |
|---|---|
| Cameras | slot mapping by cover test; a pen at 0.15–0.18 m triangulates with 1–2 mm ray gaps; metadata line decodes the commanded exposure and gain, 50 scene and 50 LED frames of 100, 0 errors at 49.8 Hz |
| Frame sets in Valve's sessions (over 1,250 sets each) | no inconsistent or incomplete set while the exposure changed: all four sensors take a new exposure on the same frame |
CLOCK_MONOTONIC against the raw counter (timesyncd) |
0.998 ms in 60 s: 16.6 ppm |