yxma commited on
Commit
0ffbf74
·
verified ·
1 Parent(s): 79562d2

refresh the published scripts and USAGE.md from the repo

Browse files
Files changed (2) hide show
  1. USAGE.md +79 -18
  2. scripts/test_site.py +35 -0
USAGE.md CHANGED
@@ -10,6 +10,60 @@ tour.
10
 
11
  ---
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  ## 1. Conventions, stated once
14
 
15
  | | |
@@ -24,11 +78,12 @@ tour.
24
 
25
  ### Up is +z — converted, not recorded
26
 
27
- OptiTrack records **Y-up**. This release is published **Z-up**, because
28
- robotics code overwhelmingly assumes Z-up and reading `pose[2]` as height under
29
- the recorded convention silently returns a *horizontal* coordinate: the numbers
30
- stay plausible, the plots look fine, and it surfaces only as a model that never
31
- learns which way gravity points.
 
32
 
33
  So the conversion was done once, in the data:
34
 
@@ -182,10 +237,11 @@ what it must generalise over is dynamics within a scene, not scenes.
182
  Measured with a 64-frame training window: **test 12.1 %, guard 9.4 %,
183
  train 78.5 %**, over 147 intervals plus 2 wholly-held-out episodes.
184
 
185
- A training window starting shortly **before** a held-out interval still contains
186
- its frames, so starts in `[a-(S-1), b]` must be rejected, not just `[a, b]`.
187
- `splits.json` records `guard_frames = max_train_window - 1`, and the loader
188
- **raises** on a longer window rather than leaking:
 
189
 
190
  ```
191
  ValueError: window spans 128 frames but the split has guard_frames=63 …
@@ -209,10 +265,12 @@ python scripts/build_splits.py --max-train-window 128
209
  | `split="test"` | can the model predict what actually happened? | real frames, real actions, real futures |
210
  | **probe set** | does it *follow the action it is given*? | commanded motions nobody performed; ground truth is geometric |
211
 
212
- The held-out split cannot isolate action-following, because the action in a
213
- recording is whatever the human happened to do. The probes command motions one
214
- axis at a time, so a failure names a direction. Probe start frames are drawn
215
- **only from held-out intervals**.
 
 
216
 
217
  ## 5. What was done to the data before you got it
218
 
@@ -273,11 +331,14 @@ All projection goes through `calibration.project_gel_to_pixel`, the same
273
  function the previews and the release fingerprint use, so an overlay you draw
274
  cannot disagree with a stored one.
275
 
276
- **What "correct" means.** Camera reprojection rmse is 4.7 / 5.3 / 7.5 mm for
277
- left / middle / right → **3.6 / 4.0 / 5.7 px** at 800 mm; the gel centre in the
278
- rigid frame is good to ~5 mm → ~3.8 px. **Agreement within about 6 px is at the
279
- noise floor.** `rollout_error` reports millimetres *and* pixels because they
280
- differ by depth.
 
 
 
281
 
282
  ## 7. Known problems, stated rather than hidden
283
 
 
10
 
11
  ---
12
 
13
+ ## Start here
14
+
15
+ Two bimanual tasks recorded with three cameras, two touch sensors and motion
16
+ capture. Each episode is a parquet table (one row per camera frame) plus five
17
+ videos.
18
+
19
+ ```python
20
+ from react_video_dataset import ReactVideoDataset
21
+ ds = ReactVideoDataset("data/motherboard", split="train", window_length=16)
22
+ cal = ds.calibration() # poses and cameras in the SAME convention
23
+ ```
24
+
25
+ Six things that bite, each explained below:
26
+
27
+ | | |
28
+ |---|---|
29
+ | **Up is +z** | recorded Y-up, published Z-up. Take poses and cameras from the same place, or every overlay moves by up to 165 px. §1 |
30
+ | **Quaternions are xyzw** | scalar-last, as `scipy` wants. §1 |
31
+ | **Touch updates on ~29 % of rows** | the rest repeat the previous value. Check `tactile_*_is_new` before averaging. §2 |
32
+ | **Force is a magnitude** | direction comes from the sensor's own frame, not from world "down". §2 |
33
+ | **Held-out data is intervals, not episodes** | a training window that starts just before one still sees it; the loader raises instead of leaking. §3 |
34
+ | **Frame rate is not 30 Hz everywhere** | read `timestamp`, never assume. §5 |
35
+
36
+ ## 0. Terms
37
+
38
+ Plain definitions for the words used throughout.
39
+
40
+ | term | what it means here |
41
+ |---|---|
42
+ | **motion capture / OptiTrack** | cameras that track reflective markers and report where an object is, at ~120 Hz |
43
+ | **rigid body** | a marker cluster the system treats as one object. Its local axes are fixed when the body is created, and are not a property of the hardware |
44
+ | **pose** | position + orientation: `[x, y, z, qx, qy, qz, qw]`, metres and a unit quaternion |
45
+ | **scalar-last (xyzw)** | the `w` of the quaternion comes last. `wxyz` is the other common order and silently gives wrong rotations |
46
+ | **world frame** | the shared coordinate system all poses are in — here, OptiTrack's, with the 2026-05-10 origin |
47
+ | **up axis** | which axis points away from gravity. This release: `+z` |
48
+ | **extrinsics** (`T_mocap_to_cam`) | where a camera sits in the world frame, as a 4×4 matrix |
49
+ | **intrinsics** | a camera's focal lengths and optical centre, which turn a 3-D point into a pixel |
50
+ | **GelSight Mini** | a touch sensor: a soft gel pad filmed from inside, so contact shows up as an image |
51
+ | **gel** | that soft pad. **Gel centre** is its middle, **gel normal** the direction perpendicular to its surface |
52
+ | **normal force** | how hard the gel is pressed, in newtons. A single number, no direction attached |
53
+ | **penetration** | how far the gel would be pushed in: `force / k`, with stiffness `k = 2 N/mm` |
54
+ | **virtual target** | the pose a stiffness controller would have been commanded to reach: the observed pose pushed `penetration` further along the gel normal |
55
+ | **held-out interval** | a stretch of frames inside an episode reserved for testing |
56
+ | **guard** | frames next to a held-out interval that training must also avoid, because a window starting there would contain held-out frames |
57
+ | **segment** | a stretch curated as clean; `mode="segment"` uses only these |
58
+ | **bad frame** | a frame flagged as corrupt: a sensor spike, a pose jump, a tracking dropout |
59
+ | **calibration epoch** | one camera-calibration session. Sessions recorded under different epochs need different extrinsics |
60
+ | **probe set** | synthetic single-axis motions used to ask whether a model follows a commanded action, as opposed to predicting a recording |
61
+ | **reprojection error** | how far a known 3-D point lands from where the calibration says it should, in pixels or millimetres — the noise floor for any overlay |
62
+ | **fingerprint** | a few stored pixel coordinates you can recompute from your own poses to confirm you are in the same frame as the release |
63
+ | **trim** | the offset between a published row and its frame in the original recording (`source_h5_frame`) |
64
+
65
+ ---
66
+
67
  ## 1. Conventions, stated once
68
 
69
  | | |
 
78
 
79
  ### Up is +z — converted, not recorded
80
 
81
+ OptiTrack records **Y-up**. This release is published **Z-up**, because most
82
+ robotics code assumes Z-up.
83
+
84
+ Why it matters: under Y-up, `pose[2]` is not height — it is a horizontal
85
+ coordinate. The numbers still look reasonable and the plots still look fine.
86
+ The only symptom is a model that never learns which way gravity points.
87
 
88
  So the conversion was done once, in the data:
89
 
 
237
  Measured with a 64-frame training window: **test 12.1 %, guard 9.4 %,
238
  train 78.5 %**, over 147 intervals plus 2 wholly-held-out episodes.
239
 
240
+ A window of length `S` that starts shortly **before** a held-out interval still
241
+ contains part of it. So the rejected range is `[a-(S-1), b]`, not just `[a, b]`
242
+ — that is what the guard is for. `splits.json` stores
243
+ `guard_frames = max_train_window - 1`, and the loader **raises** rather than
244
+ leak if your window is longer:
245
 
246
  ```
247
  ValueError: window spans 128 frames but the split has guard_frames=63 …
 
265
  | `split="test"` | can the model predict what actually happened? | real frames, real actions, real futures |
266
  | **probe set** | does it *follow the action it is given*? | commanded motions nobody performed; ground truth is geometric |
267
 
268
+ The held-out split cannot test action-following on its own: in a recording, the
269
+ action is whatever the person happened to do, so you cannot ask "what if it had
270
+ moved 5 mm the other way".
271
+
272
+ The probes command one axis at a time, so a failure names a direction. Their
273
+ start frames come **only from held-out intervals**.
274
 
275
  ## 5. What was done to the data before you got it
276
 
 
331
  function the previews and the release fingerprint use, so an overlay you draw
332
  cannot disagree with a stored one.
333
 
334
+ **What "correct" means.** Two error sources set the floor. Camera reprojection
335
+ rmse is 4.7 / 5.3 / 7.5 mm for left / middle / right,
336
+ which is **3.6 / 4.0 / 5.7 px** at 800 mm. The gel centre is good to ~5 mm,
337
+ another ~3.8 px.
338
+
339
+ So **agreement within about 6 px is as good as this rig can tell.** Do not read
340
+ a 3 px difference as a result. `rollout_error` gives millimetres *and* pixels,
341
+ because the same millimetre is more pixels up close.
342
 
343
  ## 7. Known problems, stated rather than hidden
344
 
scripts/test_site.py CHANGED
@@ -365,6 +365,41 @@ def main() -> int:
365
  f"{ {x: landed[x][0] for x in strayed} }; statuses {codes}")
366
 
367
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
  w = max(len(x) for _, x, _ in RESULTS)
369
  print()
370
  for ok, name, ev in RESULTS:
 
365
  f"{ {x: landed[x][0] for x in strayed} }; statuses {codes}")
366
 
367
 
368
+ # --- the force page's numbers come from the artifact, not from prose.
369
+ # This page exists to say the pressing axis is UNSETTLED, so any
370
+ # figure typed into the HTML is the first one to go stale. Every
371
+ # number rendered must be reproducible from press_axis.json.
372
+ import json as _j, re as _re, html as _h, urllib.request as _u2
373
+ from force_recovery.site2 import CACHE as _C
374
+ art = _j.loads((_C / "press_axis.json").read_text())
375
+
376
+ def _nums(o, acc):
377
+ if isinstance(o, dict):
378
+ [_nums(v, acc) for v in o.values()]
379
+ elif isinstance(o, list):
380
+ [_nums(v, acc) for v in o]
381
+ elif isinstance(o, (int, float)):
382
+ acc.add(round(float(o), 1)); acc.add(round(float(o), 2))
383
+ acc.add(round(float(o), 3)); acc.add(round(float(o) * 100, 0))
384
+ acc.add(float(int(o)) if float(o).is_integer() else round(float(o), 1))
385
+ return acc
386
+ pool = _nums(art, set())
387
+ pool |= {round(v, 1) for v in list(pool)}
388
+ page = _u2.urlopen(f"{a.base}/force.html", timeout=30).read().decode()
389
+ txt = _h.unescape(_re.sub(r"<[^>]+>", " ",
390
+ _re.sub(r"<(script|style)[^>]*>.*?</\1>", " ",
391
+ page, flags=_re.S)))
392
+ shown = {float(m.replace(",", ""))
393
+ for m in _re.findall(r"(?<![\w.])(\d+(?:,\d{3})*(?:\.\d+)?)", txt)}
394
+ # small integers are prose (years, counts of things named in words)
395
+ shown = {v for v in shown if v not in (0, 1, 2, 3, 5, 6, 7, 10, 15, 60)}
396
+ orphan = sorted(v for v in shown
397
+ if not any(abs(v - c) < 0.051 for c in pool))
398
+ check(not orphan,
399
+ "every number on the force page traces to press_axis.json",
400
+ f"{len(shown)} numbers rendered, all reproducible from the artifact"
401
+ if not orphan else f"not in the artifact: {orphan[:8]}")
402
+
403
  w = max(len(x) for _, x, _ in RESULTS)
404
  print()
405
  for ok, name, ev in RESULTS: