diff --git a/.omo/plans/webcam-kinect-emulator.md b/.omo/plans/webcam-kinect-emulator.md index 842989d..ce1968b 100644 --- a/.omo/plans/webcam-kinect-emulator.md +++ b/.omo/plans/webcam-kinect-emulator.md @@ -317,17 +317,25 @@ Your next move: run the default-on high-accuracy review (in progress), then exec Closes: fidelity defect found in todo 10 integration. Recommended task executor category: deep-low +- [x] 22. Add test_robustness.py to conftest ignore (F3 regression fixed; root pytest 72 passed no collection error) + Recommended task executor category: quick +- [x] 23. Correct calibration doc overclaim (gate NOTE; docs/calibration.md now states not-yet-wired + Z0=2.5 default) + Recommended task executor category: writing +- [x] 24. Make flaky player-lost robustness test deterministic (drives state seam directly; 20/20 loop + full suite 88) + Recommended task executor category: deep-low + ## Final verification wave > Runs in parallel after ALL todos. ALL must APPROVE. Surface results and wait for the user's explicit okay before declaring complete. -- [ ] F1. Plan compliance audit - every todo delivered as specified; scope boundaries (Must NOT) respected; spike findings actually drove the device-vs-fallback decisions. +- [x] F1. Plan compliance audit - every todo delivered as specified; scope boundaries (Must NOT) respected; spike findings actually drove the device-vs-fallback decisions. Recommended task executor category: unspecified-high -- [ ] F2. Code quality review - clean-room discipline (no GPLv3 vendored source), frozen contract intact (static_asserts), no fixed sleeps/blind retries, pure-math modules test-covered. +- [x] F2. Code quality review - clean-room discipline (no GPLv3 vendored source), frozen contract intact (static_asserts), no fixed sleeps/blind retries, pure-math modules test-covered. Recommended task executor category: unspecified-high -- [ ] F3. Real QA (Linux, agent-run) - the full recorded-video -> virtual Kinect -> real OpenNI2 chain yields correct depth/player-index enumeration (and a tracked skeleton IF NiTE2 is user-supplied); record/replay reproduces; robustness faults handled. The authoritative skeleton/gameplay proof is F5 (Windows). +- [x] F3. Real QA (Linux, agent-run) - the full recorded-video -> virtual Kinect -> real OpenNI2 chain yields correct depth/player-index enumeration (and a tracked skeleton IF NiTE2 is user-supplied); record/replay reproduces; robustness faults handled. The authoritative skeleton/gameplay proof is F5 (Windows). Recommended task executor category: deep-low -- [ ] F4. Ideal-state fidelity - delivered behavior vs every IS row 1:1; any shortfall becomes new `- [ ] N.` rows, never a note. +- [x] F4. Ideal-state fidelity - delivered behavior vs every IS row 1:1; any shortfall becomes new `- [ ] N.` rows, never a note. Recommended task executor category: unspecified-high -- [ ] F5. DanceEvolution playability proof (Windows, human-assisted) - DEA launches via the webcam virtual Kinect, shows the player, tracks moves, and scores directionally-correctly, captured as a gameplay recording; mirror-bit + z-sign checks pass. +- [~] F5. DanceEvolution playability proof + BLOCKED: requires the user's Windows box + DEA + webcam + a person dancing. Both Windows paths are built (shim Kinect10.dll export-verified x86+x64; device-level runbook). The synthetic-depth skeletonization KILL-GATE on the real MS NUI runtime is UNPROVEN here (no Windows/NiTE2). This is the one acceptance step that needs your Windows machine. (Windows, human-assisted) - DEA launches via the webcam virtual Kinect, shows the player, tracks moves, and scores directionally-correctly, captured as a gameplay recording; mirror-bit + z-sign checks pass. Recommended task executor category: deep-high ## Commit strategy diff --git a/conftest.py b/conftest.py index 2c55ada..17973a0 100644 --- a/conftest.py +++ b/conftest.py @@ -1,13 +1,14 @@ """Root pytest config (plan follow-up todo 19: CI test-path split). -tests/test_tracker.py imports numpy/cv2/mediapipe, which live only in -tracker/.venv, not the root .venv used for the C-contract mirror tests -(test_contract_py.py, test_record_replay.py, test_smoke.py). Running bare -pytest from the repo root with the root venv must not collection-error on -that import, so skip collecting test_tracker.py whenever the tracker's CV -stack isn't importable. Under tracker/.venv the imports succeed and the full -test set (including test_tracker.py) is collected and run normally -- see -.github/workflows/ci.yml for the two separate CI steps. +tests/test_tracker.py and tests/test_robustness.py import numpy/cv2/mediapipe, +which live only in tracker/.venv, not the root .venv used for the C-contract +mirror tests (test_contract_py.py, test_record_replay.py, test_smoke.py). +Running bare pytest from the repo root with the root venv must not +collection-error on those imports, so skip collecting any tracker-dependent +test module whenever the tracker's CV stack isn't importable. Under +tracker/.venv the imports succeed and the full test set (including those +two modules) is collected and run normally -- see .github/workflows/ci.yml +for the two separate CI steps. """ try: @@ -17,4 +18,4 @@ try: collect_ignore = [] except ImportError: - collect_ignore = ["tests/test_tracker.py"] + collect_ignore = ["tests/test_tracker.py", "tests/test_robustness.py"] diff --git a/docs/calibration.md b/docs/calibration.md index a11221e..012dbe2 100644 --- a/docs/calibration.md +++ b/docs/calibration.md @@ -2,8 +2,16 @@ The virtual Kinect needs a one-time calibration so the player-space scale, the depth placement, and the mirror orientation match your room and camera mount. The logic lives in -`core/calibration/` (`calibration.h` / `calibration.cpp`) and is reused by every surface (the -OpenNI2 driver, the USB emitter, and the Windows shim), so you calibrate once and all paths agree. +`core/calibration/` (`calibration.h` / `calibration.cpp`), which computes, persists, and +reload-tests a `CalibrationConfig`. + +> **Current limitation: not yet wired into runtime.** `core/calibration/` produces and reloads a +> config file, and that round-trip is unit-tested, but no runtime surface reads it back yet. +> Today the tracker places depth using a hard-coded default origin, `DEFAULT_Z0_METERS = 2.5` +> (`tracker/joint_mapping.py`), regardless of what you calibrate. Running the steps below exercises +> and validates the calibration math and writes a real config file, but it does not yet change what +> the running tracker, OpenNI2 driver, USB emitter, or Windows shim do at runtime. Wiring the saved +> config into those startup paths is a known pending step. Calibration is two short poses: a **mirror-confirm** (raise one arm) and a **T-pose** (arms out). Both are read from the live tracker's pose output; no extra tool is needed beyond the running @@ -53,14 +61,14 @@ rather than writing a bad config. ## Step 3: save and reuse `save_config()` writes the calibration to a plain-text key/value file; `load_config()` reads it -back. Save it once and every surface loads the same file: +back, and this save/reload round-trip is covered by tests. **No runtime surface loads this file +yet** - the tracker, the OpenNI2 SynthKinect driver, the USB emitter (`core/protocol`), and the +`Kinect10.dll` shim do not call `load_config()` on startup today; the tracker instead uses the +hard-coded `DEFAULT_Z0_METERS = 2.5` for every session. Once that wiring lands, all of those +surfaces are expected to consume the same saved file so you calibrate once and every path agrees. -- the OpenNI2 SynthKinect driver (Linux), -- the USB emitter (`core/protocol`, both OSes), -- the `Kinect10.dll` shim (Windows). - -Recalibrate when you move the camera, change your playing distance, or switch rooms. The mirror -step is worth repeating any time left/right feels wrong in a game. +Recalibrate when you move the camera, change your playing distance, or switch rooms (once wired +into runtime, below). The mirror step is worth repeating any time left/right feels wrong in a game. ## Tips diff --git a/tests/test_robustness.py b/tests/test_robustness.py index a517b43..38e2788 100644 --- a/tests/test_robustness.py +++ b/tests/test_robustness.py @@ -123,18 +123,45 @@ def test_subject_exits_then_returns_holds_then_recovers(publisher): def test_player_lost_hold_eventually_falls_through_to_no_body(publisher): """If the subject stays gone longer than the hold window, the tracker must - fall through to a genuine no-body frame (never hold forever).""" + fall through to a genuine no-body frame (never hold forever). + + Drives `Tracker._resolve_publish_frame` directly (the same deterministic + seam `test_subject_exits_then_returns_holds_then_recovers` above uses) + instead of racing `tracker.run()`'s background inference thread against + its own wall-clock-paced publish loop: in that threaded form, whether the + hold has finished counting down to a no-body frame by the time the loop's + tick/time budget runs out depends on how far the background thread got + scheduling real time, which is exactly the timing-luck race test + discipline forbids. Advancing the hold counter by an exact tick count + removes the race. + """ present = make_fake_pose(frame_index=0, image_width=80, image_height=60) - script = [present] + [None] * 40 - source = FakeFrameSource(n_frames=len(script), width=80, height=60) - provider = ScriptedPoseProvider(script) - tracker = Tracker(source, provider, publisher, target_fps=200.0, player_lost_hold_frames=3) + source = FakeFrameSource(n_frames=1, width=80, height=60) + provider = ScriptedPoseProvider([present]) + hold_frames = 3 + tracker = Tracker(source, provider, publisher, target_fps=200.0, player_lost_hold_frames=hold_frames) try: - tracker.run(max_frames=len(script) + 5, max_seconds=5.0) - frame = publisher.read_latest_frame() - assert frame.skeleton.skeleton_tracking_id == 0 + tracker._latest_pose = present + tracker._update_count += 1 + pose, _ = tracker._resolve_publish_frame() + assert pose is present + + for _ in range(hold_frames): # still within the hold window + tracker._latest_pose = None + tracker._update_count += 1 + pose, _ = tracker._resolve_publish_frame() + assert pose is present, "must keep holding while the hold window has not elapsed" + + tracker._latest_pose = None # one tick past the hold window: must fall through + tracker._update_count += 1 + pose, frame = tracker._resolve_publish_frame() + assert pose is None, "hold window exceeded must fall through to no-body, never hold forever" + + publisher.publish(pose, frame) + published_frame = publisher.read_latest_frame() + assert published_frame.skeleton.skeleton_tracking_id == 0 for j in range(c.JOINT_COUNT): - joint = frame.skeleton.joints[j] + joint = published_frame.skeleton.joints[j] assert joint.tracking_state == c.JointTrackingState.NOT_TRACKED finally: source.release()