yxma commited on
Commit
7684a18
·
verified ·
1 Parent(s): 965fecd

Update README + docs/{quality,caveats}.md: post-trim totals, three concrete filtering recipes (example dataloader / direct .pt / pose-only), rewritten OT-track-loss section reflecting the prefix-trim + recorder watchdog fix

Browse files
Files changed (3) hide show
  1. README.md +26 -5
  2. docs/caveats.md +70 -37
  3. docs/quality.md +93 -49
README.md CHANGED
@@ -53,7 +53,7 @@ Dense, contact-rich, synchronized multimodal interaction data collected from **h
53
  | Embodiment | **Human hands (no robot)** — handheld GelSight sensors with motion-capture rigid bodies |
54
  | Intended use | Dynamics / world-model learning over short multimodal windows. Sample short trajectories (1 s – 10 s); recording-file boundaries are not action boundaries. |
55
  | Total synchronized duration | **105.7 min** at 30 Hz (190,231 multimodal frames, post-trim) |
56
- | Bimanual tactile-contact time | **81.4 min — 66 % of frames** (median event duration 0.73 s) |
57
  | Cameras | 3× Intel RealSense D415 (color + depth), 480×640, 30 FPS |
58
  | Tactile | 2× GelSight Mini (left, right), handheld |
59
  | Motion capture | OptiTrack VRPN, 3 rigid bodies, ~120 Hz |
@@ -69,7 +69,18 @@ Dense, contact-rich, synchronized multimodal interaction data collected from **h
69
 
70
  See [`tasks.json`](tasks.json) for the machine-readable registry (per-date `active_sensors`, etc.).
71
 
72
- **OT-uninitialized prefixes trimmed.** Three episodes had OptiTrack offline for the first 1–11 min of recording (`2026-05-11/episode_{005,012,017}`); those prefixes have been cut from the published `.pt` files (see `_contact_meta.trim_offset` per file). The original recordings remain in the H5 archive untouched. Future episodes use a recorder-side OT watchdog that refuses to start without an active mocap stream.
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  ## Quick start
75
 
@@ -98,15 +109,25 @@ ep = torch.load(path, weights_only=False)
98
  # Plus per-frame contact metrics: tactile_{side}_{intensity, area, mixed}
99
  ```
100
 
101
- Sampling short windows for dynamics learning:
102
 
103
  ```python
104
  import json
 
105
  with open("bad_frames.json") as f:
106
- bad = json.load(f)["episodes"]
107
- # Drop ~0.085 % of frames flagged in bad_frames.json — see docs/quality.md
 
 
 
 
 
 
 
108
  ```
109
 
 
 
110
  ## Example dataloader — short contact-rich windows
111
 
112
  A reference PyTorch `Dataset` is shipped under [`examples/react_window_dataset.py`](examples/react_window_dataset.py). It scans the processed `.pt` files, applies the contact filter, drops windows that overlap [`bad_frames.json`](bad_frames.json), and respects the per-date `active_sensors` field from [`tasks.json`](tasks.json).
 
53
  | Embodiment | **Human hands (no robot)** — handheld GelSight sensors with motion-capture rigid bodies |
54
  | Intended use | Dynamics / world-model learning over short multimodal windows. Sample short trajectories (1 s – 10 s); recording-file boundaries are not action boundaries. |
55
  | Total synchronized duration | **105.7 min** at 30 Hz (190,231 multimodal frames, post-trim) |
56
+ | Bimanual tactile-contact time | ** 75 % of post-trim frames** (median event duration 0.73 s; see `data_quality_report.csv` for per-file numbers) |
57
  | Cameras | 3× Intel RealSense D415 (color + depth), 480×640, 30 FPS |
58
  | Tactile | 2× GelSight Mini (left, right), handheld |
59
  | Motion capture | OptiTrack VRPN, 3 rigid bodies, ~120 Hz |
 
69
 
70
  See [`tasks.json`](tasks.json) for the machine-readable registry (per-date `active_sensors`, etc.).
71
 
72
+ **OT-uninitialized prefixes trimmed.** Three episodes had OptiTrack offline at the start of recording (1–11 min each); those prefixes have been cut from the published `.pt` files (`_contact_meta.trim_offset` per file). Future recordings use an OT watchdog that refuses to start an episode unless mocap is streaming. Full story: [`docs/caveats.md`](docs/caveats.md).
73
+
74
+ ## Data quality
75
+
76
+ | Mode | Frames | % | Files | Cause |
77
+ |---|---:|---:|---:|---|
78
+ | GelSight LED flicker | 56 | 0.029 % | 5 | Single-frame LED dropout, recovers next frame |
79
+ | OptiTrack pose teleport | 56 | 0.029 % | 3 | Solver flip (translation > 5 m/s or angular > 15 rad/s) |
80
+ | OptiTrack track loss | 1,680 | 0.883 % | 6 | Marker briefly left mocap-volume / camera FOV mid-episode |
81
+ | **Total (union)** | **1,768** | **0.929 %** | **11** | |
82
+
83
+ Every flagged interval is in [`bad_frames.json`](bad_frames.json) keyed by `episode/episode_*` with TRIMMED-pt frame indices. Skip-list usage is shown below and in [`docs/quality.md`](docs/quality.md). Long start-of-episode OT-uninitialized prefixes (the dominant problem in the raw recordings) have already been trimmed from the published `.pt` files — see [`docs/caveats.md`](docs/caveats.md).
84
 
85
  ## Quick start
86
 
 
109
  # Plus per-frame contact metrics: tactile_{side}_{intensity, area, mixed}
110
  ```
111
 
112
+ Sampling short windows for dynamics learning — **drop windows that overlap any flagged interval**:
113
 
114
  ```python
115
  import json
116
+
117
  with open("bad_frames.json") as f:
118
+ bad = json.load(f)["episodes"] # frame indices are TRIMMED-pt coordinates
119
+
120
+ def is_clean_window(episode_key, t_start, t_end):
121
+ """True iff [t_start, t_end] doesn't intersect any flagged span."""
122
+ bf = bad[episode_key]
123
+ intervals = (bf["intensity_spikes"]
124
+ + bf["pose_teleports_L"] + bf["pose_teleports_R"]
125
+ + bf["ot_loss_L"] + bf["ot_loss_R"])
126
+ return all(not (s <= t_end and e >= t_start) for s, e in intervals)
127
  ```
128
 
129
+ Currently 1,768 / 190,231 frames (0.93 %) are flagged across 11 of 27 files — see [`docs/quality.md`](docs/quality.md) for the per-mode breakdown and more filtering recipes. The example dataloader below does this filtering for you when `skip_bad_frames=True`.
130
+
131
  ## Example dataloader — short contact-rich windows
132
 
133
  A reference PyTorch `Dataset` is shipped under [`examples/react_window_dataset.py`](examples/react_window_dataset.py). It scans the processed `.pt` files, applies the contact filter, drops windows that overlap [`bad_frames.json`](bad_frames.json), and respects the per-date `active_sensors` field from [`tasks.json`](tasks.json).
docs/caveats.md CHANGED
@@ -9,47 +9,80 @@ React is a **dense multimodal interaction stream** intended for learning **dynam
9
  - A demonstration / policy-learning dataset. "Episodes" here are just file boundaries — they don't carry semantic / action structure.
10
  - Comparable apples-to-apples with BridgeData V2, DROID, RT-1, ALOHA, etc. on "number of demos." The relevant comparison is *hours of synchronized multimodal contact-rich interaction*.
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ## Other caveats
13
 
14
  - **Missing / dropped files** on `motherboard/2026-05-11`:
15
- - `episode_000` and `episode_002` — short test recordings (8.8 s and 10.4 s) with no tactile contact on either sensor; intentionally excluded.
16
- - `episode_001` lost at recording time (HDF5 superblock never finalized when the writer was killed mid-write); intentionally absent.
17
- - The remaining episode IDs are non-contiguous as a result. **Don't infer ordering from filename gaps.**
18
- - **Lossy resize**: the 128×128 `view` and tactile fields are downsampled from native 480×640. Native resolution is **not** preserved in this release.
19
- - **Single camera**: only `realsense/cam0/color` is included. The other two RealSense views and all depth streams are not in `processed/mode1_v1/`.
20
- - **OptiTrack alignment**: the per-step poses are nearest-neighbor matched to camera ticks. The full ~120 Hz pose streams are not preserved here.
21
- - **Mode is opinionated**: contact metrics depend on the chosen `tau` and the p01 reference strategy. If you want a different `tau`, re-deriving from raw is necessary.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  ## Roadmap
24
 
25
  - **More tasks** — the registry in [`../tasks.json`](../tasks.json) will grow.
26
- - **LeRobot-format full-fidelity** variant (`lerobot/v1.0/`) is planned. It will include all three RealSense color and depth streams, GelSight at native resolution (FFV1 lossless), full-rate OptiTrack pose tracks for all three rigid bodies, and HF-native browser previews. The current `processed/mode1_v1/` slice will remain as a stable training-task view.
27
-
28
- ## OptiTrack track loss (the dominant data-quality issue)
29
-
30
- The 47 `ot_loss` intervals in [`bad_frames.json`](../bad_frames.json) all
31
- come from the same root cause: **the GelSight rigid body moved near the
32
- edge of the OptiTrack mocap volume / camera FOV**, the solver lost the
33
- body, and the recorder kept emitting the last good pose. On re-acquire
34
- the solver sometimes flips orientation (per-sample angular velocity up to
35
- 51,000 rad/s), which the cross-modal detector picks up as a teleport
36
- boundary.
37
-
38
- What's *not* broken during these intervals:
39
-
40
- - RealSense streams — all three cameras keep capturing fresh frames.
41
- - GelSight streams — the gel pad just isn't deforming (sensor moved in
42
- free air or set down). Frame-duplicate rate is high but that's a
43
- side-effect of low contact, not a pipeline stall.
44
- - The recorder itself — all writes land in the H5 on schedule.
45
-
46
- What is broken: `sensor_{side}_pose` is stale during the interval, so any
47
- training window overlapping it has an unreliable label. The shipped
48
- `bad_frames.json` flags these as `ot_loss_L` / `ot_loss_R` and the
49
- example dataloader skips overlapping windows automatically when
50
- `skip_bad_frames=True`.
51
-
52
- **Mitigation for future recordings**: keep the workspace centred in the
53
- mocap volume; add a fourth/fifth marker to each GelSight rigid body so
54
- the solver tolerates more occlusion; add a fourth OT camera if budget
55
- allows. None of these affect the current dataset retroactively.
 
9
  - A demonstration / policy-learning dataset. "Episodes" here are just file boundaries — they don't carry semantic / action structure.
10
  - Comparable apples-to-apples with BridgeData V2, DROID, RT-1, ALOHA, etc. on "number of demos." The relevant comparison is *hours of synchronized multimodal contact-rich interaction*.
11
 
12
+ ## OT-uninitialized prefixes (already trimmed from `.pt`)
13
+
14
+ Three episodes on 2026-05-11 had OptiTrack offline at the moment the
15
+ operator pressed `s` to start recording. RealSense + GelSight kept
16
+ capturing fresh frames; OT held a stale (or zero) pose until the mocap
17
+ software came online:
18
+
19
+ | Episode | Trimmed prefix | What it was |
20
+ |---|---:|---|
21
+ | `episode_005` | 81 s (2,429 frames) | OT had ~50 samples in the prefix (~0.6 Hz) |
22
+ | `episode_012` | 324 s (9,719 frames) | OT had 3 samples in the prefix |
23
+ | `episode_017` | 641 s (19,228 frames) | OT had **zero** samples in the prefix |
24
+
25
+ **These prefixes have already been trimmed** from the published `.pt`
26
+ files. Each `.pt` records the trim amount in `_contact_meta.trim_offset`,
27
+ and all frame indices in `bad_frames.json` are in post-trim coordinates.
28
+ The original H5 recordings under `data/motherboard/2026-05-11/` remain
29
+ untouched in the recording-machine archive (not on HF).
30
+
31
+ **Fixed at the source**: future recordings use a `data_collection.py`
32
+ recorder-side watchdog that (a) refuses to start an episode unless every
33
+ active rigid body has streamed an OT sample in the last 2 s, and (b)
34
+ auto-saves + ends an in-progress episode after 10 s of OT silence on any
35
+ active body. The bug that produced these prefixes can no longer happen.
36
+
37
+ ## OT track loss mid-episode (the remaining ~0.9 %)
38
+
39
+ After trimming the prefixes, the rest of the `ot_loss` intervals in
40
+ [`../bad_frames.json`](../bad_frames.json) are short (typically 1–3 s)
41
+ mid-episode mocap dropouts. Per `freeze_diagnose`'s cross-modal motion
42
+ check, the gel pad is still healthy and the cameras still capture — only
43
+ the OptiTrack solver lost the rigid body, usually because the operator's
44
+ hand moved near the edge of the mocap volume / camera FOV.
45
+
46
+ The shipped `bad_frames.json` flags these as `ot_loss_L` / `ot_loss_R`
47
+ and the example dataloader skips overlapping windows automatically when
48
+ `skip_bad_frames=True`.
49
+
50
+ **Mitigation for future recordings**: keep the workspace centred in the
51
+ mocap volume; add a fourth or fifth marker to each GelSight rigid body
52
+ so the solver tolerates more occlusion; add a fourth OT camera if budget
53
+ allows. None of these affect the current dataset retroactively — they're
54
+ just guidance for follow-up recording sessions.
55
+
56
  ## Other caveats
57
 
58
  - **Missing / dropped files** on `motherboard/2026-05-11`:
59
+ - `episode_000` and `episode_002` — short test recordings (8.8 s and
60
+ 10.4 s) with no tactile contact on either sensor; intentionally
61
+ excluded.
62
+ - `episode_001` lost at recording time (HDF5 superblock never
63
+ finalized when the writer was killed mid-write); intentionally absent.
64
+ - The remaining episode IDs are non-contiguous as a result. **Don't
65
+ infer ordering from filename gaps.**
66
+ - **Lossy resize**: the 128×128 `view` and tactile fields are downsampled
67
+ from native 480×640. Native resolution is **not** preserved in this
68
+ release.
69
+ - **Single camera**: only `realsense/cam0/color` is included in the
70
+ `processed/.../*.pt` slice. The other two RealSense views (and depth
71
+ streams) are recorded in the raw H5 archive but not exposed in
72
+ `processed/mode1_v1/`.
73
+ - **OptiTrack alignment**: the per-step poses in `.pt` are nearest-neighbour
74
+ matched to camera ticks. The full ~120 Hz pose streams are not
75
+ preserved here.
76
+ - **Contact metrics are opinionated**: `tactile_{side}_{intensity, area, mixed}`
77
+ depend on the chosen `tau` and the `p01` reference strategy. If you
78
+ want a different `tau`, you'll need to re-derive them from raw GelSight
79
+ frames.
80
 
81
  ## Roadmap
82
 
83
  - **More tasks** — the registry in [`../tasks.json`](../tasks.json) will grow.
84
+ - **LeRobot-format full-fidelity** variant (`lerobot/v1.0/`) is planned.
85
+ It will include all three RealSense color and depth streams, GelSight
86
+ at native resolution (FFV1 lossless), full-rate OptiTrack pose tracks
87
+ for all three rigid bodies, and HF-native browser previews. The current
88
+ `processed/mode1_v1/` slice will remain as a stable training-task view.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/quality.md CHANGED
@@ -1,39 +1,109 @@
1
  # Data quality
2
 
3
- A small fraction of frames contain known sensor artifacts. The repo ships a [`../bad_frames.json`](../bad_frames.json) index so downstream code can avoid sampling on top of these intervals — useful since this dataset is intended for **short-window dynamics / world-model learning**, where a glitch landing inside a training window can dominate the loss for that step.
 
 
4
 
5
  ## Headline numbers
6
 
7
  | | |
8
  |---|---:|
9
- | Total synchronized frames | 190,231 (105.7 min @ 30 Hz, post-trim) |
10
  | Recording files | 27 |
11
  | Frames flagged in `bad_frames.json` | **1,768 (0.929 %)** |
12
- | Recording files with ≥1 flagged frame | 11 |
13
 
14
  ## Failure modes — quantitative breakdown
15
 
16
  | # | Mode | Frames | % of dataset | Files | Symptom | Example |
17
  |---|---|---:|---:|---:|---|---|
18
- | 1 | **GelSight LED flicker** | 66 | **0.030 %** | 5 / 27 | 1–2 frames of uniform pink/magenta wash across the gel surface; adjacent frames normal. 2026-05-11 / {003, 007, 008, 011, 017}. | [`intensity_spike_overview.png`](../figures/dataset_figures/intensity_spike_samples/intensity_spike_overview.png) |
19
- | 2 | **OptiTrack pose teleport (>5 m/s)** | 64 | **0.029 %** | 3 / 27 | Position jumps by >5 cm in 33 ms mocap lost lock and reacquired. 2026-05-10/{001, 002}, 2026-05-11/015. | [`pose_teleport_samples/`](../figures/dataset_figures/pose_teleport_samples/) |
20
- | 3 | **OptiTrack track loss** | 33,056 | **14.92 %** | 8 / 27 | OptiTrack lost the rigid body the recorder kept emitting the held pose. Boundary glitches (ang vel up to 51 k rad/s) appear on re-acquire. Worst single outage: 10.7 min (ep_017). Cause: marker near mocap-volume / camera-FOV boundary. GelSight + RealSense streams are *not* affected. | [`freeze_diagnose/`](../figures/dataset_figures/freeze_diagnose/) |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- **Modes 1+2+3 together: 33,144 / 221,621 = 14.96% of frames flagged.** Earlier note: 122 / 221621 = 0.055 % of frames are corrupted in any modality.** Mode 3 is tracked separately because it is healthy data, just non-informative for dynamics. `bad_frames.json` covers modes 1 and 2 only; if you also want to skip rest periods, intersect with the velocity track from `sensor_*_pose`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  ## Inspection figures
25
 
26
- **Mode 1 — GelSight LED flicker** (overview across all 5 affected files):
27
 
28
  ![Intensity spike overview](../figures/dataset_figures/intensity_spike_samples/intensity_spike_overview.png)
29
 
30
- Per-file close-ups (reference frame, ±1 s neighbors, peak frame): [`figures/dataset_figures/intensity_spike_samples/`](../figures/dataset_figures/intensity_spike_samples/).
31
 
32
- **Mode 2 — OptiTrack pose teleport.** GIFs (10 s playback at 2× speed) for all 3 affected files: [`pose_teleport_samples/`](../figures/dataset_figures/pose_teleport_samples/).
33
 
34
- **Modes 1+2+3 — top-6 worst-offenders chart** (tactile intensity + sensor velocity time-series):
35
-
36
- ![Data quality report](../figures/dataset_figures/data_quality_report.png)
37
 
38
  ## `bad_frames.json` schema
39
 
@@ -43,21 +113,26 @@ Frame indices are inclusive on both ends and pre-padded by `buffer_frames` (3) o
43
  {
44
  "tau_intensity": 30.0,
45
  "tau_velocity_mps": 5.0,
 
 
 
46
  "buffer_frames": 3,
47
  "summary": {
48
  "n_episodes": 27,
49
- "total_frames": 221621,
50
- "total_bad_frames": 122,
51
- "bad_fraction_overall": 0.00055,
52
- "n_episodes_with_bad_frames": 8
53
  },
54
  "episodes": {
55
  "2026-05-11/episode_003": {
56
  "n_frames": 10032,
57
- "duration_s": 338.2,
58
  "intensity_spikes": [[260, 268], "..."],
59
  "pose_teleports_L": [],
60
  "pose_teleports_R": [],
 
 
61
  "total_bad_frames": 19,
62
  "bad_fraction": 0.0019
63
  }
@@ -67,37 +142,6 @@ Frame indices are inclusive on both ends and pre-padded by `buffer_frames` (3) o
67
 
68
  A per-mode aggregate is also available: [`figures/dataset_figures/data_quality_breakdown.json`](../figures/dataset_figures/data_quality_breakdown.json).
69
 
70
- ## Use in a dataloader
71
-
72
- ```python
73
- import json
74
- from pathlib import Path
75
-
76
- with open("bad_frames.json") as f:
77
- bad = json.load(f)["episodes"]
78
- with open("tasks.json") as f:
79
- sessions = json.load(f)["tasks"]["motherboard"]["per_date_notes"]
80
-
81
- def is_clean_window(ep_name, t_start, t_end):
82
- """Return True if [t_start, t_end] does not overlap any flagged interval."""
83
- intervals = (bad[ep_name]["intensity_spikes"]
84
- + bad[ep_name]["pose_teleports_L"]
85
- + bad[ep_name]["pose_teleports_R"])
86
- for s, e in intervals:
87
- if s <= t_end and e >= t_start:
88
- return False
89
- return True
90
-
91
- def active_sensors(ep_name):
92
- """Returns e.g. ['right'] or ['left', 'right']."""
93
- date = ep_name.split("/")[0]
94
- return sessions[date]["active_sensors"]
95
-
96
- # In your sampler:
97
- # if not is_clean_window(...): resample
98
- # sides = active_sensors(...) # mask out inactive tactile + pose modalities
99
- ```
100
-
101
  ## Full report (per-file CSV)
102
 
103
  Every file's individual stats (frames, duration, contact %, max intensity left/right, drift, max pose velocity, etc.) are in [`figures/dataset_figures/data_quality_report.csv`](../figures/dataset_figures/data_quality_report.csv).
 
1
  # Data quality
2
 
3
+ A small fraction of frames contain known sensor artifacts. The repo ships [`../bad_frames.json`](../bad_frames.json) as a skip-list so downstream code can avoid sampling on top of these intervals — important since this dataset is intended for **short-window dynamics / world-model learning**, where a glitch landing inside a training window can dominate the loss for that step.
4
+
5
+ > **All frame indices in `bad_frames.json` are in TRIMMED `.pt` coordinates.** The original H5 recordings have not been edited; only the published `.pt` files have had their OT-uninitialized prefixes cut (see [`caveats.md`](caveats.md) §OT track loss). The per-file trim offset is stored in `_contact_meta.trim_offset` inside each `.pt`.
6
 
7
  ## Headline numbers
8
 
9
  | | |
10
  |---|---:|
11
+ | Total synchronized frames (post-trim) | 190,231 (105.7 min @ 30 Hz) |
12
  | Recording files | 27 |
13
  | Frames flagged in `bad_frames.json` | **1,768 (0.929 %)** |
14
+ | Recording files with ≥ 1 flagged frame | 11 |
15
 
16
  ## Failure modes — quantitative breakdown
17
 
18
  | # | Mode | Frames | % of dataset | Files | Symptom | Example |
19
  |---|---|---:|---:|---:|---|---|
20
+ | 1 | **GelSight LED flicker** | 56 | **0.029 %** | 5 / 27 | 1–2 frames of uniform pink/magenta wash across the gel surface; adjacent frames normal. | [`intensity_spike_overview.png`](../figures/dataset_figures/intensity_spike_samples/intensity_spike_overview.png) |
21
+ | 2 | **OptiTrack pose teleport** | 56 | **0.029 %** | 3 / 27 | Translation velocity > 5 m/s **or** angular velocity > 15 rad/s in a single OT sample (solver flip physically impossible for human-hand motion). | [`pose_teleport_samples/`](../figures/dataset_figures/pose_teleport_samples/) |
22
+ | 3 | **OptiTrack track loss** | 1,680 | **0.883 %** | 6 / 27 | Sensor pose held at a stale value for 0.25 s; cross-modal motion check confirms hand was actually moving. Cause: marker briefly left the mocap volume / camera FOV. | [`freeze_diagnose/`](../figures/dataset_figures/freeze_diagnose/) |
23
+
24
+ **Union of modes 1+2+3: 1,768 / 190,231 = 0.929 % of post-trim frames flagged.** Mode 3 is by far the largest — but it's already orders of magnitude smaller than what the *raw* recordings looked like (15 % of frames before the OT-uninitialized prefixes were trimmed). The remaining 0.88 % is genuine mid-episode mocap dropout that no amount of post-processing can recover.
25
+
26
+ ## How to use the data — three recipes
27
+
28
+ ### A. Easiest: the shipped example dataloader
29
+
30
+ `ReactWindowDataset` does the right thing out of the box. Just turn `skip_bad_frames=True`:
31
+
32
+ ```python
33
+ from examples.react_window_dataset import ReactWindowDataset
34
+ from torch.utils.data import DataLoader
35
+
36
+ ds = ReactWindowDataset(
37
+ data_root = "processed/mode1_v1/motherboard",
38
+ bad_frames_path = "bad_frames.json",
39
+ tasks_json_path = "tasks.json",
40
+ window_length = 16,
41
+ skip_bad_frames = True, # ← drops windows touching ANY of modes 1/2/3
42
+ respect_active_sensors = True,
43
+ )
44
+ ```
45
 
46
+ Any window whose [t_start, t_end] range overlaps an `intensity_spikes` /
47
+ `pose_teleports_{L,R}` / `ot_loss_{L,R}` interval is silently dropped at
48
+ window-enumeration time, so your DataLoader never sees them.
49
+
50
+ ### B. Loading a single `.pt` directly — DIY skip-list
51
+
52
+ If you're rolling your own sampler or scanning a single file:
53
+
54
+ ```python
55
+ import json, torch
56
+
57
+ ep_key = "2026-05-11/episode_017"
58
+ ep = torch.load(f"processed/mode1_v1/motherboard/{ep_key}.pt", weights_only=False)
59
+ T = ep["view"].shape[0]
60
+ trim_offset = ep["_contact_meta"].get("trim_offset", 0) # already applied to ep
61
+ bad = json.load(open("bad_frames.json"))["episodes"][ep_key]
62
+
63
+ # Build a per-frame boolean mask (True = drop)
64
+ import numpy as np
65
+ mask = np.zeros(T, dtype=bool)
66
+ for s_, e_ in (bad["intensity_spikes"]
67
+ + bad["pose_teleports_L"] + bad["pose_teleports_R"]
68
+ + bad["ot_loss_L"] + bad["ot_loss_R"]):
69
+ mask[s_:e_ + 1] = True
70
+ print(f"{mask.sum()}/{T} flagged ({100 * mask.mean():.2f} %)")
71
+
72
+ # Then sample only clean windows:
73
+ def clean_window_start(t_start, win_len):
74
+ return not mask[t_start:t_start + win_len].any()
75
+ ```
76
+
77
+ ### C. Only care about action labels (pose)? Skip just ot_loss
78
+
79
+ If your model treats vision + tactile as observations and sensor pose as the *action* label (UMI-style imitation learning), the LED flicker and translation teleports are observation-side noise that you can usually tolerate (single frames or short < 0.3 s spikes). The OT track losses are the one mode you *must* exclude, because the recorded "action" is stale:
80
+
81
+ ```python
82
+ # Just the action-label cuts
83
+ def clean_pose_window(t_start, win_len, bad_ep):
84
+ for s_, e_ in (bad_ep["ot_loss_L"] + bad_ep["ot_loss_R"]
85
+ + bad_ep["pose_teleports_L"] + bad_ep["pose_teleports_R"]):
86
+ if s_ <= t_start + win_len - 1 and e_ >= t_start:
87
+ return False
88
+ return True
89
+ ```
90
+
91
+ ### What NOT to do
92
+
93
+ - Don't ignore `bad_frames.json` — for `ot_loss` intervals the *recorded pose looks plausible* (it's just a stale held value), but the actual sensor was moving. A model trained on those will learn that contact-rich tactile signals are uncorrelated with motion.
94
+ - Don't try to skip individual *frames* and stitch the rest — windows must be contiguous over time. Drop the **whole window**, not just the bad frames in it.
95
 
96
  ## Inspection figures
97
 
98
+ **Mode 1 — GelSight LED flicker** (overview across all affected files):
99
 
100
  ![Intensity spike overview](../figures/dataset_figures/intensity_spike_samples/intensity_spike_overview.png)
101
 
102
+ Per-file close-ups: [`figures/dataset_figures/intensity_spike_samples/`](../figures/dataset_figures/intensity_spike_samples/).
103
 
104
+ **Mode 2 — OptiTrack pose teleport.** GIFs (10 s playback at 2× speed) for all affected files: [`pose_teleport_samples/`](../figures/dataset_figures/pose_teleport_samples/).
105
 
106
+ **Mode 3 — OptiTrack track loss.** 15 sample clips (recording-viewer layout, 30 fps real time, red ring on the frozen-sensor projected dot): [`freeze_diagnose/ot_loss/`](../figures/dataset_figures/freeze_diagnose/ot_loss/).
 
 
107
 
108
  ## `bad_frames.json` schema
109
 
 
113
  {
114
  "tau_intensity": 30.0,
115
  "tau_velocity_mps": 5.0,
116
+ "tau_angular_rad_per_s": 15.0,
117
+ "tau_opt_gap_s": 0.10,
118
+ "freeze_threshold_s": 0.25,
119
  "buffer_frames": 3,
120
  "summary": {
121
  "n_episodes": 27,
122
+ "total_frames": 190231,
123
+ "total_bad_frames": 1768,
124
+ "bad_fraction_overall": 0.009294,
125
+ "n_episodes_with_bad_frames": 11
126
  },
127
  "episodes": {
128
  "2026-05-11/episode_003": {
129
  "n_frames": 10032,
130
+ "duration_s": 334.4,
131
  "intensity_spikes": [[260, 268], "..."],
132
  "pose_teleports_L": [],
133
  "pose_teleports_R": [],
134
+ "ot_loss_L": [],
135
+ "ot_loss_R": [],
136
  "total_bad_frames": 19,
137
  "bad_fraction": 0.0019
138
  }
 
142
 
143
  A per-mode aggregate is also available: [`figures/dataset_figures/data_quality_breakdown.json`](../figures/dataset_figures/data_quality_breakdown.json).
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  ## Full report (per-file CSV)
146
 
147
  Every file's individual stats (frames, duration, contact %, max intensity left/right, drift, max pose velocity, etc.) are in [`figures/dataset_figures/data_quality_report.csv`](../figures/dataset_figures/data_quality_report.csv).