Skip to content

Split the scanner into Core and Quest with seams and a replay backend; use the new vocabulary and tracker - #34

Draft
mrhegemon wants to merge 4 commits into
mainfrom
feat/unity-suite-seams
Draft

mrhegemon wants to merge 4 commits into
mainfrom
feat/unity-suite-seams

Conversation

@mrhegemon

Copy link
Copy Markdown
Member

Draft until a capture has been checked on a Quest: everything below is covered by tests and a build, none of it has run on a headset.

What changes

Three commits, in the order they build.

  1. com.companion.spatial (new, Packages/): an engine-free package (no UnityEngine, no clock or randomness) with 600 EditMode tests. A tag vocabulary (raw detector text to a canonical tag and one of Meta's 16 labels), a track table (detections matched across captures, found/updated/lost/revived/retired) and the scan extras v2 reader, writer, merge and schema. How v2 differs from the web Scan contract is in Documentation~/CONTRACT.md.
  2. The scanner: CompanionScan is now CompanionScan.Core with no Oculus.* or Meta.* reference, and CompanionScan.Quest holds MetaSceneCollector, XRControllerInput, ControllerMenuBuilder and the Horizon Store check. Scripts keep their GUIDs, so scenes are untouched.
    • Seams in Core: ICameraSource (a frame with the pose, intrinsics and time of capture), ISceneSource, IRaycastSource (ViewportRaycaster.AddSource) and IInputSource (ControllerInput routes the buttons, XRControllerInput is the OVRInput backend).
    • CompanionScan.Replay plays a recording or a synthetic box room back. 20 PlayMode tests run the whole pipeline from it against a CV server on a loopback port, with no headset, and check pin positions against geometry worked out by hand.
    • SemanticLabelMapper is the vocabulary, and the pipeline's inline tracker is the track table.
  3. Docs: the assemblies and seams, and docs/device-testing.md.

Behaviour that changes on purpose

The Currently... characterization tests for these are changed and renamed.

  • Labels: 16 of the 26 default-prompt classes no longer give OTHER by accident; INVISIBLE_WALL_FACE and GLOBAL_MESH can be produced.
  • Tracking: an object not seen for a while is lost, not forgotten after 2.5 s, so a second sweep of the room does not pin it again.
  • Export merge: a pin of the same object (Space Setup anchor, or capture session and track) and a snapshot with the same id replace their earlier entries instead of being listed twice; pins is never null; a glTF that cannot be read is ignored with a warning instead of failing every later export.
  • Floor plan: ear-clipping triangulation, so the mesh faces up (it faced down) and a concave boundary is covered exactly; pins on one line or on fewer than three places give no polygon.
  • Intrinsics: the identity matrix and infinite focal lengths are no intrinsics, and the desktop provider and the no-provider fallback return the zero matrix. A null frame raycast is no hit.
  • The snapshot frustum comes from the capture's pose and intrinsics; the snapshot store says when it drops a snapshot; a normalized box whose far corner is a hair past 1 stays normalized.
  • ObjectMapper and MappedObjectDatabase are removed: no scene, prefab or caller.

Still open

  • The exporter still writes extras v1; the package's v2 waits for a decision on the Scan server.
  • The pin manager averages a track's position again after the tracker has smoothed it (existing tests pin this).
  • A floor plan from pins is still a convex hull, so an L-shaped room's notch is filled.
  • A pixel box (0, 0, 1, 1) is still read as the whole image.

How it was checked

  • EditMode: 1046 of 1046 (445 scanner tests, 600 package tests).
  • PlayMode: 94 tests, 69 pass, 24 skip (they need a CV server or the Meta simulator) and 1 fails in batch mode, as before: XrSceneScreenshotTests.QaXrScene_CapturesControllersAndAnchors waits for WaitForEndOfFrame, which batch mode does not raise.
  • A Quest debug APK builds from this branch with QuestBuilder.Build (under 4 minutes with a warm cache): same package name, target API 34, the same 7 permissions and a v2 signature as before.

Not checked

  • Nothing ran on a headset, phone or tablet.
  • The package's own tests ran in the Mono editor only; IL2CPP compiled it in the Quest build, but nothing exercised it there.
  • The cv-server's own pytest suite was not run.

Packages/manifest.json is unchanged: the package is embedded. Unity adds its entry to packages-lock.json on first open.

🤖 Generated with Claude Code

mrhegemon and others added 4 commits November 25, 2026 15:20
…an extras v2

An engine-free package (no UnityEngine references, double precision, no clock, randomness or
static state), written test-first with 600 EditMode tests. It holds the semantic map's logic
so the scanner, and later other apps, share one copy:

- TagVocabulary: one vocabulary. Raw detector text (case, articles, plurals, separators,
  synonyms) becomes a canonical tag and one of Meta's 16 labels. "a couch", "tables", "TV
  screen", "Sofa Bed" and "door  frame" find their label; a class Meta has no label for, such
  as a chair, is OTHER but is still a tag, so tracking can tell a cup from a chair.
- TrackTable: matches detections across captures by tag and distance, nearest first, two
  detections of one capture never one object. Position and normal are smoothed, confidence is
  a noisy-OR, and a track that is not seen for a while is lost (Found, Updated, Lost, Revived,
  Retired events), so a later sweep of the room does not pin everything twice.
- Extras v2: a model, a reader that takes both v1 (the scanner's golden file) and v2, a writer
  with stable key order, a merge by object id, and a hand-written JSON schema. Where it differs
  from the web Scan contract is listed in Documentation~/CONTRACT.md.

Nothing in the scanner uses it yet; the next commit does.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…; use the new vocabulary and tracker

Assemblies and seams
- CompanionScan is now CompanionScan.Core and references no Oculus.* or Meta.* assembly
  (CoreAssemblyTests checks the references and the asmdef). The Meta-bound classes moved to
  CompanionScan.Quest: MetaSceneCollector, XRControllerInput, ControllerMenuBuilder and the
  Horizon Store check. Scripts keep their GUIDs, so scenes are untouched. The pipeline's and the
  exporter's scene field keeps its serialized name (metaSceneCollector), is now typed
  MonoBehaviour and is used through ISceneSource.
- Seams in Core, one per capability a platform provides: ICameraSource (a frame with the pose,
  intrinsics and time of capture; a plain ICameraProvider is adapted), ISceneSource,
  IRaycastSource (ViewportRaycaster.AddSource asks them first) and IInputSource (ControllerInput
  routes the buttons to the menu and panels; XRControllerInput is the OVRInput backend).
- CompanionScan.Replay plays a recording back: camera frames with their poses and intrinsics, a
  recorded room for raycasts and a Space Setup snapshot, plus a synthetic box room that needs no
  image files. 20 PlayMode tests run the whole pipeline from it against a CV server on a
  loopback port, with no headset, and check where the pins land against geometry worked out by
  hand. Routing of the controller buttons is now tested too.

Using the Companion.Spatial package
- SemanticLabelMapper is the tag vocabulary: 16 of the 26 default-prompt classes no longer give
  OTHER by accident, and INVISIBLE_WALL_FACE and GLOBAL_MESH can be produced.
- The pipeline's inline tracker is the TrackTable. An object that is not seen for a while is lost,
  not forgotten, so a second sweep of the room does not pin it again.

Fixes to what the characterization tests had pinned as doubtful (those tests are changed on
purpose and renamed)
- Export merge: a pin of the same object (Space Setup anchor, or capture session and track) and
  a snapshot with the same id replace their earlier entries, so saving again does not list
  everything twice; the new time, bounds and scene are kept; pins are never null; a glTF that
  cannot be read is ignored with a warning instead of failing every later export.
- Floor plan: ear-clipping triangulation, so the mesh faces up (it faced down) and a concave
  boundary is covered exactly; pins on one line or on fewer than three places give no polygon.
- Intrinsics: the identity matrix and infinite focal lengths are no intrinsics, and the desktop
  provider and the no-provider fallback return the zero matrix. A null frame raycast is no hit.
- The snapshot frustum comes from the capture's pose and intrinsics, and the store says when it
  drops a snapshot. A normalized box whose far corner is a hair past 1 stays normalized.
- Removed ObjectMapper and MappedObjectDatabase: no scene, prefab or caller.

Checked: 1046 EditMode tests (445 of the scanner's, 600 of the package's) and 94 PlayMode tests
(69 pass, 24 skip for lack of a server or simulator, 1 fails in batch mode because
WaitForEndOfFrame does not run, as before). The Quest debug APK builds from this tree with the
same package name, target API 34 and permissions. Nothing was run on a headset.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- docs/quest-capture-gltf.md: the Core, Quest and Replay assemblies, the four seams and the replay backend; the
  export merge, the floor mesh and the tag vocabulary.
- docs/device-testing.md (new): which devices can run the scanner today, how to install and check a Quest 3 build,
  what to bring back, and what each other target (Android tablet, iPhone and iPad, XREAL Aura, PICO 4 Pro) is
  missing. Nothing in it has been run on a device.
- docs/plan.md, docs/scan-export-pipeline.md, docs/spatial-capture-architecture.md: moved classes, the tracker.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…evices

Companion Scan has a page per device and pre-releases for Quest and for PICO and XREAL Aura. On an Aura puck its
WebView has no WebXR, so the WebXR app there cannot capture; Chrome on the puck is the path to try. None of it has
run on the other devices.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant