yxma commited on
Commit
7ffaae4
·
verified ·
1 Parent(s): 0bfaecc

publish the probe README as source

Browse files
Files changed (1) hide show
  1. docs/probe_testset_README.md +298 -0
docs/probe_testset_README.md ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # React probe set — controlled actions for measuring ACTION FOLLOWING
2
+
3
+ > **This is one of two evaluation sets, and they answer different questions.**
4
+ >
5
+ > | | question | data |
6
+ > |---|---|---|
7
+ > | **held-out split** | can the model predict what actually happened? | real frames, real actions, real futures — `ReactVideoDataset(..., split="test")` |
8
+ > | **probe set** (this) | does the model *follow the action it is given*? | commanded actions nobody performed; ground truth is geometric |
9
+ >
10
+ > The held-out split scores prediction against recorded frames. It cannot
11
+ > isolate action-following, because the action in a recording is whatever the
12
+ > human happened to do. These probes command motions that were never performed,
13
+ > one axis at a time, so a failure names a direction.
14
+
15
+ 72 commanded action sequences over 6 start frames, for scoring a tactile world
16
+ model's rollouts against ground truth that is **geometric, not photometric**.
17
+
18
+ Format `react-probe-testset/1.0`. Task: `motherboard`.
19
+
20
+ ---
21
+
22
+ ## Why this exists
23
+
24
+ A world model rolled out from a real episode can be scored against the frames
25
+ that were actually recorded. That measures interpolation of behaviour the model
26
+ has seen. It does not tell you whether the model has learned *how a commanded
27
+ motion moves the sensor* — because the action in a recording is whatever the
28
+ human happened to do.
29
+
30
+ These probes are **axis-aligned, controlled actions**: six pure translations
31
+ along ±x, ±y, ±z and six pure rotations about the same axes, from each start
32
+ frame. Nobody performed them, so **there is no ground-truth future image**.
33
+
34
+ What *is* ground truth is where the sensor **would be** if the action were
35
+ executed exactly — a pose sequence, and its projection into each camera. A
36
+ rollout is judged by comparing the sensor it draws against that projection.
37
+ Axis-aligned on purpose: when a probe fails you can say *which direction*
38
+ failed. A random direction gives you a number and no handle.
39
+
40
+ ![overlay example](overlay_example.jpg)
41
+
42
+ *Yellow: commanded ground truth. Red: a deliberately wrong rollout, offset
43
+ 25 mm in world x — it reads 18–19 px, three times the ~6 px noise floor.
44
+ Dimmed: the hand that must stay still. `overlays/` holds one such still for
45
+ every probe.*
46
+
47
+ ## What a probe is
48
+
49
+ | | |
50
+ |---|---|
51
+ | Probes | **72** — 12 per start frame (6 translations, 6 rotations) |
52
+ | Start frames | **6**, each 4 consecutive context frames × **5 streams** (3 cameras + 2 tactile) |
53
+ | Translation amplitude | **0.113 – 0.391 m** |
54
+ | Rotation amplitude | **18.6 – 88.7°** |
55
+ | Horizon | **1.50 – 4.27 s** at 30 Hz |
56
+ | Speed | dataset percentile **p33 – p77** |
57
+ | Moving hand | 36 left / 36 right; one hand moves, the other holds |
58
+ | Closest approach between gels | **0.131 m** (rule: ≥ 0.12 m) |
59
+
60
+ **One hand moves per probe.** The other holds its pose for the whole horizon,
61
+ so a rollout must keep it still — a model that drifts both hands is visibly
62
+ wrong even when the moving one is right.
63
+
64
+ **Rotations pivot on the gel**, not on the OptiTrack marker cluster. The marker
65
+ cluster sits 65.7 mm from the gel, so rotating about it would swing the contact
66
+ point through an arc of up to 53 mm and a "pure rotation" would translate
67
+ across the screen.
68
+
69
+ ## Layout
70
+
71
+ ```
72
+ manifest.json format, conventions, error budget, residuals
73
+ calibration/ T_mocap_to_cam_{left,middle,right}.json
74
+ T_gel_to_rigid_{left,right}.json
75
+ probes/runN/
76
+ meta.json episode, context rows, moving/held hand
77
+ context/ctx{0..3}_view_{left,middle,right}.jpg what a model conditions on
78
+ context/ctx{0..3}_tactile_{left,right}.jpg
79
+ {trans,rot}{±x,±y,±z}.npz one probe
80
+ overlays/runN_<probe>.jpg ground truth drawn on the last context frame
81
+ overlay_example.jpg the figure above
82
+ ```
83
+
84
+ Each `.npz` holds:
85
+
86
+ | key | shape | meaning |
87
+ |---|---|---|
88
+ | `poses` | (T+1, 7) | commanded ground-truth pose of the moving sensor |
89
+ | `held_pose` | (7,) | the stationary hand, constant over the horizon |
90
+ | `context_poses_moving` / `_held` | (4, 7) | poses at the context frames |
91
+ | `gel_pos_m` | (T+1, 3) | the gel centre — what the action is measured at |
92
+ | `delta_gel_pos_m` | (T, 3) | **the action**: per-step translation, world axes, at the gel |
93
+ | `delta_gel_rotvec_rad` | (T, 3) | **the action**: per-step rotation, world axes |
94
+ | `action_scalar` | (T,) | the same action as one number: signed step along `action_axis` |
95
+ | `action_axis` / `action_sign` | scalar | 0/1/2 for x/y/z, and ±1 |
96
+ | `delta_rigid_pos_m` / `delta_rigid_rotvec_rad` | (T, 3) | the marker cluster's motion instead |
97
+ | `gt_px_{left,middle,right}` | (T+1, 2) | ground-truth gel-centre pixels |
98
+ | `context_{tactile,force}_*` | (4,) | the numeric channels **at the context rows** — intensity, area, is_new, force, penetration |
99
+
100
+ Poses are `[x, y, z, qx, qy, qz, qw]`, position in **metres**, quaternion in
101
+ **xyzw** order (`scipy.spatial.transform.Rotation.from_quat`), in the OptiTrack
102
+ world frame with **2026-05-10** as reference.
103
+
104
+ ### One action, one direction — and where you have to measure it
105
+
106
+ Every probe moves along **exactly one axis**: a translation probe has zero
107
+ rotation, a rotation probe has zero translation, and the off-axis components are
108
+ zero to machine precision. All of that is true **at the gel**, and false at the
109
+ marker cluster.
110
+
111
+ The pose 7-vec is the OptiTrack marker cluster's, and rotations pivot on the gel
112
+ 65.7 mm away — so in rigid-body coordinates a "pure rotation" carries up to
113
+ **91 mm** of translation. A model fed `delta_rigid_*` for `rot+x` reads
114
+ "translate 91 mm *and* rotate 79°" for something labelled a pure rotation. Hence
115
+ `delta_gel_*` is the primary action; `delta_rigid_*` ships alongside for a model
116
+ that predicts the marker-cluster pose, under a name that cannot be confused.
117
+
118
+ Rotation deltas are **world-frame**, i.e. pre-multiplied: `dq = q[i+1] · q[i]⁻¹`,
119
+ integrate as `q[i+1] = dq · q[i]`. The probes rotate about world axes, so the
120
+ world-frame increment lies exactly along the named axis; the body-frame
121
+ increment `q[i]⁻¹ · q[i+1]` is the same rotation seen from the moving hand and
122
+ sits 7.1e-3 rad off it.
123
+
124
+ Both deltas integrate back to their own trajectory exactly — the rigid one to
125
+ `poses`, the gel one to `gel_pos_m` — asserted to 1e-9 m and 1e-6 deg.
126
+
127
+ ## Usage
128
+
129
+ ```python
130
+ import json, numpy as np, cv2
131
+ from react_toolbox.calibration import load_calibration
132
+ from react_toolbox.probe_eval import overlay_gt, rollout_error
133
+
134
+ root = "react_probe_testset"
135
+ cal = load_calibration(root) # the calibration IN the package
136
+ run = json.load(open(f"{root}/probes/run0/meta.json"))
137
+ d = np.load(f"{root}/probes/run0/trans+x.npz")
138
+
139
+ gel = cal[f"gel_{run['moving_side']}"]
140
+ cam = cal["cams"]["middle"]
141
+
142
+ # --- the model input: 4 context frames, and the action
143
+ ctx = [cv2.imread(f"{root}/probes/run0/context/ctx{i}_view_middle.jpg")[:, :, ::-1]
144
+ for i in range(4)]
145
+ tac_l = [cv2.imread(f"{root}/probes/run0/context/ctx{i}_tactile_left.jpg")[:, :, ::-1]
146
+ for i in range(4)] # and tactile_right
147
+ action = np.concatenate([d["delta_gel_pos_m"],
148
+ d["delta_gel_rotvec_rad"]], axis=1) # (T, 6), at the gel
149
+ # or, since each probe is one-directional, the same thing as one number:
150
+ # d["action_scalar"], along axis "xyz"[int(d["action_axis"])]
151
+
152
+ pred = my_world_model.rollout(ctx, action) # -> (T+1, 7) poses
153
+
154
+ # --- score it
155
+ err = rollout_error(pred, d["poses"], gel, cam)
156
+ print(err["pos_mm_final"], err["rot_deg_final"], err["px_final"])
157
+
158
+ # --- and look at it
159
+ vis = overlay_gt(ctx[-1], d["poses"], gel, cam,
160
+ held_pose7=d["held_pose"], held_gel_mm=cal[f"gel_{run['held_side']}"])
161
+ vis = overlay_gt(vis, pred, gel, cam, color=(255, 90, 90)) # your rollout, in red
162
+ ```
163
+
164
+ ### The overlay
165
+
166
+ `overlay_gt` draws, on a context frame:
167
+
168
+ * the **held hand**, dimmed, with a stem back to its marker cluster
169
+ * the **start** and **end** sensor frames as perspective triads — a dot cannot
170
+ show a rotation probe, where the gel centre does not move at all
171
+ * the commanded **path** as a polyline, start a white dot, end a ring
172
+
173
+ Triads go down first and the path markers on top; the other order puts the start
174
+ triad's centre dot exactly over the start marker and hides it.
175
+
176
+ All projection goes through `calibration.project_gel_to_pixel`, the same
177
+ function the dataset previews and the release fingerprint use, so an overlay you
178
+ draw cannot disagree with the stored `gt_px_*`.
179
+
180
+ ### What "correct" means — the overlay's error bar
181
+
182
+ Projected ground truth is not exact:
183
+
184
+ | source | at 800 mm depth |
185
+ |---|---|
186
+ | camera reprojection rmse (left / middle / right: 4.7 / 5.3 / 7.5 mm) | **3.6 / 4.0 / 5.7 px** |
187
+ | gel centre in the rigid frame (≤ ~5 mm) | **≈ 3.8 px** |
188
+
189
+ **Agreement within about 6 px is at the noise floor** and should be read as
190
+ correct. `rollout_error` reports millimetres *and* pixels because they differ by
191
+ depth, and neither substitutes for the other.
192
+
193
+ ## How the probes were generated
194
+
195
+ 1. **Sample a start frame.** A run of 4 consecutive rows with both sensors
196
+ tracked, from a session whose world frame is pinned (below). Start frames and
197
+ actions are sampled **independently**: a frame is accepted or rejected
198
+ against the actions, never adjusted to fit them — nudging a trajectory to
199
+ keep it on screen would make two probes named `+x` mean different things.
200
+
201
+ 2. **Generate 12 actions** from the moving hand's start pose: six translations
202
+ along the signed world axes, six rotations about them. Rotations pre-multiply
203
+ in the world frame ("turn the hand this way in the room"), which is what a
204
+ viewer can judge from a camera image.
205
+
206
+ 3. **Pace them against the dataset.** Speed is drawn uniformly in *percentile*
207
+ of the measured per-step distribution (p45–p85, capped by the horizon), not
208
+ uniformly in mm/step — the distribution spans a decade between p25 and p90,
209
+ so a uniform draw in value would put most probes in a tail the data barely
210
+ occupies. Every probe records the percentile it actually lands on.
211
+
212
+ The 1.5 s horizon caps speed at `amplitude / 45`, which bites at small
213
+ amplitudes: 0.1 m over 45 steps is p44, 18° is p32. Those probes are the
214
+ slowest in the set and cannot be faster without breaking the horizon.
215
+
216
+ 4. **Reject, never adjust.** A probe is discarded, and the start frame with it,
217
+ if the two gel centres come within 0.12 m — hands do not pass through each
218
+ other, and a probe that says they do tests whether the model will hallucinate
219
+ rather than whether it can predict. The projected path must also stay
220
+ **40 px** clear of the image border: in frame is not enough, because a
221
+ rollout that overshoots a path ending 15 px from the edge leaves the image
222
+ and cannot be scored at all.
223
+
224
+ ### Start frames are HELD OUT
225
+
226
+ Start frames are drawn only from the held-out intervals of `splits.json`.
227
+ Without that the context images would be *training* frames: the action is novel
228
+ either way, but the model would already have seen the picture it starts from,
229
+ and nothing would say so.
230
+
231
+ `meta.json` records `context_rows` — **release-parquet row indices**, not raw
232
+ HDF5 frames and not seconds. Row `r` is camera frame `trim + r`, where
233
+ `trim = source_h5_frame[0]`; `source_h5_frames` in the same file gives the
234
+ mapping explicitly so you never have to apply it yourself. The four rows are
235
+ consecutive, one camera frame apart.
236
+
237
+ **Context is five streams, not three.** The first export shipped only the
238
+ camera views, which made the package unusable for the one thing it exists to
239
+ test. Each start frame now ships `view_{left,middle,right}` and
240
+ `tactile_{left,right}`, plus the numeric channels at those exact rows.
241
+
242
+ The images come from the **published** `videos/` tree, not the unpublished raw
243
+ HDF5, so the package can be rebuilt from what the dataset ships. Video frame
244
+ `r` is parquet row `r` for every stream — measured against the raw capture at
245
+ 1.88 mean pixel difference where two adjacent raw frames differ by 4.89. The
246
+ tactile videos are **already row-aligned**: cross-correlating a contact
247
+ measure from the video against the parquet's `tactile_left_intensity` peaks at
248
+ lag 0 with r = 0.980, falling off symmetrically. The +15-frame acquisition lag
249
+ was applied at encode time, so nothing is re-applied here.
250
+
251
+ The release holds out **intervals from inside episodes**, not whole episodes.
252
+ There are 32 motherboard episodes; spending them on episode-level held-out data
253
+ buys independence a short-horizon world model does not need — what it must
254
+ generalise over is dynamics within a scene, not scenes. Measured, with a
255
+ 64-frame training window: **test 12.1%, guard 9.4%, train 78.5%**, over 147
256
+ intervals plus 2 wholly-held-out episodes.
257
+
258
+ The **guard** is the part that leaks if you get it wrong. A training window
259
+ starting shortly before a held-out interval still contains its frames, so
260
+ starts in `[a-(S-1), b]` must be rejected, not just `[a, b]`. `splits.json`
261
+ records `guard_frames = max_train_window - 1`, and the loader **refuses** a
262
+ longer window rather than leaking — a leak here leaves no trace in any metric
263
+ until the numbers are suspiciously good. Without the guard, 1827 windows leak
264
+ in the first six episodes alone.
265
+
266
+ ### Sessions
267
+
268
+ All three sessions are **eligible**; which ones a given draw contains is
269
+ chance. Run `build_probe_testset.py` with a different `--seed` and the mix
270
+ changes.
271
+
272
+ **2026-05-19** had its OptiTrack world redefined mid-collection. The release
273
+ applies the translation-only correction (230, 0, 175) mm, and the residual yaw
274
+ about the table normal is **unmeasured** — attempts scatter ±2.3°, about 16 px
275
+ at the workspace. It is included with that stated in `manifest.json` under
276
+ `world_residual` and `session_note`, rather than dropped: a bounded, declared
277
+ error is not a reason to discard a fifth of the sessions. An earlier build did
278
+ drop it, and an earlier version of the web page went on saying so after the
279
+ decision was reversed — the pages now generate that sentence from the manifest.
280
+
281
+ ## Reproducing
282
+
283
+ ```
284
+ python scripts/build_splits.py # writes splits.json
285
+ python scripts/build_probe_testset.py --runs 6 --seed 0
286
+ python scripts/test_splits.py
287
+ python scripts/test_probe_testset.py
288
+ ```
289
+
290
+ `test_splits.py` enumerates every admissible training window and asserts none
291
+ touches a held-out frame, and that removing the guard *does* leak — a guard
292
+ nobody can show to be load-bearing is decoration.
293
+
294
+ `test_probe_testset.py` asserts the package is self-contained, that the stored ground-truth
295
+ pixels recompute from the calibration **inside the package**, that the deltas
296
+ integrate back to the poses, that the ground truth keeps its scoring margin, and
297
+ that the scorer reads zero on the ground truth and exactly 10 mm on an injected
298
+ 10 mm error.