Head tracking¶
TL;DR. The head is tracked by PICO OS's own tracker, libSlam.so (PICO4_SLAM_BACKEND=stock, the default):
a multi-camera visual-inertial tracker whose front end runs on the Compute DSP (CDSP). In Valve's
idle session pico4-slamd takes about 70% of one core and vrserver about 120% (with Basalt
350–390%). Basalt stays selectable as it is. Without the tracker's data in the image, or
without the station, the HMD stays on 3DoF.
cameras, head IMU ─▶ pico4_slam.c (driver_monado or monado-service)
│ raw 10-bit scene sets, IMU samples ▲ poses (IMU rate)
▼ │
/dev/shm/pico4-slam (pico4_slam_feed.h) │
│ │
pico4-slamd ── image processing ── libSlam.so ─┘
(bionic root /usr/lib/pico4-stock-slam) ── FastRPC ──▶ CDSP
PICO OS's tracker¶
- Its root.
/usr/lib/pico4-stock-slam, with PICO OS's bootstrap linker and bionic C library (no Android runtime): the tracker and its libraries (libion.soamong them, without which the DSP optical flow cannot allocate and 6DoF never starts), DSP modules, configuration (/system/etc/pvr/config), the DSP's process shells andcdsprpcd, the headset's own: preinit binds them in read-only from the data partition's copy and thedsppartition (installed-system.md). Stand-ins of this project:libandroid.so(the trace calls and the hardware-buffer calls, which fail) andlibpico4-slam-stubs.so(preloaded: Android logging to the journal, empty property lookups). Programs in the root are built with clang foraarch64-linux-android29, without an NDK: the package pico4-slamd of overpressure/packages. - Its runner.
stock-slamchroots a program of the root in a private mount namespace with/dev,/proc,/sys, persist'spvr/at/mnt/vendor/persist/pvrand/mnt/vendor/pvr, and tmpfs/dataand/tmp. - The CDSP.
pico4-cdsp.serviceboots it withremoteproc-boot cdsp(cdsp.mdt,cdspr.jsn).pico4-cdsprpcd.servicerunscdsprpcdin the root; without it the DSP's loader stalls on the tracker's first module. The tracker opens a signed user PD (fastrpc_shell_3) and loads its modules itself. The DSP's context banks must be coherent, as in the stock device tree, or it reads stale frames. - The FastRPC bridge. The stock
libcdsprpc.sospeaks the vendor kernel's ioctls on/dev/adsprpc-smdand allocates through ION; Valve's kernel has upstream FastRPC (/dev/fastrpc-cdsp) and DMA-BUF heaps.stock-slampreloadslibpico4-fastrpc-bridge.so(fastrpc_bridge.h): GETINFO opens the upstream node, INIT and INIT_ATTRS become INIT_ATTACH, INIT_CREATE or INIT_CREATE_STATIC, INVOKE becomes the upstream INVOKE, MMAP and MUNMAP keep their layouts, CONTROL says the kernel allocates (FASTRPC_CONTROL_KALLOC), and ION allocations come from/dev/dma_heap/system. The DSP's memory requests (apps_mem) are mapped by descriptor through the kernel commit “misc: fastrpc: map a client's buffer through mmap”. Its translations have native tests. - pico4-slamd.
pico4-slamd(unit, wanted by Valve's session and Monado) creates/dev/shm/pico4-slam(group video, 0660) and drives the tracker as PICO OS's tracking service does:createHandle(""),headSensorModelicm4x6xx,startAlgorithm, the result callback,start6DOF6; one thread passes every IMU sample, another each frame set once the IMU is 30 ms past it (earlier, the tracker waits for the IMU in vain).updateImageonly queues; the work happens inside a laterupdate6AxisIMU(up to 11 ms), so poses can be up to about 18 ms apart. Each driver start bumps a generation in the shared memory;pico4-slamdthen exits and comes back with a new tracker. - Images. PICO OS's processing, reimplemented in isp.h: the first scene
row doubled (replacing the metadata row), black level 16 off,
v + (v >> 8), a per-pixel lens-shading gain (128 = 1×) and a 10-to-8-bit gamma table; no rotation. The lens-shading table follows camera 0's module (vendor) id: 8 →config_lscSY.txt, 9 and 13 →config_lscLH.txt, 7 →config_lscneo3.txt, else none (PICO4_SLAMD_LSCoverrides). The ids live in/var/lib/pico4-stock-slam/stationservice/camera_otp.json(PICO OS'scamera_otp.json, bound into the root); when they are not valid, the driver reads them from the modules' OTP through the station (op05) before it starts a tracker, andpico4-slamdsaves them. - Recovery. When the tracker's confidence falls from 1 to 0 and stays 0 for more than 10 s
(
PICO4_SLAMD_RESTART_S, 0 off),pico4-slamdrestarts it in the process (pre-stop, stop with the map saved, destroy, start), as PICO OS's service does; libSlam otherwise can stay in relocalisation for good. The restarted tracker relocalises in the room as at a start. - IMU. Raw samples of the factory body frame at 1 kHz, as PICO OS feeds them, each with the
ICM-42688's latest die temperature (the gyro bias table is binned by it): the driver streams
sensor_temperatureat 5 Hz beside the IMU; without onepico4-slamdpasses 30 °C. - Poses. World and body frames have the body frame's axes (x up, y left, z back); the driver
maps both into HMD axes (inverse of
Q_B_Hon each side), adds the HMD origin and predicts along the pose's velocities to the requested time plus the display lead, at most 45 ms past the newest pose, as PICO OS'sgetPredictResultdoes. Past times (the controller tracker's LED exposures) are interpolated. The HMD takes the poses directly (the tracker fuses the IMU). A pose older than 200 ms, or untracked, counts as lost: the HMD keeps the last position with the 3DoF orientation.
Auto exposure¶
PICO OS's own, ExposurePredict from libExposureImageProcess.so, called as its calcExpo thread
does, on a thread of pico4-slamd: per scene set it is not busy with, the four 16-bit images after
black level and lens shading, the set's lines and gains, 50 fps, flicker detection on. Its result
(lines 13–737, gain 16–240 in steps of 16; cameras 2 and 3 share one) goes to the driver unless
unchanged; the driver sends it per camera as the scene phase of CameraSetPara and runs no auto
exposure of its own while pico4-slamd serves its generation with a fresh heartbeat. Frame counters,
not exposures, decide whether frames form a set. PICO4_SLAMD_AE=0 leaves the exposure to the
driver's median loop (Basalt).
Room setup¶
PICO OS keeps a room with the tracker's map: libSlam.so loads the maps in /data/misc/user/0/maps
at createHandle, tries to relocalise for about 8 s after start6DOF, and saves its map at the stop
(preStopAlgorithm, stopAlgorithm non_sleep, destroyHandle) only while boundary/stdata.txt
holds a boundary (createHandle and start6DOF empty it). After a relocalisation it writes the
saved boundary in this session's world to boundary/stdataforalgorithm.txt; pico4-slamd watches
that file (the callback RelocResultCallbackRegister is not called with this configuration). Boundary
files hold vertexcount and points (a, b, c), b up; the world point is (b, −a, c).
- Where it lives.
stock-slambinds/var/lib/pico4-stock-slam/{maps,boundary}(data partition, mode 0700) into the root, so maps survive reboots and updates and never leave the headset. - Room ids. Every map is saved with its room's reference quadrilateral as its boundary, 1.5 m
below the room's first start: three sides of 1.5 m + v × 0.2 mm, v 12 bits each, which carry the
room's id (room.h). After a relocalisation
pico4-slamdreads the id from the copy's sides and fits the copy to the room's shape (a turn about up and a shift, accepted below 5 cm residual): the transform from the session's world to the room's. It publishes it in the shared memory and writes the copy tostdata.txt; the driver puts every pose of that generation into the room's world. The tracker relocalises about 1 s after its first frames. Without a relocalisation 10 s after the first frame set (PICO4_SLAMD_RELOCALISE_S) the session becomes a new room with a random id; a later relocalisation moves it into the saved room. Rooms saved with the plain 2 m square (no id) get an id at their next relocalisation and keep their universe throughboundary/pico4_rooms.txt; play areas drawn against the plain square can be off by a quarter turn until drawn again. - SteamVR's universe. The room's identity
room-<id>hashes to its universe (never 0, 1 or 424242, whichvrserverreserves). Once the room is settled,driver_monadoswitches universes as the Frame's driver does, throughvrserver's unversionedIVRChaperoneServerDriver_XXX: slot 1 restores a universechaperone_info.vrchapholds (bool (uint64 universe, const HmdMatrix34_t *, bool refine), identity, false), else slot 0 creates it (void (uint64 universe, bool keepOrigins), true: a 1 m default play area, room setup not done, so SteamVR asks for the playspace setup). Setting onlyProp_CurrentUniverseId_Uint64leaves a new universe without a standing space. Until the room is settled the universe is 2. The tracker's map name (getRelocMapInfo) is no identity: after a merge it can be the session's new map. - Room setup in the headset. SteamVR's Space Setup menu needs
Prop_SupportsInHMDRoomSetup_Bool(11003), and its steps past the recenterProp_VRLinkClientHMDSupportsRoomSetupRequests_Bool(11004; without it "HMD doesnt support setRoomSetupStep").driver_monadoreports both; away from a VR Link server the steps run in SteamVR (VRChaperoneSetup) and the result is kept per universe inchaperone_info.vrchap. Clear Playspace exists only in SteamVR's main-branch builds. - The detected floor. As on the Frame, the driver hands the floor height to
vrserverwhile the dashboard's room-setup step (event 809) is 3 (boundary circle), 6 (silent detection at start) or 7 (playspace setup): through the room setup's transform (/chaperone/room_setup/transform, y′ = m₁₁·y + m₁₃) to the unversionedIVRServerInternal_XXX, slot 40, which posts it to the compositor (floor_detection_result); NaN clears it when the step ends. HerelibSlam's ground detection gives the floor (plane1,setPlaneDetect; status 1 per fitted plane, 1.3 m below the head if none). The first height depends on what the cameras see (a bed or table gives 1.2 m instead of 1.6 m), so each of these steps restarts the detection (pico4_hmd_detect_floor, the feed'sfloor_requests; monado-steamvr-floor.patch). Slot 40 belongs to thisvrserverbuild: check it again with every new SteamVR. - Recenter. Holding the PICO button runs room-setup step 1: SteamVR resets only its seated zero pose; the standing pose and play area stay, and the recenter is gone after a SteamVR restart.
Basalt¶
Deprecated: selectable (PICO4_SLAM_BACKEND=basalt) as it is, without further work. Monado loads
Basalt through its VIT interface (libbasalt.so from pico4-basalt,
Monado's fork, pinned; built for armv8.2-a, since -march=native under QEMU emits SVE). Arch's
OpenCV highgui links Qt, so qt6-base is in the image.
- Frames. Scene sets only (LED frames make Basalt drift by hundreds of metres), with one exposure
and gain in all four metadata lines and each camera's ISP frame counter at its usual offset; other
sets are dropped and counted. 480 scene rows, 8 bits after black level 16 and a digital gain
(1–8×, aiming at mean
PICO4_SLAM_BRIGHTNESS). Images upside down relative to the first camera are turned with their calibration (pico4_tcam_rotate_180); Basalt's stereo matching cannot follow the lower pair's 180°. - Auto exposure. Every 25 sets from the median brightness of the cameras (one covered or
saturated camera is ignored): from 300 lines and 1×, aiming at 250 above black (10-bit), at most 4×
per step; exposure first up to
PICO4_SLAM_MAX_EXPOSURE(400 lines, against motion blur), then gain up to 15.5×. - IMU. Raw body-frame samples, every second one (
PICO4_SLAM_IMU_DIVISOR), with the delivered rate declared (1024 Hz for 1 kHz) and noisePICO4_SLAM_IMU_NOISE(about five times the measured Allan deviation; PICO OS's tracker's values made Basalt jiggle and run away). - VIO settings. pico4-vio.json
(
basalt-vio-config.patch):optical_flow_image_safe_radius300 px, outside which the fisheyes are black. Basalt logs "Using VIO config" when it loads it. - Decoupling. Two feeder threads (the newest frame set; a 2,048-sample IMU ring) keep the cameras
and the IMU thread from waiting on Basalt; one feeder for both deadlocks.
basalt-realtime-input.patchkeeps one set waiting for the optical flow and two for the estimator and never blocks IMU pushes (unbounded queues made poses trail by 641 ms). At shutdown the driver stops the frames and gives Basalt a second before stopping it, or its optical flow aborts. - Priority. Basalt, its TBB workers and feeders run at nice 19 on cores 0–5 (
PICO4_SLAM_CPUS), leaving the two fastest cores to the compositor and the app. - Fusion. Basalt's 25 Hz poses arrive about 100 ms late. pico4_fusion.c
keeps the pose at the IMU rate: the 3DoF orientation turned towards Basalt's (0.5 s), the
accelerometer integrated for position, pulled to Basalt's position and velocity at the images'
time (
PICO4_FUSION_POSITION_MS), corrections faded in overPICO4_FUSION_SMOOTHING_MS. Without a Basalt pose for 500 ms the position is held, untracked. - Anchor and runaway. A pose more than 15 cm or 10° off is an outlier; five in a row move the
anchor. A pose is implausible when its velocity change over 0.5 s exceeds the accelerometer's by
0.5 m/s, when it moves above 0.15 m/s with the IMU quiet for 0.5 s, or above 4 m/s; three in a row
hold the position and reset Basalt (
t_slam_reset, every 5 s while lost), then re-anchor. - Without the fusion (
PICO4_FUSION=0), Monado's prediction from Basalt's newest pose (the driver setsSLAM_PREDICTION_TYPE3, gyro plus mean acceleration aboveSLAM_ACCEL_DEADBAND;monado-slam-prediction.patch); poses over 500 ms old are untracked.
Verified results¶
On the headset on Valve's kernel, lying still unless stated otherwise.
| Check | Result |
|---|---|
| PICO OS's tracker in Valve's session, still on a table, 60 s | 61,391 poses, none lost, within 0.7 mm and 0.04°; 25 sets and 1,024 IMU samples per second, none skipped; pico4-slamd 71% of a core, vrserver 116% (Basalt 346–388%); hottest zone 55.8 °C (Basalt 75.8 °C) |
| PICO OS's tracker worn, untethered: a closed walk back to the start spot | 12.14 m in 58 s; back within 1.8 cm; no pose lost; largest step between poses 0.7 mm; turns to 86°/s, 0.7 m/s |
| PICO OS's tracker: slid along a table and back, twice | 0.512 m and 0.495 m; back within 0.4 and 0.8 cm; no pose lost |
| PICO OS's tracker worn in Valve's session (user) | "feels and looks just like stock"; turns up to 458°/s without a lost pose |
| PICO OS's tracker turned and lifted by hand, 72 s | angular rate equals the raw gyro (ratio 1.000), velocity the positions' (1.001); extrapolated 45 ms, within 0.07° and 0.3 mm (median) of the later pose |
libSlam's pose against the gyro, 30 s |
at a constant rate about 3.5 ms behind its stamp; newest pose stamped 7.9–9.0 ms in the future |
| IMU temperature to the tracker | ICM-42688 at 44.1–44.3 °C with the SoC at 60–61 °C; still within 0.8 mm for 60 s |
| Basalt (deprecated) | on a table slid 0.50 m and back within 1.5–1.8 cm; worn steps back within 3.4–4.4 cm; pose latency worn 112 ms median; seven worn sessions within 0.55–1.51 m of the start, runaways held and reset; 1.6–4.8 m drift in 30 s with the lower cameras 15 cm from a surface |
| Rooms | a drawn play area comes back after a reboot where it was drawn and its boundary shows near its edge; it stays after tracker restarts relocalising at any turn (worn at −3° and 165°) and after SteamVR restarts; a tracker crashed with SIGSEGV is back in the same room within 13 s; a playspace setup in a known room committed the detected floor to the millimetre |