Skip to content

Lens distortion and IPD

TL;DR. The lens model is the stock compositor's: a polynomial per eye, from the lens's factory data or PICO OS's table of lens batches, around a lens centre from the factory file. The GD32 MCU reports the lens separation, which the driver reads every second, and moves the lenses, which pico4-lens and Overpressure Settings control.

Lens model

The lens model is the stock compositor's (libpxrcompositor.so), like the Oculus mobile SDK's:

  • Distortion. A panel point p metres from the lens centre is seen at tan-angle t·s(|t|²), t = p / F, s a polynomial K0…K10. Each eye's F and A0…A10 come from one profile, picked as PICO OS's ConfigServerService picks it:
  • distortion_parameter in pvr/OpticalCalibrationData.json, the lens's factory polynomial;
  • else the lens's batch in PICO OS's table of lens batches (SDK_Lens_Distortion_MatchConfigFile.txt, about 100 batches by mould, cavity and date, and default). The factory file's lens_data gives the lens's serial number, m<lens_model>_h<lens_hole>_d<lens_date>. Of the entries whose serial number contains <lens_model>_h<lens_hole>, and default, the one that sorts last at or below the lens's in plain string order: the newest batch of that mould and cavity dated on or before the lens, default for an unlisted mould or cavity or an older lens;
  • else the generic profile of SDK_Lens_ConfigFile.txt.

Factory files exist without distortion_parameter, and a headset's two eyes can carry lenses of different batches. Where a file has the polynomial, it equals its lens's batch entry, F included. - Lens centre. The panel centre plus lens_center_gos in millimetres, in the stock compositor's directions: a larger centerx moves it to the wearer's left, a larger centery up, in both eyes (in the driver's panel coordinates, y down: −centerx, −centery). As in stock, the offset moves only the lens model; the field of view stays symmetric. On SteamVR an asymmetric vertical field of view moves the picture by its asymmetry, several times the offset. Measured on the scanout, a right lens centre moved 2 mm moves that eye's picture 93 px up along centery and 98 px left along centerx, stock's 94 px (47 px per mm), and worn it moves slightly. The offsets differ per headset: on one, the two eyes' centery differ by 0.05 mm, on another by 0.33 mm. Stock's compositor reads no other field of the file's lens geometry (rotation_binocular, decenter_lineangle, lens_center_through_lens). The panels move with the lenses, so the IPD does not change the distortion. - Chromatic aberration. Red and blue scale the green tan-angle by 1 + CA0 + CA1·r² + CA4·r and 1 + CA2 + CA3·r² + CA5·r, from the stock SDK_Lens_ConfigFile.txt. Off by default as on PICO OS (sdk_chromaticStaus = 0); PICO4_LENS_CA=1 turns it on, and then the two-layer test scene drops to 83–87 commits per second (87–88 without).

pico4_lens.c feeds Monado's distortion mesh (one UV per channel). The polynomial is fitted only inside the panel's inscribed circle (2% beyond allowed); outside it the driver evaluates it at the circle and lets the tan-angle grow steeply, so the image ends cleanly. The field of view, from the panel centre to its edges (2160 px at 21.3 µm) through the green channel, is about ±53.3° per eye, the same to every side.

Reading the IPD

The GD32 MCU answers on /dev/ttyHS1 (115200 8N1, raw). pico4_ipd.c sends A0 08 00 00 00 A8 (get position; the last byte is the XOR of the others) and waits up to 200 ms for 79 a_lo a_hi b_lo b_hi xor: the lens separation in 0.01 mm (57.00–73.00 mm) and the Hall reading, told apart by range. pico4-fan shares the port: both hold an exclusive flock per transaction, and the IPD read gives up after a second. The driver re-reads every second; after a move SteamVR gets the new eye positions and Prop_UserIpdMeters_Float. Without an answer it uses Monado's default.

Setting the IPD

The motor moves the lenses (no wheel). pico4-lens set MM does what gd32ipdservice's SetIPDPosition does: A0 22 00 00 00 82 (no timestamp reports), A0 07 00 lo hi xor (the target in 0.01 mm, 58.00–72.00), then A0 11 00 00 00 B1 every 50 ms until the reply 79 state xor says 0 (1 while moving, 2 at the near end). 0.9 mm take 0.17 s and end within 0.05 mm. The motor stops by itself at 59.4–59.9 mm: a move there ends in state 2, where the lenses stopped. The range is PICO OS's, 58–72 mm; the PICO 4 is specified for 62–72. The Lens distance page of Overpressure Settings in SteamVR's dashboard controls it: a slider, ±0.5 mm buttons and four presets (press moves, hold 1 s stores, in ~/.config/pico4-lens/presets). As in PICO OS's settings, closer than 62 mm goes only once the wearer ticks the box of a warning that the lenses can press on the nose: until then a move closer stops at 62 and the warning shows; wider always goes, and leaving the page clears the box. An amber bar marks 58–62 under the slider. The first-run setup's lens page does the same.

Verified results

On the headset on Valve's kernel.

Check Result
Scanned-out image and lenses red L only in the left eye, blue R only in the right; grid lines straight, steady at 90 Hz; the checkerboard stays fixed in the room with no visible latency
Field of view from the lens data ±53.35° per side in the left eye, ±53.33° in the right
IPD 71.99 mm (Hall 888) with the lenses at their widest, 72 mm