Skip to content

Controllers

TL;DR. The station, an nRF52832 on SPI, relays the controllers and syncs the tracking cameras; the controllers' IMU, buttons and battery reach the driver through the sensor DSP. The driver makes each controller a Monado device with PICO OS's render models, sends vibration, and tracks each controller's 20 IR LEDs with a reimplementation of PICO OS's controller tracker.

The controller radio

The nRF52832 on /dev/spidev0.0 relays the controllers and generates the tracking cameras' frame sync (FSIN). On Valve's kernel it is a plain spidev: every transfer is full duplex, commands go out as transfers and zeros poll for the next frame every 2 ms. The station repeats its last frame until it has another, so only a frame that differs from the last is new.

  • Frames. 40 bytes: header (AA to the station, BB replies, A5 notifications), target (01 station, 02 left, 03 right controller) or notification type, command, payload (bytes 37–38 a sequence number), CRC-8 (Dallas/Maxim, reflected 0x8C, initial 0) over bytes 0–38.
  • Acknowledgements. Every station frame except stream notifications (A5 01) is acknowledged with FA carrying its bytes 37–38.
  • Data path. Controller IMU, buttons, sticks, touch and battery go from the station to the sensor DSP, which exposes them as the SSC sensor ble_mcu. SPI is only the control plane.
  • Bring-up. The station-power regulator's sysfs state power-cycles it (off, 100 ms, on). It announces itself (A5 06) within 3 s and waits for the camera frame rate (19, 01 00 01: 50 Hz, device type 0) before it accepts camera commands. The controllers reconnect on their own.
  • Sleep. PICO OS has no command that wakes a controller. Its goToSleep sends 0D 00 00 (controllers to slow advertising) and cuts the station's power; wakeUp powers it on. The driver does the same when it closes (pico4_station_sleep), as does pico4-station power off. Awake controllers lying still reconnect without a press after at least 15 minutes off; after hours they need a button press.
  • Camera sync. After a timeout the station refuses (EIO) every further start, so the tracker resets the station as the driver's start does, up to three times.
  • Firmware. 2.96, the version PICO OS ships.

The C module and the pico4-station tool build frames only from this allowlist:

Command Payload Purpose C module pico4-station
FA bytes 37–38 of the acknowledged frame acknowledge yes yes
0D exactly 00 00 (other first bytes are trackers) controllers to slow advertising yes yes
19 01 (50 Hz) or 02, device type, 01 answer to the announcement yes yes
04 01 00 02 00 (exposure-first-row flag 2, resolution 0) camera init yes yes
04 02, camera (0 all, 1–4), 01 on / 02 off camera stream yes yes
04 28 bytes: 03, 8 × (u16 exposure, u8 gain) in bytes 1–12 and 16–27, 52 (u16) and an event index in 13–15 camera exposure and gain yes yes
04 07 00, rate camera frame rate – yes
04 05 01, then 05 02 the camera modules' ids from their OTP yes –
01 none firmware version – yes
07 controller, 01 on / 00 off controllers' IMU stream to the DSP – yes
22 exactly 01 00 (a read; 0 would set the tracker work mode) work mode – yes
29, 30 none crash info, whitelist (read-only) – yes
02, 08, 03 exactly one byte, 01 left or 02 right enter pairing, stop pairing, unpair (Pairing) – yes
01 to 02/03 play (01, or zeros to stop), amplitude, u16 ms vibration yes –
02 to 02/03 exactly one byte, chunk 1–12 the controller's calibration record (read-only) yes yes
03 to 02/03 none controller info (read-only; these controllers do not answer) – yes

Neither sends firmware, bootloader or flash commands or touches the boot pin. The C module's unit test checks its frames against golden bytes from the Python tool and that every other command is refused.

Connections and calibration.

  • A5 03, hand in byte 2 (1 left, 2 right): disconnected.
  • A5 02, hand in byte 2, repeated a few times: connected. Bytes 3–8 software version, byte 9 status (low four bits: 1 connected, 2 invalid), 10–11 hardware, 13–29 the serial (naming its pvr/<serial>.txt), 30–35 the radio address.
  • The calibration record: 12 chunks of 32 bytes. The reply BB, target, 02 echoes the index in byte 3 (FF: not ready, retry after 50 ms; EE: error), data in bytes 4–35. Chunks 1–3: IMU calibration (gyro and accelerometer 3 × 3 matrix row-major, then bias; 24 floats); 4–11: the 20 LED positions in metres; 12: imu_IR (seven floats; valid when its fourth is 1 and the first IMU float is not 0). Late replies for another chunk are skipped.

Pairing

Pairing lives in the station and the controllers: controllers paired under PICO OS connect as they are. A replacement controller, one paired to another headset, or one unpaired from its own buttons (Home and Trigger for 4 s; A5 05) needs pairing. pico4-station pair left|right does what PICO OS's EnterPairing/StopPairing do:

  1. 02 with the mask (01 left, 02 right); BB 01 02 with byte 4 01 means it listens.
  2. The owner holds Trigger and Home for 6 s; the station reports A5 02, status 1.
  3. 08 with the mask ends the pairing, also after a connect or the timeout (60 s by default).

pico4-station unpair left|right sends 03 with the mask (BB 01 03, byte 4 01: done). The driver reads a newly paired controller's calibration on connect; there is no file per controller.

With the session stopped pico4-station talks to the station itself. While a session runs, pair, unpair and status go to the driver's pairing socket, $XDG_RUNTIME_DIR/pico4-station (session user and root only), served by the station thread between reads (pico4_station.h): one request per connection (pair left|right [SECONDS], unpair left|right, status). A pairing answers pairing HAND when the station listens, then paired HAND SERIAL or timeout HAND; a client that hangs up stops it. The onboarding (onboarding.md) pairs through it.

Inputs, poses and vibration

pico4_blemcu.c parses the ble_mcu events as PICO OS's SlpiDataParserV2 does. Each is a 200-byte radio packet: 5A, format version, station time in µs (bytes 4–11, LE), the records' length (byte 12), then records [length][type][id][time offset][data]. The id's low six bits name the device (1 left, 2 right, 3–5 trackers); bit 7 adds a time offset (2 bytes, 4 with bit 6) in µs before the packet's time.

  • IMU (type 0): gyro 3 × int16 at 8.192 LSB per °/s, accelerometer 3 × int16 at 1,024 LSB per g, temperature (raw / 132.48 + 25 °C), a 16-bit counter.
  • Inputs (type 1): trigger, stick y (255 up), stick x (255 right), grip as bytes (sticks centred at 128). Buttons: home (bit 0), menu, A/X, B/Y, grip, stick click (bit 5), trigger (bit 7). Touch: A/X (bit 0), B/Y, stick, thumb rest, trigger (bit 4).
  • Battery (type 2): one byte, a fifth of a charge per level (0–5), reported to SteamVR as a percentage; level 1 is low.

pico4_controller.c makes each controller a Monado device (PICO 4 left/right controller) with Monado's profile /interaction_profiles/bytedance/pico4_controller.

  • Timing. IMU samples are timed by the SSC event time (the packet's station time) minus the record's offset, as on PICO OS. Samples stamped at or after their arrival are dropped; the controller tracker starts over on a backward step or a gap above 35 ms.
  • Pose. While the controller tracker has placed a controller, its pose: tracked while 6DoF, valid but untracked while it holds the position (still or briefly unseen), as PICO OS publishes it. Before the first fix: m_imu_3dof orientation (IMU axes to the aim frame as x,-z,y) at a placeholder 0.18 m to the side, 0.35 m below and 0.30 m in front of the head. A controller whose newest sample is 0.2 s old holds its orientation, untracked.
  • Aim and grip. The tracked pose is the aim pose; the grip is aim × T, per hand, from PICO OS's tracking service (about 34° about x and 5 cm of lever arm), read by tooling/controllers/aimgrip.py into calibration/controllers/aim-to-grip.json. Without the file the grip is the aim. SteamVR gets the aim pose, the render models' frame.
  • Vibration. One motor frame (command 01) per request, mapped as PICO OS maps OpenXR haptics: level = amplitude × 255, whole milliseconds, at least 10 ms, Monado's minimum duration as 500 ms, 0 ms as a stop, at PICO OS's default strength of 75% (so PICO OS's low-battery limit never applies). SteamVR's pulses without a duration (hover feedback) go out as 10 ms.
  • Render models. tooling/controllers/controllermodel.py converts PICO OS's textured OBJs (/system/pre_resource/data/misc/user/controller/Neo3Phx/, 60.obj left, 61.obj right) to {monado}pico4_controller_left and _right, in metres in the aim frame. For the known disconnected topology it separates the four face buttons, trigger, grip and thumbstick from the stationary shell, tracking ring and LED, retaining the original geometry, UVs, normals and idle texture. SteamVR's native JSON motion descriptions animate these parts from the driver's input paths; MENU and PICO have separate aliases without changing the handed system mapping. Each button has a model component bit as well as its input path; SteamVR needs both even with its modern model-state API. The extra face button uses a distinct bit without changing the handed system mapping. The thumbstick bearing centre comes from its two lowest circular cross-sections, the trigger hinge from the front lip and the grip hinge from the tilted mounting rim. Travel is nominal visual feedback, not factory calibration. The complete static OBJ remains available; unknown topology keeps the static body. Aim, grip and battery status components keep their existing transforms and battery-panel UVs. These models stay in the headset's private stock tree: no new model assets or runtime dependencies are packaged.

Controller tracking

Each controller's ring of 20 IR LEDs lights in the station's short controller exposure, every other camera frame (4 lines at gain 26). tooling/controllers/ledmodel.py reads the nominal rings (20 points and normals per hand) from PICO OS's libpico_controller_tracking.pxr.so into calibration/controllers/led-models.json. On every connect the station thread reads the controller's calibration record and hands it to the tracker: the IMU calibration, its own 20 LED positions (replacing the nominal ones) and its gyro bias table pvr/<serial>.txt (read only; sm8250-persist copies the root-only files to /run/pico4-controllers/ for SteamVR's driver). The serial is not logged.

The tracker (pico4_ctrack_* in pico4-monado, C++17 with Eigen) reimplements that library's approach:

  • Frames. World +x up (the headset body frame), the LED-model frame equal to the controller IMU's after the remap (x, y, z) → (−z, −x, y).
  • Blobs. Threshold (fixed, or adaptive 11 × 11 mean + 30), outer contours, moments, area and circularity filters; a window around predicted LEDs while tracking, the whole image at > 70 for acquisition.
  • Acquisition from one camera: five or more blobs, an LED-triple search with the IMU's rotation and EPnP, else a geometric hash of 5-LED patterns (the rule PICO OS's table was built with); three or four blobs, P3P. Every result passes PICO OS's plausibility checks (brightness and footprint against distance, the other cameras, |x|, |y| < 1.2 m, |z| < 0.8 m around the head); three in a row start tracking.
  • Tracking. Facing LEDs projected with the IMU's prediction, associated by shift hypotheses, then a robust Levenberg-Marquardt fit over all cameras with a soft prior on the IMU rotation.
  • Fusion. A 15-state error-state filter (optical poses correct position and yaw; tilt from the IMU), predicted 41 ms ahead of the newest IMU sample. A hand is lost after 1.2 s still or 3 s moving without optical updates, or on an IMU gap over 35 ms.
  • At rest. A hand still for 3 s, or back from an IMU gap, tries no P3P until it has moved for 3 s or is tracked (as PICO OS). Controllers lying side by side look like one cluster that only P3P takes, so controllers put down together are found when picked up.

pico4_slam.c converts the LED sets to 8 bits and hands them to the tracker's thread, which waits up to 60 ms for the IMU up to the exposure and takes the head pose at that time. The aim pose is the LED-model frame offset by PICO OS's lever arm (about 2 cm, tooling/controllers/leverarm.py → calibration/controllers/lever-arm.json); without it or the LED models the tracker stays off. PICO4_CTRACK=0 turns it off; PICO4_CTRACK_TRACE=FILE writes a CSV row per hand and update.

Trap: the controller IMU rate. With ble_mcu the only sensor streaming, the DSP drops it from about 500 to about 90 events per second a few minutes after its start, and the gaps trip the 35 ms rule. The driver always streams the head IMU at 1 kHz, and pico4-cam --record-imu records it too.

PICO OS sends exposure commands all the time, so its tracker sees LEDs as they are after the first one (at 0.7 m neighbours merge, centroids move up to 1 px). It sets no LED level for the controllers (2F goes only to body trackers; 1B has no caller).

pico4-ctrack-replay runs the tracker over pico4-cam capture --record-leds LEDS --record-imu IMU recordings and prints per-hand JSON (--trace a CSV line per set). The head counts as still, up from the recorded head accelerometer (--head-up, or --estimate-head-up from a still controller); --max-imu-gap, --delay left|right S, --skip S.

Running it

The radio on its own (stop the Monado service first):

pico4-station version                             # station firmware version
pico4-station listen --seconds 5                  # frames the station sends

Verified results

On the headset on Valve's kernel.

Check Result
Station power cycle, announcement and frame-rate answer every time; firmware 2.96
Controllers in OpenXR both as PICO 4 left/right controller; per controller about 500 IMU samples and 100 input packets per second
Controller inputs and sticks every button, trigger, grip and touch decoded; sticks 0 and 255 at the ends of both axes
Controller tracker replay, both lying 0.71–0.73 m ahead, 30 s, LEDs before any exposure command both acquired in the third set, tracked in 747 of 750 sets; median residual 0.62–0.77 px; optical pose within 1.9 mm and 0.9° after 10 s; under 11 ms per set
Controller tracker in Monado's service, same controllers, after exposure commands the right tracked at 0.66–0.76 px; the left not acquired: its fits miss stock's limits by 12–46° of tilt with the brighter, merging LEDs
Controller tracker replay, both lying about 1 m ahead no acquisition: the fits lie at 0.99 m, outside PICO OS's range box (|z| < 0.8 m)
Controllers worn: lying on the table while the head moves both acquired within about 9 s; the right one at one world position for 53 s
Controllers worn: slid 30 cm along a ruler, three times there and back 30.4–33.3 cm (mean 31.8 cm)
Controllers worn: hands crossed, lowered out of view for 10 s no swap or jump; none closer than 0.49 m to the head; re-acquired when raised
Controllers worn, held still within 0.2–0.4 mm and 0.06°; no visible jiggle with PICO OS's render models (user)
Render models in SteamVR {monado}pico4_controller_left/right at the hands, turned like the real controllers (user)
Vibration pico4-station vibrate: 1 s at 255 felt on the addressed controller; vrcmd --spamhaptics left: 376 requests, 376 motor frames to the left, none to the right
Controller IMU rate 494–499 samples per second per hand held and moved, longest interval 4 ms; about 90 with ble_mcu alone
Controller gyro scale against the optical tracker 0.993–1.003 at 8.192 LSB per °/s (bias about 1.5°/s removed)
Controller samples, about 60,000 per hand no duplicate, backward or future-stamped sample; 4–9 single samples lost per 30 s
Controller calibration records 12 chunks each; matrices within 0.4% of identity, gyro biases up to 0.016 rad/s, LED positions 0.3 mm (mean) from the nominal models
Controllers worn, 120 s: the left switched off for 10 s and on held its place while off, record re-read in 48 ms on reconnect, tracked at once; event time minus station time 0.00–0.99 µs
Station power cycled 10 times, awake controllers still both reconnect within 0.3–0.4 s each time
Station off 30 s to 15 minutes, awake controllers still both reconnect within 1.3 s, without a press
Pairing in the running session a left controller that had lost its pairing connected about 10 s into a pairing, then tracked and vibrated