harryzhang1018 commited on
Commit
6039542
·
verified ·
1 Parent(s): c27a6f3

SO101 pick-and-place: archive study source and reproduction guide outside NeDM results PR

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. README.md +31 -62
  2. so101_pick_place/code/README.md +198 -0
  3. so101_pick_place/code/REPRODUCE.md +44 -0
  4. so101_pick_place/code/configs/contact_nrd/collection/so101_grasp.json +344 -0
  5. so101_pick_place/code/configs/so101_pick_place/calib_v1.json +1526 -0
  6. so101_pick_place/code/configs/so101_pick_place/dyn_fit_d2q.json +77 -0
  7. so101_pick_place/code/configs/so101_pick_place/nrd/base_c0.json +81 -0
  8. so101_pick_place/code/configs/so101_pick_place/nrd/ft_c1_s62.json +90 -0
  9. so101_pick_place/code/configs/so101_pick_place/parts_override_v2.json +1667 -0
  10. so101_pick_place/code/configs/so101_pick_place/real_scene_v2.json +627 -0
  11. so101_pick_place/code/configs/so101_pick_place/so101_follower_lerobot_calib.json +44 -0
  12. so101_pick_place/code/configs/so101_pick_place/teacher/env_jt_b140.json +1 -0
  13. so101_pick_place/code/configs/so101_pick_place/teacher/env_jt_h110.json +1 -0
  14. so101_pick_place/code/configs/so101_policy/ppo/curriculum_tol_v3.json +8 -0
  15. so101_pick_place/code/configs/so101_policy/ppo/env_v2.json +11 -0
  16. so101_pick_place/code/configs/so101_policy/ppo/joint_ppo_v3.json +35 -0
  17. so101_pick_place/code/configs/so101_policy/ppo/r2s/joint_ppo_v3_kl02.json +35 -0
  18. so101_pick_place/code/configs/so101_policy/ppo/r2s/teacher_roll_v12_fr10.json +15 -0
  19. so101_pick_place/code/configs/so101_policy/ppo/r2s/teacher_roll_v8.json +10 -0
  20. so101_pick_place/code/configs/so101_policy/ppo/train_v2.json +14 -0
  21. so101_pick_place/code/configs/so101_policy/vision/viral_r2s_home.json +20 -0
  22. so101_pick_place/code/configs/so101_policy/vision/viral_r2s_online_relabel_roll_v8.json +45 -0
  23. so101_pick_place/code/configs/so101_policy/vision/viral_r2s_online_relabel_v4.json +44 -0
  24. so101_pick_place/code/configs/so101_policy/vision/viral_r2s_online_v1.json +17 -0
  25. so101_pick_place/code/configs/so101_policy/vision/viral_r2s_online_v12_tb10.json +55 -0
  26. so101_pick_place/code/configs/so101_policy/vision/viral_r2s_v1.json +64 -0
  27. so101_pick_place/code/contact_nrd/so101_grasp/.gitignore +2 -0
  28. so101_pick_place/code/contact_nrd/so101_grasp/fetch_sources.py +61 -0
  29. so101_pick_place/code/contact_nrd/so101_grasp/source_manifest.json +159 -0
  30. so101_pick_place/code/docs/hf_dataset_card.md +866 -0
  31. so101_pick_place/code/requirements-so101-pick-place.txt +33 -0
  32. so101_pick_place/code/scripts/so101_pick_place/check/check_analyze.py +231 -0
  33. so101_pick_place/code/scripts/so101_pick_place/check/check_eval.py +275 -0
  34. so101_pick_place/code/scripts/so101_pick_place/check/gates_summary.py +277 -0
  35. so101_pick_place/code/scripts/so101_pick_place/check/run_gates.sh +97 -0
  36. so101_pick_place/code/scripts/so101_pick_place/check/sel_rules.py +161 -0
  37. so101_pick_place/code/scripts/so101_pick_place/check/sim_eps.py +189 -0
  38. so101_pick_place/code/scripts/so101_pick_place/download.py +141 -0
  39. so101_pick_place/code/scripts/so101_pick_place/nrd/equiv.py +53 -0
  40. so101_pick_place/code/scripts/so101_pick_place/nrd/equiv_compare.py +46 -0
  41. so101_pick_place/code/scripts/so101_pick_place/nrd/strip_ckpt.py +148 -0
  42. so101_pick_place/code/scripts/so101_pick_place/nrd/subsets.py +74 -0
  43. so101_pick_place/code/scripts/so101_pick_place/nrd/summarize.py +92 -0
  44. so101_pick_place/code/scripts/so101_pick_place/reproduce.sh +872 -0
  45. so101_pick_place/code/scripts/so101_pick_place/robot/build_results.py +321 -0
  46. so101_pick_place/code/scripts/so101_pick_place/robot/render_videos.py +224 -0
  47. so101_pick_place/code/scripts/so101_policy/real2sim/hw/QDGAIN_TEST.md +101 -0
  48. so101_pick_place/code/scripts/so101_policy/real2sim/hw/README.md +241 -0
  49. so101_pick_place/code/scripts/so101_policy/real2sim/hw/hw_lib.py +1140 -0
  50. so101_pick_place/code/scripts/so101_policy/real2sim/hw/make_orin_bundle.sh +51 -0
README.md CHANGED
@@ -799,68 +799,37 @@ dataset revision you used (`cba82611210e401dc0155cb78fcf456a385ecef4`).
799
 
800
  ## Part E: SO101 pick and place
801
 
802
- ### What it is
803
-
804
- Follow-on work to the paper, not part of it. A camera policy (the "student") for a real SO101 arm picks a 30 mm cube
805
- and places it on a plate. Every training step ran inside a contact NRD of the arm and the cube (the design of Part C,
806
- trained on CPU MuJoCo 3.15.0 episodes): a state teacher trained with PPO in the NRD, then the student trained in the
807
- NRD with ray-traced images of a calibrated copy of the real scene (online DAgger). No real image was a training
808
- sample. On the real arm the student placed the cube in 36 of 50 stress-test episodes (72 %; 95 % interval 58–83 %).
809
- The training, the results and the commands are in
810
- [`so101_pick_place/` of the code repository](https://github.com/uwsbel/NeDM/tree/main/so101_pick_place).
811
 
812
- ### Layout
 
 
813
 
814
- | Path | Contents |
815
  |---|---|
816
- | `so101_pick_place/nrd/c1_s62/`, `nrd/c0_s62/` | The policy NRD (every teacher and student stage ran in it) and its base: `best.pt` loads with `nedm.contact_nrd.model.load_model`; `original/best.pt` is the file as trained (two training-only heads more); the training records |
817
- | `so101_pick_place/nrd_data/` | The 4 NRD training data parts (93,494 episodes; `unified_data.npz`, `system.json`, `manifest.json`), and the 7 PPO policies behind `policy_v3` |
818
- | `so101_pick_place/nrd_test/` | The sealed scripted test set (3,050 episodes) |
819
- | `so101_pick_place/teacher/`, `student/` | Every teacher (T0-T6) and student (S0-S5) checkpoint of the chain with its run record; the teacher's expert data |
820
- | `so101_pick_place/rl_inputs/` | Task sets, start banks, geometry, the task sets of the sim checks |
821
- | `so101_pick_place/results/` | The sealed NRD test, the sim-check results and selection rules, the per-episode robot results |
822
- | `so101_pick_place/robot/` | Raw logs of 19 robot sessions (102 policy episodes), 52 videos of the student's input images, 2 LeRobot teleop recordings |
823
- | `so101_pick_place/bundle/` | The folder installed on the robot computer, and its tarball |
824
- | `so101_pick_place/scene_calib/`, `provenance/` | Camera calibration, scene and servo fit (also in the code repository); code snapshots that are in no commit |
825
- | `so101_pick_place/release_manifest.json` | Size and SHA-256 of every file; provenance (commits, runs, sources) |
826
-
827
- Total 13.3 GB (NRD data 10.6 GB).
828
-
829
- ### What the files contain
830
-
831
- - NRD data (`unified_data.npz`, uncompressed): `arm` [N, 601, 12] (6 joint angles, 6 joint rates), `cube` [N, 601,
832
- 13] (position, quaternion wxyz, velocity, angular velocity), `action` [N, 601, 6] (joint position targets),
833
- `contacts` [N, 600, 3] (fixed jaw - cube, moving jaw - cube, cube - table), `lengths`, `splits` (0 train,
834
- 1 validation, 2 test), `family`, `phase`, contact force, impulse and depth, ids, seeds and outcome fields. Records
835
- are 10 ms apart, episodes 4 s.
836
- - Checkpoints: PyTorch files. Teachers: MLP state policies with privileged inputs. Students: two ResNet18 image
837
- encoders (external camera crop and wrist camera, 224 x 224 RGB), joint angles and rates, a chunk of 10 joint
838
- targets as output.
839
- - Robot logs: per session `session.json` (command line, typed outcome per episode) and `first_frames.npz`; per
840
- episode `episode_live.json` (setup, guard, latency, outcome) and `episode_live.npz` (50 Hz joints and commands,
841
- each policy query with its action chunk and the two input images at 112 px).
842
-
843
- ### Download and use
844
-
845
- ```bash
846
- scripts/so101_pick_place/reproduce.sh full --steps download # in the code repository; checks every SHA-256
847
- ```
848
-
849
- The code repository's `so101_pick_place/release_manifest.json` pins the Hub revision; `--with-nrd-data` and
850
- `--with-robot` add the large folders. The MuJoCo Menagerie SO101 model is not in this dataset: the code repository
851
- fetches it at a pinned revision.
852
-
853
- ### Known limitations
854
-
855
- - **One robot, one lab, one cube and plate.** The outcome is typed by the operator; the stress protocol was not fixed
856
- in advance, and the student was chosen with robot results.
857
- - **The NRD test set has only scripted families** and is not fully blind (run once before on an older NRD design).
858
- - **Lab content.** The robot logs hold lab background images, the robot computer's user path and the USB adapter
859
- serial. The videos show the student's input images as logged on the robot (112 px; the student sees 224 px);
860
- there is no full-resolution video.
861
-
862
- ### License and citation
863
-
864
- BSD-3-Clause, the same as Part A and the code. The MuJoCo Menagerie model is not hosted here. The SO101 pick and place
865
- has no publication yet: please cite the NeDM paper (Part A) and name the dataset revision you used (the
866
- `hf_revision` of `so101_pick_place/release_manifest.json` in the code repository).
 
799
 
800
  ## Part E: SO101 pick and place
801
 
802
+ Follow-on work to the paper. CPU MuJoCo arm-and-cube dynamics were distilled into a contact NRD, then a state
803
+ teacher and a camera student were trained inside it. The student placed a cube on a plate on a real SO101 arm
804
+ in **36/50 stress-test episodes (72 %; Wilson 95 % interval 58–83 %)**. No real image was a training sample;
805
+ real recordings informed calibration, later training rounds and student selection.
 
 
 
 
 
806
 
807
+ The NeDM [study summary](https://github.com/uwsbel/NeDM/tree/main/so101_pick_place) contains results and limitations.
808
+ The implementation, configs and full training guide are hosted here under
809
+ [`so101_pick_place/code/`](https://huggingface.co/datasets/harryzhang1018/NeDM/tree/main/so101_pick_place/code).
810
 
811
+ | Path under `so101_pick_place/` | Contents |
812
  |---|---|
813
+ | `code/` | Browsable source, configs, requirements, full study README, source manifest and `source.tar.gz` overlay; start with `code/REPRODUCE.md` |
814
+ | `nrd/`, `nrd_data/`, `nrd_test/` | Base and policy NRDs, 93,494 training episodes and the 3,050-episode scripted test |
815
+ | `teacher/`, `student/`, `rl_inputs/` | Training-chain checkpoints, run records, expert data, task sets and geometry |
816
+ | `results/` | NRD evaluations, simulation checks, selection rules and robot result records |
817
+ | `robot/` | 19 session logs, 52 videos and two LeRobot calibration/replay recordings |
818
+ | `bundle/`, `scene_calib/`, `provenance/` | Tested robot bundle, scene and servo calibration, available historical code snapshots |
819
+ | `release_manifest.json` | Original 503-file data manifest: sizes, SHA-256 values and stage provenance |
820
+
821
+ The original data release is about 13.3 GB, unchanged. The NeDM study's compact `release_manifest.json` pins the
822
+ source revision and original data revision separately. Download the source archive using the checksum-verified
823
+ command in the study summary, apply it over its pinned base Git checkout, then follow the full archived README.
824
+ The restored `scripts/so101_pick_place/reproduce.sh` downloads the data and checks every selected file's size
825
+ and SHA-256. Its `full --steps download,robot` command rebuilds result tables from archived logs.
826
+
827
+ Limits: one robot and lab; operator-labelled placements; student selection used robot screening; the stress
828
+ protocol was not fixed in advance. tb10 failed its original frozen sim rule and there is no sealed student test.
829
+ The NRD's 0.22/4.13 mm median/p95 1 s cube error scores 2,000 selected-family episodes; p95 over all 3,050 is
830
+ 4.61 mm. That scripted NRD test was previously used on an older design. Videos are the logged 112 px student
831
+ inputs. Some historical stages permit recipe-only reruns. Robot logs contain the previously released lab
832
+ images, paths and USB identifiers.
833
+
834
+ BSD-3-Clause, as for Part A and the code. The MuJoCo Menagerie model remains fetched from its pinned upstream
835
+ revision. This study has no publication yet; cite the NeDM paper and the data and source revisions used.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
so101_pick_place/code/README.md ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NeDM — Neural Reduced Dynamics for Complex Robot Control
2
+
3
+ Code and artifacts for *Learning the Right Abstraction: Neural Reduced Dynamics
4
+ for Complex Robot Control* (Zhang and Negrut).
5
+
6
+ **Project page: <https://uwsbel.github.io/NeDM/>** — figures, and the nine
7
+ side-by-side Chrono rollouts behind the Study Case I result. Its source is
8
+ [`web/`](web/README.md).
9
+
10
+ High-fidelity Chrono trajectories are distilled into a task-specific neural
11
+ reduced dynamics model (NN-ROM); the model is frozen and replicated into a
12
+ vectorized environment where a control policy is trained with PPO; the trained
13
+ policy is then returned to the full Chrono system for closed-loop validation.
14
+
15
+ Two study cases instantiate the pipeline across three control tasks:
16
+
17
+ - **Study Case I** — terrain-aware HMMWV trajectory tracking on rigid, bumpy and
18
+ deformable CRM terrain. A 15-D reduced state carries body motion plus a
19
+ per-wheel terramechanics block; a two-class terrain code resolves the
20
+ rigid-vs-CRM ambiguity. One policy trained inside the conditioned model beats
21
+ both single-terrain specialists on all three terrains, including zero-shot
22
+ bumpy.
23
+ - **Study Case II** — an M113 tracked vehicle with a front-mounted 4-DOF arm,
24
+ driven by two independent tasks. A 3-D planar state serves base goal reaching
25
+ (100/100 goals in Chrono at 0.75 m); an 8-D joint-space state serves arm
26
+ end-effector reaching (97/100 at 0.05 m, zero contacts or joint-limit
27
+ violations), with the end-effector recovered by forward kinematics rather than
28
+ learned.
29
+
30
+ **Follow-on work, not part of the paper:** [`traversing/`](traversing/README.md)
31
+ records an off-road traversing study. A learned route-risk planner picks routes
32
+ across generated hill-and-crater terrain in Chrono, on rigid ground and CRM
33
+ soil, with results that vary by vehicle and ground. Separately, a route tracker
34
+ trained with PPO inside a learned reduced dynamics model is compared with PID:
35
+ it tracks routes more closely on rigid ground but completes fewer routes on
36
+ soil. The folder records milestones, evidence and limits through 2026-09-28.
37
+ The study's data and models are in the `traversing/` folder of the Hugging Face
38
+ dataset; its training and evaluation code is in `src/nedm/traversing/`.
39
+
40
+ **Follow-on work, not part of the paper:** [`contact_nrd/`](contact_nrd/README.md)
41
+ extends neural reduced dynamics (NRD) to contacts that start and stop: a bouncing ball, two pool balls,
42
+ an SO101 arm that pushes a T, and a Unitree G1 humanoid that a frozen walking policy drives in MuJoCo.
43
+ A core network, a collision network and a contact network, with one design for all four cases, predict
44
+ each 20 ms step. The first three cases share one training config; G1 has its own. The data, test sets
45
+ and trained models are in the `contact_nrd/` folder of the Hugging Face dataset; the code is in
46
+ `src/nedm/contact_nrd/`.
47
+
48
+ **Follow-on work, not part of the paper:** [`so101_push_rl/`](so101_push_rl/README.md)
49
+ trains one PPO policy inside a contact NRD of the SO101 arm and the T, then
50
+ checks it in Chrono: it pushes the T to small and large translation and rotation
51
+ goals (82–96 % of the sealed test goals of each trained goal type). The NRD, its
52
+ training data, the RL inputs, the policies and the Chrono evaluations are in the
53
+ `so101_push_rl/` folder of the Hugging Face dataset; the code is in
54
+ `src/nedm/so101_push_rl/`, `scripts/so101_push_rl/` and `configs/so101_push_rl/`.
55
+
56
+ **Follow-on work, not part of the paper:** [`g1_footstep_rl/`](g1_footstep_rl/README.md)
57
+ trains a footstep policy with PPO inside the G1 contact NRD, then checks it in MuJoCo. The policy sets
58
+ the velocity command of the frozen walking policy (HOMIE) so that the feet land on given footprints, on
59
+ a flat floor and on planks with gaps: it completes 92–100 % of the development courses of each course
60
+ type, a hand-written footstep controller 0–28 %. The policies, RL inputs, MuJoCo results and videos are
61
+ in the `g1_footstep_rl/` folder of the Hugging Face dataset; the code is in `src/nedm/g1_footstep_rl/`,
62
+ `scripts/g1_footstep_rl/` and `configs/g1_footstep_rl/`.
63
+
64
+ **Follow-on work, not part of the paper:** [`so101_pick_place/`](so101_pick_place/README.md)
65
+ trains a camera policy for a real SO101 arm only inside a contact NRD of the arm and a cube: a state
66
+ teacher with PPO, then a camera student with online DAgger on ray-traced images of a calibrated copy of
67
+ the real scene. With no real image in training, the student placed the cube on the plate in 36 of 50
68
+ episodes of a stress test on the real arm (72 %; 95 % interval 58–83 %). The NRD, its data and sealed
69
+ test set, every teacher and student checkpoint, the robot bundle, the robot logs and videos are in the
70
+ `so101_pick_place/` folder of the Hugging Face dataset; the code is in `src/nedm/so101_policy/`,
71
+ `src/nedm/render/`, `src/nedm/contact_nrd/collect/`, `scripts/so101_pick_place/` and `scripts/so101_policy/`.
72
+
73
+ **[docs/progress.md](docs/progress.md) is the reproduction record** — every stage
74
+ output with the artifact that produced it and the command that regenerates it.
75
+ Start there.
76
+
77
+ ## Environment
78
+
79
+ ```bash
80
+ conda env create -f environment.nedm.yml
81
+ conda activate nedm
82
+ git lfs install && git lfs pull
83
+ ```
84
+
85
+ `environment.nedm.yml` (env `nedm`, pychrono 10.0.0 from the `projectchrono`
86
+ channel) is what everything runs in: data collection, training, RL, and
87
+ Chrono-backed evaluation. `environment.yml` (env `tutorial`, pychrono 9.0.1) and
88
+ `environment.lock.yml` are retained for the earliest datasets, which were
89
+ collected under it.
90
+
91
+ Project Chrono itself is a local dependency, not vendored — collection configs
92
+ expect a checkout at `chrono/` and read `chrono/data` for vehicle assets.
93
+
94
+ ## Layout
95
+
96
+ Code, scripts and configs are grouped by study. `core` holds what both paper studies share.
97
+
98
+ | Path | Contents |
99
+ |---|---|
100
+ | `src/nedm/core/` | Shared by both paper studies: preprocessing, the causal-transformer dynamics model and the trainer with rollout-based checkpoint selection (`training/`); the frozen NN-ROM loader and default paths (`rl/`); the scenario generator, the Hugging Face release helpers and the Blender export |
101
+ | `src/nedm/hmmwv/` | Study Case I: HMMWV scene builders and data collectors (`hmmwv_data`, `hmmwv_crm`); the vectorized NN-ROM tracking environment, its Chrono-backed twins and the reference sets (`rl/`) |
102
+ | `src/nedm/tracked_arm/` | Study Case II: M113 and arm data collectors (`tracked_vehicle_data`, `arm_data`); the 4-DOF gripper arm imported from SolidWorks (`arm_model/`); the goal and arm environments, arm forward kinematics and the clearance shield (`rl/`) |
103
+ | `src/nedm/traversing/` | Traversing study code: model training (`training/`) and the Chrono evaluation class (`evaluation/`) |
104
+ | `src/nedm/contact_nrd/` | Contact NRD: the three networks, training, test scores and the data download |
105
+ | `src/nedm/so101_push_rl/` | SO101 push-T PPO inside the contact NRD: the NRD environment, action decoder, arm kinematics, reward and rules |
106
+ | `src/nedm/g1_footstep_rl/` | G1 footstep PPO inside the contact NRD: courses and scorer, the NRD environment, the HOMIE copy, leg kinematics, the MuJoCo scene and runner, the hand-written footstep baseline (H-FS) |
107
+ | `configs/hmmwv/`, `configs/tracked_arm/` | Collection and training configs |
108
+ | `configs/contact_nrd/` | Training configs of the contact NRD (one for the first three cases, one for G1) and the G1 evaluation block |
109
+ | `configs/so101_push_rl/` | Environment config, the two PPO curricula and the arm and T settings |
110
+ | `configs/g1_footstep_rl/` | Environment config, PPO curriculum, MuJoCo scene and HOMIE sources of the G1 footstep study |
111
+ | `traversing/` | Traversing study documents, results and release manifest |
112
+ | `contact_nrd/` | Contact NRD design, results, the four study cases, the G1 data format and release manifest |
113
+ | `so101_push_rl/` | SO101 push-T PPO study: results, the NRD it used and release manifest |
114
+ | `g1_footstep_rl/` | G1 footstep PPO study: results, training, the NRD and HOMIE, release manifest |
115
+ | `artifacts/` | Checkpoints, run metadata and Chrono evaluation output (datasets are on Hugging Face, see below) |
116
+
117
+ `scripts/` is organised by study (`core/`, `hmmwv/`, `tracked_arm/`, `traversing/`, `so101_push_rl/`,
118
+ `g1_footstep_rl/`), then by pipeline stage, in the order you would run them:
119
+
120
+ | Path | Contents |
121
+ |---|---|
122
+ | `scripts/hmmwv/collection/` | Shard planners and Chrono collectors for the flat, bumpy and CRM datasets, plus their validators and small-scale smoke tests |
123
+ | `scripts/tracked_arm/collection/` | The M113 drive collector (the arm collector is `python -m nedm.tracked_arm.arm_data`) |
124
+ | `scripts/core/preprocess/` | Raw episodes → processed caches (all three dynamics models) |
125
+ | `scripts/hmmwv/preprocess/`, `scripts/tracked_arm/preprocess/` | RL reference-set builders; arm FK geometry extraction |
126
+ | `scripts/core/training/` | The dynamics trainer (all three dynamics models) |
127
+ | `scripts/hmmwv/training/`, `scripts/tracked_arm/training/` | The three PPO trainers, and the launchers holding each run's exact hyperparameters |
128
+ | `scripts/hmmwv/ablations/`, `scripts/tracked_arm/ablations/` | Config generation, sweep runners and ranking for Appendices C–E and the specialist comparison; the arm q-input probe |
129
+ | `scripts/core/evaluation/` | Open-loop rollout eval of a dynamics checkpoint |
130
+ | `scripts/hmmwv/evaluation/`, `scripts/tracked_arm/evaluation/` | Chrono closed-loop transfer, open-loop arm eval, and the seeded 100-goal benchmarks |
131
+ | `scripts/hmmwv/figures/`, `scripts/tracked_arm/figures/` | The eleven generators behind the manuscript's plotted figures, plus the Blender renderers |
132
+ | `scripts/core/throughput/`, `scripts/hmmwv/throughput/` | Chrono and NN-ROM throughput probes (Appendix A) and the context-truncation sweep |
133
+ | `scripts/hmmwv/cluster/`, `scripts/tracked_arm/cluster/` | SLURM array jobs for the collections that only run at cluster scale |
134
+ | `scripts/so101_push_rl/` | The SO101 push-T PPO trainer and `reproduce.sh` (download, training, NRD validation) |
135
+ | `scripts/g1_footstep_rl/` | The G1 footstep PPO trainer, the MuJoCo evaluation, the H-FS parameter search, the bank builders, the HOMIE fetch and `reproduce.sh` |
136
+ | `scripts/hmmwv/validation/` | Chrono validation harnesses for the tire-force channels (not a unit-test suite) |
137
+ | `scripts/core/release/` | The Hugging Face dataset release: raw CSV → Parquet export, validation, upload, and the download/rehydrate helper |
138
+ | `scripts/traversing/` | The traversing study's result recount (`analysis/`) and release download/verification (`release/`) |
139
+
140
+ Every script under `scripts/core/`, `scripts/hmmwv/` and `scripts/tracked_arm/` reproduces something the paper
141
+ reports; nothing else is kept. The ablation *artifacts* and *configs* keep their original `ablation_ofat` name
142
+ because it is recorded inside the run metadata.
143
+
144
+ The paper was produced with the earlier stage-first layout (`scripts/<stage>/`, `src/nedm/{training,rl}/`,
145
+ `src/arm_model/`, `test/`, `blender-render/`). That layout is kept at the GitHub tag
146
+ [`paper-v1`](https://github.com/uwsbel/NeDM/tree/paper-v1); the Hugging Face dataset card
147
+ (`docs/hf_dataset_card.md`, mirrored on the Hub) still names its paths.
148
+
149
+ ## Datasets
150
+
151
+ All five datasets the paper's dynamics models train on are published at
152
+ **<https://huggingface.co/datasets/harryzhang1018/NeDM>** (70 GB: every recorded channel as
153
+ float32 Parquet plus the four processed training caches; the dataset card documents schemas,
154
+ splits and provenance). Nothing needs to be re-collected:
155
+
156
+ ```bash
157
+ conda activate nedm
158
+ # the exact .npy caches the deployed models trained on -> artifacts/training_datasets/
159
+ PYTHONPATH=src python scripts/core/release/download_nedm_datasets.py --dataset all --no-raw --processed
160
+ # a raw dataset as the collectors' per-episode CSV tree -> artifacts/datasets/ (preprocess etc. run unchanged)
161
+ PYTHONPATH=src python scripts/core/release/download_nedm_datasets.py --dataset tracked --rehydrate
162
+ ```
163
+
164
+ `docs/hf_dataset_card.md` is the source of the Hub README; `scripts/core/release/export_hf_dataset.py`
165
+ + `validate_hf_export.py` + `upload_hf_dataset.sh` regenerate and publish the release.
166
+
167
+ ## Quick start
168
+
169
+ Collect a small dataset, build its cache, and train:
170
+
171
+ ```bash
172
+ conda activate nedm
173
+ python scripts/hmmwv/collection/collect_hmmwv_dataset.py --config configs/hmmwv/hmmwv_overfit_v1.json
174
+ python scripts/core/preprocess/build_hmmwv_training_dataset.py --help
175
+ PYTHONPATH=src python scripts/core/training/train_hmmwv_dynamics.py \
176
+ --config configs/hmmwv/hmmwv_transformer_v07_tire_normal_force_omega_300g_crm2000_mix25_rebal_rollout_onehot.json
177
+ ```
178
+
179
+ The full flat collection is cluster-scale (~305 GB of CSV; download it from Hugging Face
180
+ instead, see above); `scripts/hmmwv/cluster/collect_hmmwv_tire300g.sh` is the job that produced it and
181
+ `scripts/hmmwv/collection/smoke_test_hmmwv_bumpy10g.sh` rehearses the same path at small scale.
182
+
183
+ Evaluate a trained policy back in Chrono:
184
+
185
+ ```bash
186
+ PYTHONPATH=src python scripts/hmmwv/evaluation/eval_hmmwv_rl_chrono_tracking.py --help # Study Case I
187
+ PYTHONPATH=src python scripts/tracked_arm/evaluation/benchmark_tracked_goal_chrono.py --help # Study Case II, base
188
+ PYTHONPATH=src python scripts/tracked_arm/evaluation/benchmark_arm_reach_chrono.py --help # Study Case II, arm
189
+ ```
190
+
191
+ ## Further reading
192
+
193
+ - [docs/model_checkpoints.md](docs/model_checkpoints.md) — the deployed checkpoints and how to load them
194
+ - [docs/data_collection_pipeline.md](docs/data_collection_pipeline.md), [docs/hmmwv_crm_data_collection_pipeline.md](docs/hmmwv_crm_data_collection_pipeline.md) — collection design
195
+ - [docs/hmmwv_training_pipeline.md](docs/hmmwv_training_pipeline.md), [docs/rl_tracking.md](docs/rl_tracking.md) — Study Case I
196
+ - [docs/arm-dyn-model.md](docs/arm-dyn-model.md), [docs/arm-reaching-rl-plan.md](docs/arm-reaching-rl-plan.md), [docs/tracked_vehicle_nn_rom_rl_plan.md](docs/tracked_vehicle_nn_rom_rl_plan.md) — Study Case II
197
+ - [docs/ablation_ofat_plan.md](docs/ablation_ofat_plan.md) — the ablation protocol
198
+ - [deep-research-report-vehicle.md](deep-research-report-vehicle.md) — background survey on learned vehicle dynamics
so101_pick_place/code/REPRODUCE.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SO101 pick-and-place source release
2
+
3
+ The study implementation, configs, requirements, full study README and original data manifest live here.
4
+ The NeDM pull request keeps the results and pinned links. Source commit: `9363774e428a844540c525d3a6458beeb3e39e4d`; base: `dacc64968c006340393f60e7f1e15a2b65fc4aa7`.
5
+ The 95 browsable source files retain their original paths and bytes. `source.tar.gz` contains the same files,
6
+ including executable modes, and `source_manifest.json` records their sizes, SHA-256 values and Git modes.
7
+
8
+ ## Restore the study checkout
9
+
10
+ Use the pinned download and checksum command in the NeDM study's
11
+ [results README](https://github.com/uwsbel/NeDM/blob/so101-pick-place/so101_pick_place/README.md).
12
+ It downloads this archive at the exact `code.hf_revision` of the compact GitHub release manifest.
13
+ Then, from the directory containing the downloaded `source.tar.gz`:
14
+
15
+ ```bash
16
+ GIT_LFS_SKIP_SMUDGE=1 git clone --no-checkout https://github.com/uwsbel/NeDM.git so101-study
17
+ cd so101-study
18
+ GIT_LFS_SKIP_SMUDGE=1 git checkout --detach dacc64968c006340393f60e7f1e15a2b65fc4aa7
19
+ tar -xzf ../source.tar.gz --strip-components=1
20
+ git fetch origin so101-pick-place-study
21
+ ```
22
+
23
+ The base checkout supplies the existing NeDM contact-NRD model, training and evaluation code. The overlay supplies
24
+ the whole study implementation, so it must be unpacked at the repository root. Git history is needed for the NRD
25
+ retraining and equivalence steps; the historical study branch remains available for those steps.
26
+
27
+ Read `so101_pick_place/README.md` in the restored checkout for the complete training chain, original validation,
28
+ dependencies, deployment instructions and limitations. Install the GPU's torch/torchvision build, then this
29
+ study's `requirements-so101-pick-place.txt`. Use `bash` to invoke scripts downloaded individually from the Hub,
30
+ because Hub downloads do not preserve executable permissions; the tar archive does preserve them.
31
+
32
+ ```bash
33
+ bash scripts/so101_pick_place/reproduce.sh --help
34
+ bash scripts/so101_pick_place/reproduce.sh full --steps download,robot
35
+ bash scripts/so101_pick_place/reproduce.sh full --steps download,nrd_test
36
+ ```
37
+
38
+ The `robot` step above only rebuilds result tables from archived logs. Training and live robot operation are
39
+ separate steps described in the full study README. The source archive preserves the original pinned data revision
40
+ `dcb873bc5da3da8ad5abdec6137c77ef46038f43`; existing datasets, checkpoints, logs and videos are unchanged.
41
+
42
+ The archived README and source comments describe the original code release. For current NeDM repository contents,
43
+ use the results README linked above. Some older stages are recipe-only reruns, as documented there and in the
44
+ full README; this source release does not change that limitation.
so101_pick_place/code/configs/contact_nrd/collection/so101_grasp.json ADDED
@@ -0,0 +1,344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "so101_grasp",
3
+ "source_manifest": "contact_nrd/so101_grasp/source_manifest.json",
4
+ "record_step_s": 0.01,
5
+ "control_step_s": 0.02,
6
+ "model_step_s": 0.02,
7
+ "records_per_episode": 601,
8
+ "target_time_s": 4.0,
9
+ "warmup_s": 0.3,
10
+ "physics": {
11
+ "timestep_s": 0.0005,
12
+ "integrator": "implicitfast",
13
+ "cone": "elliptic",
14
+ "impratio": 10.0,
15
+ "solver": "newton",
16
+ "iterations": 100,
17
+ "ls_iterations": 50,
18
+ "tolerance": 1e-10,
19
+ "noslip_iterations": 0
20
+ },
21
+ "tight_solver": {
22
+ "iterations": 200,
23
+ "ls_iterations": 100,
24
+ "tolerance": 1e-12
25
+ },
26
+ "convergence": {
27
+ "master_seed": 20261085,
28
+ "episodes": {
29
+ "nominal": 16,
30
+ "off_centre": 4,
31
+ "one_sided": 4,
32
+ "near_miss": 4,
33
+ "weak_closure": 8,
34
+ "drop": 8,
35
+ "push": 4,
36
+ "free_arm": 2,
37
+ "cube_flight": 32,
38
+ "cube_table": 8,
39
+ "jaw_fixed": 8,
40
+ "jaw_moving": 8
41
+ }
42
+ },
43
+ "table": {
44
+ "center_xy_m": [
45
+ 0.25,
46
+ 0.0
47
+ ],
48
+ "size_xy_m": [
49
+ 1.2,
50
+ 1.2
51
+ ],
52
+ "thickness_m": 0.04,
53
+ "friction": [
54
+ 0.5,
55
+ 0.005,
56
+ 0.0001
57
+ ],
58
+ "condim": 3,
59
+ "solref": [
60
+ 0.005,
61
+ 1.0
62
+ ],
63
+ "solimp": [
64
+ 0.9,
65
+ 0.95,
66
+ 0.001,
67
+ 0.5,
68
+ 2.0
69
+ ],
70
+ "edge_margin_m": 0.05
71
+ },
72
+ "cube": {
73
+ "size_m": 0.03,
74
+ "mass_kg": 0.03,
75
+ "friction": [
76
+ 0.5,
77
+ 0.005,
78
+ 0.0001
79
+ ],
80
+ "condim": 3,
81
+ "solref": [
82
+ 0.005,
83
+ 1.0
84
+ ],
85
+ "solimp": [
86
+ 0.9,
87
+ 0.95,
88
+ 0.001,
89
+ 0.5,
90
+ 2.0
91
+ ],
92
+ "park_xy_m": [
93
+ 0.7,
94
+ 0.45
95
+ ]
96
+ },
97
+ "contact_threshold_n": 0.01,
98
+ "visual_overlap": {
99
+ "threshold_m": 0.001,
100
+ "grid_m": 0.0005,
101
+ "point_spacing_m": 0.002,
102
+ "cube_points_per_edge": 11
103
+ },
104
+ "joint_target_margin_rad": 0.05,
105
+ "palm_geoms": [
106
+ "gripper_collision0",
107
+ "fixed_jaw_box1",
108
+ "fixed_jaw_box2",
109
+ "moving_jaw_box1"
110
+ ],
111
+ "grasp_point_m": [
112
+ 0.0105,
113
+ 0.0,
114
+ -0.092
115
+ ],
116
+ "workspace": {
117
+ "pan_axis_xy_m": [
118
+ 0.0388,
119
+ 0.0
120
+ ],
121
+ "r_m": [
122
+ 0.15,
123
+ 0.27
124
+ ],
125
+ "angle_deg": [
126
+ -75,
127
+ 75
128
+ ]
129
+ },
130
+ "throw_region": {
131
+ "x_m": [
132
+ 0.45,
133
+ 0.7
134
+ ],
135
+ "y_m": [
136
+ -0.35,
137
+ 0.35
138
+ ]
139
+ },
140
+ "speed_rad_s": {
141
+ "arm": [
142
+ 1.0,
143
+ 2.0
144
+ ],
145
+ "jaw": 4.5,
146
+ "arm_max": 3.0
147
+ },
148
+ "ik": {
149
+ "position_tol_m": 0.0005,
150
+ "angle_tol_deg": 2.0
151
+ },
152
+ "workers": 6,
153
+ "campaigns": {
154
+ "pilot": {
155
+ "master_seed": 20261008,
156
+ "task_scale": 1.0,
157
+ "probe_scale": 1.0,
158
+ "note": "512 task episodes and the probes the coverage targets need; splits 0/1 by family"
159
+ },
160
+ "production": {
161
+ "master_seed": 20261021,
162
+ "task_scale": 35.15625,
163
+ "probe_scale": 10.0,
164
+ "note": "18,000 task episodes (nominal and difficult in the pilot ratio) and the probes at 10 times their pilot counts; splits 0/1, 90/10 inside each family: 16,197 + 1,803 task and 9,450 + 1,050 probe episodes"
165
+ },
166
+ "test": {
167
+ "master_seed": 20261034,
168
+ "task_scale": 3.90625,
169
+ "probe_scale": 1.0,
170
+ "note": "sealed test: 2,000 task episodes and the probes at their pilot counts; all split 2"
171
+ },
172
+ "extra": {
173
+ "master_seed": 20261123,
174
+ "task_scale": 70.3125,
175
+ "probe_scale": 1.0,
176
+ "note": "supplementary training data (2026-10-10): twice the production count of each task family (collect with --families for the hard ones); all split 0, so the production validation episodes stay the validation set"
177
+ },
178
+ "noisy_v1": {
179
+ "master_seed": 20261147,
180
+ "task_scale": 1.0,
181
+ "probe_scale": 1.0,
182
+ "families": [
183
+ "noisy_nominal",
184
+ "noisy_off_centre",
185
+ "noisy_carry",
186
+ "noisy_offset"
187
+ ],
188
+ "note": "NRD data round of the SO101 policy study (2026-10-11): scripted plans with policy-like commands (OU noise on the 5 arm targets, stationary std 5-20 mrad, time constant 0.1-0.4 s, a constant jaw-target offset of +-30 mrad, rate-limited like the data) and grasp-point targets 1-8 mm off the cube centre; 10,000 task episodes, splits 0/1 90/10 inside each family. Master seed new (not pilot, production, test 20261034, convergence, extra, critic noise 20261011)"
189
+ }
190
+ },
191
+ "families": [
192
+ {
193
+ "name": "nominal",
194
+ "group": "nominal",
195
+ "select": true,
196
+ "episodes": 320,
197
+ "records": 601,
198
+ "note": "approach, descend, close, lift to a random height, hold, move while holding (half), lower, release, retreat"
199
+ },
200
+ {
201
+ "name": "off_centre",
202
+ "group": "difficult",
203
+ "select": true,
204
+ "episodes": 32,
205
+ "records": 601,
206
+ "note": "grasp offset along the jaw width, the closing axis and the height; the cube can turn or slip in the grasp"
207
+ },
208
+ {
209
+ "name": "one_sided",
210
+ "group": "difficult",
211
+ "select": true,
212
+ "episodes": 32,
213
+ "records": 601,
214
+ "note": "only one jaw touches the cube on the table: a fixed-jaw side push, a moving-jaw swat or a fingertip tap"
215
+ },
216
+ {
217
+ "name": "near_miss",
218
+ "group": "difficult",
219
+ "select": true,
220
+ "episodes": 32,
221
+ "records": 601,
222
+ "note": "the jaws close 15-35 mm off the cube centre: an edge graze or nothing; lift, lower, release"
223
+ },
224
+ {
225
+ "name": "weak_closure",
226
+ "group": "difficult",
227
+ "select": true,
228
+ "episodes": 32,
229
+ "records": 601,
230
+ "note": "the jaw target is set at the measured contact angle plus a small opening; fast lift and shake; slip or drop"
231
+ },
232
+ {
233
+ "name": "drop",
234
+ "group": "difficult",
235
+ "select": true,
236
+ "episodes": 32,
237
+ "records": 601,
238
+ "note": "grasp and lift, then the jaw opens in the air: cube flight, table impact and tumbling"
239
+ },
240
+ {
241
+ "name": "push",
242
+ "group": "difficult",
243
+ "select": true,
244
+ "episodes": 32,
245
+ "records": 601,
246
+ "note": "closed jaws lowered beside the cube push it across the table"
247
+ },
248
+ {
249
+ "name": "free_arm",
250
+ "group": "probe",
251
+ "select": false,
252
+ "episodes": 100,
253
+ "records": 601,
254
+ "note": "random joint-space motion of the arm; the cube rests out of reach"
255
+ },
256
+ {
257
+ "name": "cube_flight",
258
+ "group": "probe",
259
+ "select": false,
260
+ "episodes": 650,
261
+ "records": 101,
262
+ "note": "cube thrown upwards above the table (1-2.2 m/s, spin up to 25 rad/s, landings up to about 2.6 m/s): flight, impacts, tumbling until it rests (1 s); the arm moves freely"
263
+ },
264
+ {
265
+ "name": "cube_table",
266
+ "group": "probe",
267
+ "select": false,
268
+ "episodes": 100,
269
+ "records": 101,
270
+ "note": "cube released just above the table with sliding velocity and spin: impacts, sliding, settling (1 s)"
271
+ },
272
+ {
273
+ "name": "jaw_fixed",
274
+ "group": "probe",
275
+ "select": false,
276
+ "episodes": 100,
277
+ "records": 201,
278
+ "note": "cube released just above the fixed jaw's inner face (held up, sloped along the finger), in the air; it rests or slides, then a fast arm move tips the face over: the cube falls to the table (or onto the arm base, which ends the episode) or stays on the gripper against a palm block"
279
+ },
280
+ {
281
+ "name": "jaw_moving",
282
+ "group": "probe",
283
+ "select": false,
284
+ "episodes": 100,
285
+ "records": 201,
286
+ "note": "cube released just above the moving jaw's inner face (held up, sloped along the finger), in the air; it rests or slides, then a fast arm move tips the face over: the cube falls to the table (or onto the arm base, which ends the episode) or stays on the gripper against a palm block"
287
+ },
288
+ {
289
+ "name": "step_arm",
290
+ "group": "probe",
291
+ "select": false,
292
+ "episodes": 3000,
293
+ "records": 201,
294
+ "note": "step commands of the arm joints and the jaw (held 0.1-0.6 s), servo saturation without contact; the cube rests out of reach (2 s). Only in campaign extra. The 2026-10-10 collection drew targets 0.05 rad inside the limits (15 % of its episodes passed a limit by up to 33 mrad); the code now keeps 0.12 rad",
295
+ "campaigns": [
296
+ "extra"
297
+ ]
298
+ },
299
+ {
300
+ "name": "noisy_nominal",
301
+ "group": "noisy",
302
+ "select": true,
303
+ "episodes": 2500,
304
+ "records": 601,
305
+ "campaigns": [
306
+ "noisy_v1"
307
+ ],
308
+ "note": "the nominal script (grasp at the cube centre, lift, hold, move while holding (half), lower, release, retreat); then policy-like commands: OU noise on the 5 arm targets (stationary std U(5, 20) mrad, time constant U(0.1, 0.4) s, per episode, independent per joint, from 0), a constant jaw-target offset U(-30, 30) mrad, clipped to the target range and rate-limited to 0.06 rad (arm) and 0.09 rad (jaw) per 20 ms (noisy_commands). Campaign noisy_v1 only"
309
+ },
310
+ {
311
+ "name": "noisy_off_centre",
312
+ "group": "noisy",
313
+ "select": true,
314
+ "episodes": 1500,
315
+ "records": 601,
316
+ "campaigns": [
317
+ "noisy_v1"
318
+ ],
319
+ "note": "the off_centre script (grasp offset 4-12 mm along the jaw width, +-3 mm along the closing axis, 0-12 mm higher); then policy-like commands: OU noise on the 5 arm targets (stationary std U(5, 20) mrad, time constant U(0.1, 0.4) s, per episode, independent per joint, from 0), a constant jaw-target offset U(-30, 30) mrad, clipped to the target range and rate-limited to 0.06 rad (arm) and 0.09 rad (jaw) per 20 ms (noisy_commands). Campaign noisy_v1 only"
320
+ },
321
+ {
322
+ "name": "noisy_carry",
323
+ "group": "noisy",
324
+ "select": true,
325
+ "episodes": 3000,
326
+ "records": 601,
327
+ "campaigns": [
328
+ "noisy_v1"
329
+ ],
330
+ "note": "carry and place: the nominal script with the move while holding always drawn (realised when it fits in 6 s and is reachable); then policy-like commands: OU noise on the 5 arm targets (stationary std U(5, 20) mrad, time constant U(0.1, 0.4) s, per episode, independent per joint, from 0), a constant jaw-target offset U(-30, 30) mrad, clipped to the target range and rate-limited to 0.06 rad (arm) and 0.09 rad (jaw) per 20 ms (noisy_commands). Campaign noisy_v1 only"
331
+ },
332
+ {
333
+ "name": "noisy_offset",
334
+ "group": "noisy",
335
+ "select": true,
336
+ "episodes": 3000,
337
+ "records": 601,
338
+ "campaigns": [
339
+ "noisy_v1"
340
+ ],
341
+ "note": "the nominal script with the grasp-point target 1-8 mm off the cube centre in a random horizontal direction (policy-like imprecision); then policy-like commands: OU noise on the 5 arm targets (stationary std U(5, 20) mrad, time constant U(0.1, 0.4) s, per episode, independent per joint, from 0), a constant jaw-target offset U(-30, 30) mrad, clipped to the target range and rate-limited to 0.06 rad (arm) and 0.09 rad (jaw) per 20 ms (noisy_commands). Campaign noisy_v1 only"
342
+ }
343
+ ]
344
+ }
so101_pick_place/code/configs/so101_pick_place/calib_v1.json ADDED
@@ -0,0 +1,1526 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "calib_v1",
3
+ "joint_map": {
4
+ "names": [
5
+ "shoulder_pan",
6
+ "shoulder_lift",
7
+ "elbow_flex",
8
+ "wrist_flex",
9
+ "wrist_roll",
10
+ "gripper"
11
+ ],
12
+ "sign": [
13
+ 1,
14
+ 1,
15
+ 1,
16
+ 1,
17
+ 1,
18
+ 1
19
+ ],
20
+ "offset_rad": [
21
+ 0.0,
22
+ -0.03189816653157993,
23
+ -0.14769081483654048,
24
+ -0.019577445234141684,
25
+ -1.3227713329150206,
26
+ 0.0
27
+ ],
28
+ "gripper_lin": [
29
+ 0.022960654771994715,
30
+ -0.1915981705843725
31
+ ],
32
+ "offset_deg": [
33
+ 0.0,
34
+ -1.8276303164649856,
35
+ -8.462060362981891,
36
+ -1.1217049855648262,
37
+ -75.78921463692504,
38
+ 0.0
39
+ ],
40
+ "evidence": "LeRobot 0.6.2 so_follower (use_degrees=True): arm joints in DEGREES mode = (raw - (range_min+range_max)/2) * 360/4095 (no clamping); gripper RANGE_0_100 = (raw - 2033)/(3551 - 2033)*100 (drive_mode 0, 1518 ticks = 133.4 servo deg, 1.334 deg/unit). Signs: pinhole PnP on the 30 resting-cube points for all 32 sign combinations: (pan, lift, elbow, wrist_flex) = (+,+,+,+) rms 3.2-3.3 px; flipping pan puts the camera below the table (z -0.48 m, rms 3.9-4.1); every lift/elbow/wrist_flex flip gives rms >= 16.7 px. wrist_roll sign: full joint fit with roll sign -1 keeps 30 % of the wrist cube and 7 % of the wrist plate observations within 8 px (vs 91 % / 76 % with +1). Offsets: joint bundle adjustment of both cameras with the arm kinematics (lift -1.8, elbow -8.5, wrist_flex -1.1, wrist_roll -75.8 deg; pan fixed 0 = gauge with the scene rotation about the pan axis). Rest pose: the overlay of the mapped folded pose matches the real external images (overlay_external_*). wrist_roll offset ~ -76 deg: with 0 the jaws in the external view open sideways while the real jaws are seen edge-on (evidence_roll_offset_external.png), and the wrist views cannot be fit (wrist cube median error 67 px with the MJCF mount, 2 px with the fitted offset); the calibration homing pose of the roll was probably not the diagram pose. Gripper: the moving-jaw tip in the wrist image (4291 frames) vs gripper value gives 1.30 deg/unit (per-frame fit; 1.32 deg/unit in the joint fit) - close to the 1:1 servo value 1.334; holding plateau g = 13.8 maps to sim jaw 7.2 deg, while the MJCF pads are 30 mm apart at ~9.5 deg (2.3 deg / ~4 mm gap mismatch of the jaw geometry).",
41
+ "alternatives": {
42
+ "flat_table": {
43
+ "note": "same fit with the table tilt held at 0 (only the height free): total robust cost +14 % (43,313 vs 37,866 on ~24,170 residuals); the tilt and the shoulder_lift offset are partly interchangeable",
44
+ "offset_deg": [
45
+ 0.0,
46
+ -3.122641288667537,
47
+ -8.38954493189108,
48
+ -0.7644935735601069,
49
+ -75.66093676419115,
50
+ 0.0
51
+ ],
52
+ "table_plane_coef": [
53
+ -0.008009308889286833,
54
+ -2.1491765199895853e-05,
55
+ 0.009612408187844257
56
+ ]
57
+ },
58
+ "gripper_lin_hold_width": {
59
+ "gripper_lin": [
60
+ 0.022960654771994715,
61
+ -0.15105075691406578
62
+ ],
63
+ "note": "same slope, offset chosen so that the real holding value g = 13.8 maps to the MJCF 30 mm pad gap (9.5 deg)"
64
+ },
65
+ "gripper_lin_servo_slope": {
66
+ "gripper_lin": [
67
+ 0.023282692221604357,
68
+ -0.19964910682461356
69
+ ],
70
+ "note": "1:1 servo slope (1.334 deg/unit), offset matched at g = 25 (the middle of the observed range)"
71
+ }
72
+ }
73
+ },
74
+ "cameras": {
75
+ "external": {
76
+ "model": "opencv_fisheye",
77
+ "width": 640,
78
+ "height": 480,
79
+ "K": [
80
+ 270.9954603103234,
81
+ 261.8734348229722,
82
+ 327.2984559297393,
83
+ 242.2070590246824
84
+ ],
85
+ "D": [
86
+ 0.05934478263356295,
87
+ -0.06552001554295192,
88
+ 0.018633618776505437,
89
+ 0.0
90
+ ],
91
+ "parent": "world",
92
+ "T_parent_cam": [
93
+ 0.31363691894620577,
94
+ -0.4029396077403384,
95
+ 0.46435950260329845,
96
+ 0.36013966124320823,
97
+ -0.9273343294895559,
98
+ 0.05535449661100124,
99
+ -0.08536009286971218
100
+ ],
101
+ "rms_px": 1.2592991515134293,
102
+ "n_points": 380,
103
+ "holdout_rms_px": 2.068731133844219,
104
+ "rms_by_kind": {
105
+ "es": {
106
+ "n": 30,
107
+ "rms": 1.562940528989659,
108
+ "median": 1.351876056710025,
109
+ "p90": 2.1875282323495315
110
+ },
111
+ "ec": {
112
+ "n": 286,
113
+ "rms": 1.2340633600326392,
114
+ "median": 0.7186424447329098,
115
+ "p90": 2.09558948136562
116
+ },
117
+ "ep": {
118
+ "n": 60,
119
+ "rms": 1.1216415671467188,
120
+ "median": 0.810191148406559,
121
+ "p90": 1.6395210247420884
122
+ },
123
+ "em": {
124
+ "n": 4,
125
+ "rms": 2.1386814405510273,
126
+ "median": 1.817326270603266,
127
+ "p90": 2.98687427880641
128
+ },
129
+ "line": {
130
+ "n": 489,
131
+ "rms": 0.372576986624876,
132
+ "median": 0.11467553210897949,
133
+ "p90": 0.3616200999534955
134
+ }
135
+ },
136
+ "holdout_by_kind": {
137
+ "es": {
138
+ "n": 6,
139
+ "rms": 1.7000158762747766,
140
+ "median": 1.706206797407797,
141
+ "p90": 2.1722019728207553
142
+ },
143
+ "ec": {
144
+ "n": 8,
145
+ "rms": 3.147731448080604,
146
+ "median": 2.858126041312958,
147
+ "p90": 4.054635838769286
148
+ },
149
+ "ep": {
150
+ "n": 12,
151
+ "rms": 1.1054724131995697,
152
+ "median": 1.0500067829916078,
153
+ "p90": 1.505015106251997
154
+ }
155
+ },
156
+ "field_of_view_deg": {
157
+ "horizontal": 134.2678287247104,
158
+ "vertical": 103.25719491947129,
159
+ "off_axis_angle_at": {
160
+ "left": 68.8428372260975,
161
+ "right": 65.4249914986129,
162
+ "top": 52.22183194012677,
163
+ "bottom": 51.03536297934451,
164
+ "tl": 85.94877022230551,
165
+ "tr": 83.77159508343836,
166
+ "bl": 85.36151345130384,
167
+ "br": 83.12978831098856
168
+ }
169
+ },
170
+ "monotonic_up_to_deg": 100.0
171
+ },
172
+ "wrist": {
173
+ "model": "opencv_fisheye",
174
+ "width": 640,
175
+ "height": 480,
176
+ "K": [
177
+ 270.3644876253468,
178
+ 269.3012989566298,
179
+ 320.8374595779736,
180
+ 247.34515999152364
181
+ ],
182
+ "D": [
183
+ 0.019374438138353576,
184
+ -0.013656734022638041,
185
+ 0.0,
186
+ 0.0
187
+ ],
188
+ "parent": "camera_mount",
189
+ "T_parent_cam": [
190
+ 0.007351691658097521,
191
+ 0.07103337062823585,
192
+ -0.005855746112084782,
193
+ 0.2150442533481458,
194
+ 0.975426158417913,
195
+ -0.046165552522736186,
196
+ -0.012981538286402914
197
+ ],
198
+ "rms_px": 3.2624611907480996,
199
+ "n_points": 11359,
200
+ "holdout_rms_px": 4.5798765265510655,
201
+ "rms_by_kind": {
202
+ "ws": {
203
+ "n": 2497,
204
+ "rms": 2.1190160729947656,
205
+ "median": 1.4863094104400525,
206
+ "p90": 3.3104130226497133
207
+ },
208
+ "wp": {
209
+ "n": 3468,
210
+ "rms": 2.6963133412348492,
211
+ "median": 2.017160729970648,
212
+ "p90": 4.230368986949722
213
+ },
214
+ "wm": {
215
+ "n": 5379,
216
+ "rms": 3.962202165156834,
217
+ "median": 2.733035025328462,
218
+ "p90": 6.667430097384301
219
+ },
220
+ "wc": {
221
+ "n": 15,
222
+ "rms": 1.4435558030725049,
223
+ "median": 0.36865684647750446,
224
+ "p90": 2.6545733167704513
225
+ }
226
+ },
227
+ "holdout_by_kind": {
228
+ "ws": {
229
+ "n": 504,
230
+ "rms": 6.548088395063642,
231
+ "median": 5.253529952974112,
232
+ "p90": 9.769261065314838
233
+ },
234
+ "wp": {
235
+ "n": 712,
236
+ "rms": 3.604175570470226,
237
+ "median": 2.7215718884717535,
238
+ "p90": 5.6021889074205555
239
+ },
240
+ "wc": {
241
+ "n": 3,
242
+ "rms": 10.083291990676772,
243
+ "median": 11.39883195508622,
244
+ "p90": 12.54352280111784
245
+ },
246
+ "wm": {
247
+ "n": 1213,
248
+ "rms": 4.045053073976811,
249
+ "median": 2.648599720729882,
250
+ "p90": 6.769268538306048
251
+ }
252
+ },
253
+ "field_of_view_deg": {
254
+ "horizontal": 135.3573319369848,
255
+ "vertical": 101.22620821512568,
256
+ "off_axis_angle_at": {
257
+ "left": 67.97759774649298,
258
+ "right": 67.37973419049182,
259
+ "top": 52.276060549439066,
260
+ "bottom": 48.950147665686615,
261
+ "tl": 88.85736878036911,
262
+ "tr": 88.25990251286534,
263
+ "bl": 86.23506804399645,
264
+ "br": 85.65130448187536
265
+ }
266
+ },
267
+ "monotonic_up_to_deg": 100.0
268
+ }
269
+ },
270
+ "time_offset_frames": {
271
+ "external": -1.4277886844891619,
272
+ "wrist": -1.2727768244696938
273
+ },
274
+ "episodes": [
275
+ {
276
+ "dataset": "green_cube_red_plate",
277
+ "episode": 0,
278
+ "cube_start_xyz": [
279
+ 0.2922240844678056,
280
+ -0.08237138900679891,
281
+ -0.001833608455945452
282
+ ],
283
+ "cube_start_yaw_deg": -13.08489835802935,
284
+ "cube_start_yaw_silhouette_deg": 28.07915925002419,
285
+ "plate_xy": [
286
+ 0.25192569147494603,
287
+ 0.1331498858001346
288
+ ],
289
+ "plate_yaw_deg": -1.6740143854602323,
290
+ "grasp_frame": 175,
291
+ "release_frame": 296,
292
+ "cube_end_xyz": [
293
+ 0.24741904110977161,
294
+ 0.1285688428628516,
295
+ 0.007574393866097578
296
+ ],
297
+ "cube_end_yaw_deg": 2.8982100687915704,
298
+ "cube_end_yaw_silhouette_deg": -3.1184593369744107,
299
+ "p_grip": [
300
+ 0.0059446855238881186,
301
+ -0.004504709202517019,
302
+ -0.09322332889544027
303
+ ],
304
+ "n_frames": 454,
305
+ "start_pose_deg": [
306
+ 1.4065934419631958,
307
+ -88.21977996826172,
308
+ 84.57142639160156,
309
+ 57.89011001586914,
310
+ 1.3626374006271362,
311
+ 30.895915985107422
312
+ ],
313
+ "sim_check": {
314
+ "cube_r": 0.2664747873913306,
315
+ "cube_angle_deg": -18.005912319982592,
316
+ "cube_in_annulus": true,
317
+ "plate_r": 0.2512995273677664,
318
+ "plate_angle_deg": 31.995006283950232,
319
+ "plate_in_annulus": true,
320
+ "cube_plate_dist": 0.21925642606822884,
321
+ "dist_in_6_30cm": true,
322
+ "yaw_turn_deg": 11.410883972569117,
323
+ "turn_within_30": true,
324
+ "task_in_sim_distribution": true
325
+ }
326
+ },
327
+ {
328
+ "dataset": "green_cube_red_plate",
329
+ "episode": 1,
330
+ "cube_start_xyz": [
331
+ 0.36177125454191705,
332
+ 0.10925312674967667,
333
+ -0.0008469495547748368
334
+ ],
335
+ "cube_start_yaw_deg": 4.334782135288606,
336
+ "cube_start_yaw_silhouette_deg": 43.08942589811704,
337
+ "plate_xy": [
338
+ 0.2515983620370499,
339
+ 0.13046661958289843
340
+ ],
341
+ "plate_yaw_deg": -0.725114887527873,
342
+ "grasp_frame": 265,
343
+ "release_frame": 438,
344
+ "cube_end_xyz": [
345
+ 0.2521431014955,
346
+ 0.13400820634125934,
347
+ 0.007502277115549797
348
+ ],
349
+ "cube_end_yaw_deg": 4.392105835124141,
350
+ "cube_end_yaw_silhouette_deg": -25.570433378754842,
351
+ "p_grip": [
352
+ 0.006802686869003093,
353
+ 0.0015230349977821786,
354
+ -0.10768474370877577
355
+ ],
356
+ "n_frames": 618,
357
+ "start_pose_deg": [
358
+ 2.549450635910034,
359
+ -88.13186645507812,
360
+ 81.05494689941406,
361
+ 68.87911987304688,
362
+ -0.9230769276618958,
363
+ 31.225296020507812
364
+ ],
365
+ "sim_check": {
366
+ "cube_r": 0.3409496692548047,
367
+ "cube_angle_deg": 18.68939699205513,
368
+ "cube_in_annulus": false,
369
+ "plate_r": 0.24960905775039513,
370
+ "plate_angle_deg": 31.51245064324276,
371
+ "plate_in_annulus": true,
372
+ "cube_plate_dist": 0.11219660654883537,
373
+ "dist_in_6_30cm": true,
374
+ "yaw_turn_deg": -5.059897022816479,
375
+ "turn_within_30": true,
376
+ "task_in_sim_distribution": false
377
+ }
378
+ },
379
+ {
380
+ "dataset": "green_cube_red_plate",
381
+ "episode": 2,
382
+ "cube_start_xyz": [
383
+ 0.24830345776541993,
384
+ -0.0687186101373142,
385
+ 1.6230182825906214e-05
386
+ ],
387
+ "cube_start_yaw_deg": 4.917583034467697,
388
+ "cube_start_yaw_silhouette_deg": -41.88437002726664,
389
+ "plate_xy": [
390
+ 0.25285443485312337,
391
+ 0.13266698860698123
392
+ ],
393
+ "plate_yaw_deg": -2.0603295571042324,
394
+ "grasp_frame": 113,
395
+ "release_frame": 228,
396
+ "cube_end_xyz": [
397
+ 0.2549004415358194,
398
+ 0.12579343252907302,
399
+ 0.00725103408286417
400
+ ],
401
+ "cube_end_yaw_deg": 1.3960516259329552,
402
+ "cube_end_yaw_silhouette_deg": -17.24840737508157,
403
+ "p_grip": [
404
+ 0.006331398171498901,
405
+ -0.0031136446511145772,
406
+ -0.10366927506225715
407
+ ],
408
+ "n_frames": 373,
409
+ "start_pose_deg": [
410
+ -4.131868362426758,
411
+ -88.21977996826172,
412
+ 82.10989379882812,
413
+ 65.18681335449219,
414
+ -4.9670329093933105,
415
+ 32.015811920166016
416
+ ],
417
+ "sim_check": {
418
+ "cube_r": 0.22048570519394511,
419
+ "cube_angle_deg": -18.159854916278015,
420
+ "cube_in_annulus": true,
421
+ "plate_r": 0.25183294253598937,
422
+ "plate_angle_deg": 31.78987085334917,
423
+ "plate_in_annulus": true,
424
+ "cube_plate_dist": 0.20143701440909803,
425
+ "dist_in_6_30cm": true,
426
+ "yaw_turn_deg": -6.977912591571936,
427
+ "turn_within_30": true,
428
+ "task_in_sim_distribution": true
429
+ }
430
+ },
431
+ {
432
+ "dataset": "green_cube_red_plate",
433
+ "episode": 3,
434
+ "cube_start_xyz": [
435
+ 0.18466875758532686,
436
+ 0.04716400265690074,
437
+ 0.00446111621746428
438
+ ],
439
+ "cube_start_yaw_deg": -2.1670829558666895,
440
+ "cube_start_yaw_silhouette_deg": -15.657193476388784,
441
+ "plate_xy": [
442
+ 0.2514778596791974,
443
+ 0.13148083796407223
444
+ ],
445
+ "plate_yaw_deg": -1.3396439474038928,
446
+ "grasp_frame": 149,
447
+ "release_frame": 263,
448
+ "cube_end_xyz": [
449
+ 0.24371158457013986,
450
+ 0.1174070462330751,
451
+ 0.007504414344891259
452
+ ],
453
+ "cube_end_yaw_deg": 0.27668448000747503,
454
+ "cube_end_yaw_silhouette_deg": 5.685983209525148,
455
+ "p_grip": [
456
+ 0.006375063365364854,
457
+ 0.011869139608925073,
458
+ -0.08624019095690287
459
+ ],
460
+ "n_frames": 410,
461
+ "start_pose_deg": [
462
+ 6.769230842590332,
463
+ -88.13186645507812,
464
+ 81.23076629638672,
465
+ 67.82417297363281,
466
+ 4.439560413360596,
467
+ 39.525691986083984
468
+ ],
469
+ "sim_check": {
470
+ "cube_r": 0.15330406904615088,
471
+ "cube_angle_deg": 17.91766779264547,
472
+ "cube_in_annulus": true,
473
+ "plate_r": 0.250038162586152,
474
+ "plate_angle_deg": 31.72501645689727,
475
+ "plate_in_annulus": true,
476
+ "cube_plate_dist": 0.1075768787370497,
477
+ "dist_in_6_30cm": true,
478
+ "yaw_turn_deg": 0.8274390084627967,
479
+ "turn_within_30": true,
480
+ "task_in_sim_distribution": true
481
+ }
482
+ },
483
+ {
484
+ "dataset": "green_cube_red_plate",
485
+ "episode": 4,
486
+ "cube_start_xyz": [
487
+ 0.34814450267731467,
488
+ 0.020158225264894875,
489
+ -0.0019868733547590348
490
+ ],
491
+ "cube_start_yaw_deg": 1.4161929174319425,
492
+ "cube_start_yaw_silhouette_deg": -25.502347522400267,
493
+ "plate_xy": [
494
+ 0.2519098724004053,
495
+ 0.1333224186841573
496
+ ],
497
+ "plate_yaw_deg": -0.7336327571526198,
498
+ "grasp_frame": 129,
499
+ "release_frame": 237,
500
+ "cube_end_xyz": [
501
+ 0.24041476801432177,
502
+ 0.13120653890355088,
503
+ 0.007877852786357796
504
+ ],
505
+ "cube_end_yaw_deg": 17.838345302111094,
506
+ "cube_end_yaw_silhouette_deg": -2.0988315791528294,
507
+ "p_grip": [
508
+ 0.006794340565046262,
509
+ 0.005454148916516266,
510
+ -0.10315095660370299
511
+ ],
512
+ "n_frames": 347,
513
+ "start_pose_deg": [
514
+ 9.670330047607422,
515
+ -87.86813354492188,
516
+ 83.69230651855469,
517
+ 59.82417678833008,
518
+ 12.615385055541992,
519
+ 39.06455993652344
520
+ ],
521
+ "sim_check": {
522
+ "cube_r": 0.3100006054550626,
523
+ "cube_angle_deg": 3.728369308776301,
524
+ "cube_in_annulus": false,
525
+ "plate_r": 0.2513775746527736,
526
+ "plate_angle_deg": 32.030267944957906,
527
+ "plate_in_annulus": true,
528
+ "cube_plate_dist": 0.1485504585545453,
529
+ "dist_in_6_30cm": true,
530
+ "yaw_turn_deg": -2.1498256745845623,
531
+ "turn_within_30": true,
532
+ "task_in_sim_distribution": false
533
+ }
534
+ },
535
+ {
536
+ "dataset": "green_cube_red_plate_1",
537
+ "episode": 0,
538
+ "cube_start_xyz": [
539
+ 0.3362984123885602,
540
+ 0.03362302211608906,
541
+ -0.0013083058566654288
542
+ ],
543
+ "cube_start_yaw_deg": 17.231553510337662,
544
+ "cube_start_yaw_silhouette_deg": 3.4619090812536797,
545
+ "plate_xy": [
546
+ 0.23775179307229014,
547
+ 0.09426941804957464
548
+ ],
549
+ "plate_yaw_deg": -0.8671598522726214,
550
+ "grasp_frame": 227,
551
+ "release_frame": 523,
552
+ "cube_end_xyz": [
553
+ 0.23745046908400183,
554
+ 0.08135624656505,
555
+ 0.007070370607670854
556
+ ],
557
+ "cube_end_yaw_deg": 25.02836142856748,
558
+ "cube_end_yaw_silhouette_deg": 34.94908225053723,
559
+ "p_grip": [
560
+ 0.006871078695017272,
561
+ 0.005258328341525626,
562
+ -0.09552328563980401
563
+ ],
564
+ "n_frames": 721,
565
+ "start_pose_deg": [
566
+ -3.780219793319702,
567
+ -88.13186645507812,
568
+ 86.5054931640625,
569
+ 51.736263275146484,
570
+ 2.3296704292297363,
571
+ 5.731225490570068
572
+ ],
573
+ "sim_check": {
574
+ "cube_r": 0.29939240636651565,
575
+ "cube_angle_deg": 6.44815922199851,
576
+ "cube_in_annulus": false,
577
+ "plate_r": 0.2201557156788913,
578
+ "plate_angle_deg": 25.35301905515907,
579
+ "plate_in_annulus": true,
580
+ "cube_plate_dist": 0.11571266792528355,
581
+ "dist_in_6_30cm": true,
582
+ "yaw_turn_deg": -18.098713362610283,
583
+ "turn_within_30": true,
584
+ "task_in_sim_distribution": false
585
+ }
586
+ },
587
+ {
588
+ "dataset": "green_cube_red_plate_1",
589
+ "episode": 1,
590
+ "cube_start_xyz": [
591
+ 0.24310267523306428,
592
+ 0.03441436148265043,
593
+ 0.002099439797836814
594
+ ],
595
+ "cube_start_yaw_deg": 7.173328412449337,
596
+ "cube_start_yaw_silhouette_deg": -30.695586552993007,
597
+ "plate_xy": [
598
+ 0.2463060534247659,
599
+ -0.06612282182324314
600
+ ],
601
+ "plate_yaw_deg": -1.635638213195314,
602
+ "grasp_frame": 246,
603
+ "release_frame": 485,
604
+ "cube_end_xyz": [
605
+ 0.2451054841944107,
606
+ -0.07432431001874013,
607
+ 0.00393286163497124
608
+ ],
609
+ "cube_end_yaw_deg": -0.5444850378216728,
610
+ "cube_end_yaw_silhouette_deg": 28.35088977874102,
611
+ "p_grip": [
612
+ 0.007171254664335991,
613
+ 0.011681074044125066,
614
+ -0.09421128301367335
615
+ ],
616
+ "n_frames": 667,
617
+ "start_pose_deg": [
618
+ 6.769230842590332,
619
+ -88.21977996826172,
620
+ 84.04395294189453,
621
+ 68.35164642333984,
622
+ 2.9450550079345703,
623
+ 0.7246376872062683
624
+ ],
625
+ "sim_check": {
626
+ "cube_r": 0.20718091462208935,
627
+ "cube_angle_deg": 9.561593615070922,
628
+ "cube_in_annulus": true,
629
+ "plate_r": 0.21778656931452442,
630
+ "plate_angle_deg": -17.674734843066297,
631
+ "plate_in_annulus": true,
632
+ "cube_plate_dist": 0.10058820437268931,
633
+ "dist_in_6_30cm": true,
634
+ "yaw_turn_deg": -8.80896662564465,
635
+ "turn_within_30": true,
636
+ "task_in_sim_distribution": true
637
+ }
638
+ },
639
+ {
640
+ "dataset": "green_cube_red_plate_1",
641
+ "episode": 2,
642
+ "cube_start_xyz": [
643
+ 0.32817551420492297,
644
+ -0.08364074027858599,
645
+ -0.003165892909052233
646
+ ],
647
+ "cube_start_yaw_deg": 1.544501346832135,
648
+ "cube_start_yaw_silhouette_deg": 43.80362067343265,
649
+ "plate_xy": [
650
+ 0.3160766805373744,
651
+ 0.04638385584626384
652
+ ],
653
+ "plate_yaw_deg": -6.643819453476887,
654
+ "grasp_frame": 251,
655
+ "release_frame": 452,
656
+ "cube_end_xyz": [
657
+ 0.31606217386098107,
658
+ 0.03924854224960805,
659
+ 0.003434922175829155
660
+ ],
661
+ "cube_end_yaw_deg": 3.729485391724751,
662
+ "cube_end_yaw_silhouette_deg": -11.573424331640126,
663
+ "p_grip": [
664
+ 0.006658822937748594,
665
+ 0.0024152636397525937,
666
+ -0.09584952728272615
667
+ ],
668
+ "n_frames": 625,
669
+ "start_pose_deg": [
670
+ 15.032966613769531,
671
+ -88.30769348144531,
672
+ 80.35164642333984,
673
+ 73.71428680419922,
674
+ 5.406593322753906,
675
+ 1.383399248123169
676
+ ],
677
+ "sim_check": {
678
+ "cube_r": 0.3012207855638675,
679
+ "cube_angle_deg": -16.121343545617613,
680
+ "cube_in_annulus": false,
681
+ "plate_r": 0.28112954247640387,
682
+ "plate_angle_deg": 9.496714017855188,
683
+ "plate_in_annulus": false,
684
+ "cube_plate_dist": 0.1305862832518995,
685
+ "dist_in_6_30cm": true,
686
+ "yaw_turn_deg": -8.188320800309022,
687
+ "turn_within_30": true,
688
+ "task_in_sim_distribution": false
689
+ }
690
+ },
691
+ {
692
+ "dataset": "green_cube_red_plate_1",
693
+ "episode": 3,
694
+ "cube_start_xyz": [
695
+ 0.23693331324341219,
696
+ 0.11404958195243715,
697
+ 0.003786421016462217
698
+ ],
699
+ "cube_start_yaw_deg": 9.509931596053292,
700
+ "cube_start_yaw_silhouette_deg": 1.585706222508179,
701
+ "plate_xy": [
702
+ 0.21896506094674684,
703
+ -0.09300922065067556
704
+ ],
705
+ "plate_yaw_deg": -5.738457255660862,
706
+ "grasp_frame": 275,
707
+ "release_frame": 614,
708
+ "cube_end_xyz": [
709
+ 0.2129822983387097,
710
+ -0.10022411664794635,
711
+ 0.0046268487689335065
712
+ ],
713
+ "cube_end_yaw_deg": -5.3548402780715065,
714
+ "cube_end_yaw_silhouette_deg": 20.468108046783527,
715
+ "p_grip": [
716
+ 0.005881383552392475,
717
+ -0.0003234354715301664,
718
+ -0.08855879013053385
719
+ ],
720
+ "n_frames": 769,
721
+ "start_pose_deg": [
722
+ 12.131868362426758,
723
+ -87.95604705810547,
724
+ 79.82417297363281,
725
+ 75.38461303710938,
726
+ 5.758241653442383,
727
+ 0.7246376872062683
728
+ ],
729
+ "sim_check": {
730
+ "cube_r": 0.2286134662707728,
731
+ "cube_angle_deg": 29.925609736612984,
732
+ "cube_in_annulus": true,
733
+ "plate_r": 0.20275641620425,
734
+ "plate_angle_deg": -27.304795831132388,
735
+ "plate_in_annulus": true,
736
+ "cube_plate_dist": 0.2078369693438379,
737
+ "dist_in_6_30cm": true,
738
+ "yaw_turn_deg": -15.248388851714157,
739
+ "turn_within_30": true,
740
+ "task_in_sim_distribution": true
741
+ }
742
+ },
743
+ {
744
+ "dataset": "green_cube_red_plate_1",
745
+ "episode": 4,
746
+ "cube_start_xyz": [
747
+ 0.21193264031596862,
748
+ -0.10428216999188723,
749
+ 0.0006874141944178958
750
+ ],
751
+ "cube_start_yaw_deg": 5.806186887957097,
752
+ "cube_start_yaw_silhouette_deg": 21.93948538973359,
753
+ "plate_xy": [
754
+ 0.3350434767604382,
755
+ -0.05952046219217152
756
+ ],
757
+ "plate_yaw_deg": -5.146533225050717,
758
+ "grasp_frame": 259,
759
+ "release_frame": 461,
760
+ "cube_end_xyz": [
761
+ 0.3372310339033622,
762
+ -0.07075477507605178,
763
+ 0.0006441606276854188
764
+ ],
765
+ "cube_end_yaw_deg": 18.872738044470168,
766
+ "cube_end_yaw_silhouette_deg": -30.60400972439311,
767
+ "p_grip": [
768
+ 0.006366142270968058,
769
+ 0.0017110546234158633,
770
+ -0.09914164438208337
771
+ ],
772
+ "n_frames": 719,
773
+ "start_pose_deg": [
774
+ 13.362637519836426,
775
+ -87.95604705810547,
776
+ 80.43955993652344,
777
+ 71.69230651855469,
778
+ 3.2087912559509277,
779
+ 0.5928853750228882
780
+ ],
781
+ "sim_check": {
782
+ "cube_r": 0.20211304292646584,
783
+ "cube_angle_deg": -31.061619301920906,
784
+ "cube_in_annulus": true,
785
+ "plate_r": 0.30216366913095627,
786
+ "plate_angle_deg": -11.360463746915734,
787
+ "plate_in_annulus": false,
788
+ "cube_plate_dist": 0.13099575769926322,
789
+ "dist_in_6_30cm": true,
790
+ "yaw_turn_deg": -10.952720113007814,
791
+ "turn_within_30": true,
792
+ "task_in_sim_distribution": false
793
+ }
794
+ },
795
+ {
796
+ "dataset": "green_cube_red_plate_1",
797
+ "episode": 5,
798
+ "cube_start_xyz": [
799
+ 0.3134928060010325,
800
+ -0.05422882329767086,
801
+ -0.0020912052763076873
802
+ ],
803
+ "cube_start_yaw_deg": 8.641153443739185,
804
+ "cube_start_yaw_silhouette_deg": -8.436737907580891,
805
+ "plate_xy": [
806
+ 0.15766258264189403,
807
+ 0.1346439771632627
808
+ ],
809
+ "plate_yaw_deg": -4.384619095841259,
810
+ "grasp_frame": 215,
811
+ "release_frame": 492,
812
+ "cube_end_xyz": [
813
+ 0.16115728431797743,
814
+ 0.12884156858252127,
815
+ 0.010720153062789117
816
+ ],
817
+ "cube_end_yaw_deg": 40.9672705439051,
818
+ "cube_end_yaw_silhouette_deg": -3.4406897443341222,
819
+ "p_grip": [
820
+ 0.006503568456744795,
821
+ 0.00409745151635252,
822
+ -0.09070305582845196
823
+ ],
824
+ "n_frames": 662,
825
+ "start_pose_deg": [
826
+ 11.780220031738281,
827
+ -88.13186645507812,
828
+ 81.05494689941406,
829
+ 73.0988998413086,
830
+ 3.912087917327881,
831
+ 0.7246376872062683
832
+ ],
833
+ "sim_check": {
834
+ "cube_r": 0.2799944694899721,
835
+ "cube_angle_deg": -11.167517729365366,
836
+ "cube_in_annulus": false,
837
+ "plate_r": 0.1796032130521119,
838
+ "plate_angle_deg": 48.562203543461514,
839
+ "plate_in_annulus": true,
840
+ "cube_plate_dist": 0.2448591294318319,
841
+ "dist_in_6_30cm": true,
842
+ "yaw_turn_deg": -13.025772539580444,
843
+ "turn_within_30": true,
844
+ "task_in_sim_distribution": false
845
+ }
846
+ },
847
+ {
848
+ "dataset": "green_cube_red_plate_1",
849
+ "episode": 6,
850
+ "cube_start_xyz": [
851
+ 0.32511099449985625,
852
+ 0.040601883662711995,
853
+ -0.0007728228538362823
854
+ ],
855
+ "cube_start_yaw_deg": 13.573430330752245,
856
+ "cube_start_yaw_silhouette_deg": -37.601592450039334,
857
+ "plate_xy": [
858
+ 0.20170285802793997,
859
+ -0.13275250337582703
860
+ ],
861
+ "plate_yaw_deg": -4.832110736310625,
862
+ "grasp_frame": 235,
863
+ "release_frame": 535,
864
+ "cube_end_xyz": [
865
+ 0.20221573717492425,
866
+ -0.1373753136656336,
867
+ 0.004336639428636529
868
+ ],
869
+ "cube_end_yaw_deg": -10.98473776596893,
870
+ "cube_end_yaw_silhouette_deg": 29.31948243336774,
871
+ "p_grip": [
872
+ 0.006644944584108808,
873
+ 0.006780973739959127,
874
+ -0.09070852660906625
875
+ ],
876
+ "n_frames": 738,
877
+ "start_pose_deg": [
878
+ 7.208791255950928,
879
+ -88.04395294189453,
880
+ 80.0,
881
+ 73.18681335449219,
882
+ 2.4175825119018555,
883
+ 0.7246376872062683
884
+ ],
885
+ "sim_check": {
886
+ "cube_r": 0.2891755496726117,
887
+ "cube_angle_deg": 8.071320666313655,
888
+ "cube_in_annulus": false,
889
+ "plate_r": 0.21014416077117187,
890
+ "plate_angle_deg": -39.177217673241394,
891
+ "plate_in_annulus": true,
892
+ "cube_plate_dist": 0.21279405925208228,
893
+ "dist_in_6_30cm": true,
894
+ "yaw_turn_deg": -18.40554106706287,
895
+ "turn_within_30": true,
896
+ "task_in_sim_distribution": false
897
+ }
898
+ },
899
+ {
900
+ "dataset": "green_cube_red_plate_1",
901
+ "episode": 7,
902
+ "cube_start_xyz": [
903
+ 0.3358569124310158,
904
+ -0.04939976482839293,
905
+ -0.0028167951824430403
906
+ ],
907
+ "cube_start_yaw_deg": 4.948931371879411,
908
+ "cube_start_yaw_silhouette_deg": -34.71620852640831,
909
+ "plate_xy": [
910
+ 0.16382104319681312,
911
+ 0.03666171711010693
912
+ ],
913
+ "plate_yaw_deg": -6.144857392913153,
914
+ "grasp_frame": 250,
915
+ "release_frame": 466,
916
+ "cube_end_xyz": [
917
+ 0.16226090422382297,
918
+ 0.03480294570318543,
919
+ 0.008953120618880534
920
+ ],
921
+ "cube_end_yaw_deg": 6.517096960009326,
922
+ "cube_end_yaw_silhouette_deg": 7.156521236313893,
923
+ "p_grip": [
924
+ 0.006360686653333365,
925
+ 0.0001542840366439142,
926
+ -0.09936972528821529
927
+ ],
928
+ "n_frames": 683,
929
+ "start_pose_deg": [
930
+ 8.263736724853516,
931
+ -88.21977996826172,
932
+ 79.03296661376953,
933
+ 76.79120635986328,
934
+ 5.758241653442383,
935
+ 0.7246376872062683
936
+ ],
937
+ "sim_check": {
938
+ "cube_r": 0.30113642421359244,
939
+ "cube_angle_deg": -9.441730241532468,
940
+ "cube_in_annulus": false,
941
+ "plate_r": 0.13028561986451506,
942
+ "plate_angle_deg": 16.343478076455444,
943
+ "plate_in_annulus": false,
944
+ "cube_plate_dist": 0.19236142798549408,
945
+ "dist_in_6_30cm": true,
946
+ "yaw_turn_deg": -11.093788764792563,
947
+ "turn_within_30": true,
948
+ "task_in_sim_distribution": false
949
+ }
950
+ },
951
+ {
952
+ "dataset": "green_cube_red_plate_1",
953
+ "episode": 8,
954
+ "cube_start_xyz": [
955
+ 0.22600836460100854,
956
+ 0.13419560045529497,
957
+ 0.004554138786007456
958
+ ],
959
+ "cube_start_yaw_deg": 9.655842462625984,
960
+ "cube_start_yaw_silhouette_deg": -10.124904042255366,
961
+ "plate_xy": [
962
+ 0.1877809533535277,
963
+ -0.08890757867773201
964
+ ],
965
+ "plate_yaw_deg": -5.147258848310777,
966
+ "grasp_frame": 238,
967
+ "release_frame": 414,
968
+ "cube_end_xyz": [
969
+ 0.18693319596072389,
970
+ -0.0916222193040863,
971
+ 0.005733243034075623
972
+ ],
973
+ "cube_end_yaw_deg": -3.2933907345142046,
974
+ "cube_end_yaw_silhouette_deg": 11.907414960267488,
975
+ "p_grip": [
976
+ 0.006347298849924511,
977
+ 0.006755526159009365,
978
+ -0.09130915095186147
979
+ ],
980
+ "n_frames": 525,
981
+ "start_pose_deg": [
982
+ 8.527472496032715,
983
+ -88.21977996826172,
984
+ 80.43955993652344,
985
+ 72.21977996826172,
986
+ 3.912087917327881,
987
+ 0.7246376872062683
988
+ ],
989
+ "sim_check": {
990
+ "cube_r": 0.23033764555135425,
991
+ "cube_angle_deg": 35.63389316744528,
992
+ "cube_in_annulus": true,
993
+ "plate_r": 0.1734931756826853,
994
+ "plate_angle_deg": -30.827546138227383,
995
+ "plate_in_annulus": true,
996
+ "cube_plate_dist": 0.2263545084816018,
997
+ "dist_in_6_30cm": true,
998
+ "yaw_turn_deg": -14.80310131093676,
999
+ "turn_within_30": true,
1000
+ "task_in_sim_distribution": true
1001
+ }
1002
+ },
1003
+ {
1004
+ "dataset": "green_cube_red_plate_1",
1005
+ "episode": 9,
1006
+ "cube_start_xyz": [
1007
+ 0.3339740883823542,
1008
+ -0.04216628504553652,
1009
+ -0.002615412576366962
1010
+ ],
1011
+ "cube_start_yaw_deg": 8.689959188177355,
1012
+ "cube_start_yaw_silhouette_deg": -3.719106369436304,
1013
+ "plate_xy": [
1014
+ 0.18194602497979362,
1015
+ -0.13559693220556127
1016
+ ],
1017
+ "plate_yaw_deg": -5.986317204415101,
1018
+ "grasp_frame": 191,
1019
+ "release_frame": 361,
1020
+ "cube_end_xyz": [
1021
+ 0.18463537950243214,
1022
+ -0.1365156133112859,
1023
+ 0.004992519054821343
1024
+ ],
1025
+ "cube_end_yaw_deg": -6.559622628092129,
1026
+ "cube_end_yaw_silhouette_deg": 22.289686286406322,
1027
+ "p_grip": [
1028
+ 0.006450193202969755,
1029
+ 0.005320314744372343,
1030
+ -0.09915379507440343
1031
+ ],
1032
+ "n_frames": 523,
1033
+ "start_pose_deg": [
1034
+ 13.01098918914795,
1035
+ -88.04395294189453,
1036
+ 79.20879364013672,
1037
+ 76.26373291015625,
1038
+ 7.780219554901123,
1039
+ 0.7246376872062683
1040
+ ],
1041
+ "sim_check": {
1042
+ "cube_r": 0.2981706525580532,
1043
+ "cube_angle_deg": -8.12982807314328,
1044
+ "cube_in_annulus": false,
1045
+ "plate_r": 0.19717330572639713,
1046
+ "plate_angle_deg": -43.44865873344575,
1047
+ "plate_in_annulus": true,
1048
+ "cube_plate_dist": 0.1784427580224931,
1049
+ "dist_in_6_30cm": true,
1050
+ "yaw_turn_deg": -14.676276392592456,
1051
+ "turn_within_30": true,
1052
+ "task_in_sim_distribution": false
1053
+ }
1054
+ }
1055
+ ],
1056
+ "scene": {
1057
+ "mat": {
1058
+ "corners_xy": [
1059
+ [
1060
+ 0.4415421393776707,
1061
+ 0.2154313577822069
1062
+ ],
1063
+ [
1064
+ 0.13464808253175026,
1065
+ 0.2361415190848988
1066
+ ],
1067
+ [
1068
+ 0.10367857174908096,
1069
+ -0.22278097136385888
1070
+ ],
1071
+ [
1072
+ 0.4105726285950014,
1073
+ -0.24349113266655079
1074
+ ]
1075
+ ],
1076
+ "center_xy": [
1077
+ 0.2726103555633758,
1078
+ -0.00367480679082599
1079
+ ],
1080
+ "yaw_deg": -3.8606433112404153,
1081
+ "size_xy": [
1082
+ 0.30759205599061,
1083
+ 0.45996626271696056
1084
+ ],
1085
+ "z": 0.001
1086
+ },
1087
+ "plate_top_z": 0.0039031332928005,
1088
+ "plate_thickness": 0.0039031332928005,
1089
+ "plate_size": 0.05,
1090
+ "cube_size": 0.03,
1091
+ "table_plane": {
1092
+ "coef": [
1093
+ -0.004681260916979778,
1094
+ -0.03640954226125585,
1095
+ 0.01836320115536056
1096
+ ],
1097
+ "meaning": "table top z = c0 + c1 * x + c2 * y in the arm-base frame (m)",
1098
+ "tilt_deg": [
1099
+ -2.086113105573168,
1100
+ 1.0521339245519172
1101
+ ]
1102
+ },
1103
+ "colors_srgb": {
1104
+ "external": {
1105
+ "cube": {
1106
+ "mean_srgb": [
1107
+ 18.4,
1108
+ 104.0,
1109
+ 42.3
1110
+ ],
1111
+ "median_srgb": [
1112
+ 15.0,
1113
+ 105.0,
1114
+ 41.0
1115
+ ],
1116
+ "mean_linear": [
1117
+ 0.0063,
1118
+ 0.1384,
1119
+ 0.0235
1120
+ ],
1121
+ "n_pixels": 34326,
1122
+ "n_frames": 266
1123
+ },
1124
+ "plate": {
1125
+ "mean_srgb": [
1126
+ 151.9,
1127
+ 18.1,
1128
+ 25.9
1129
+ ],
1130
+ "median_srgb": [
1131
+ 151.0,
1132
+ 16.0,
1133
+ 25.0
1134
+ ],
1135
+ "mean_linear": [
1136
+ 0.3136,
1137
+ 0.0061,
1138
+ 0.0102
1139
+ ],
1140
+ "n_pixels": 66214,
1141
+ "n_frames": 256
1142
+ },
1143
+ "mat": {
1144
+ "mean_srgb": [
1145
+ 23.5,
1146
+ 26.9,
1147
+ 20.0
1148
+ ],
1149
+ "median_srgb": [
1150
+ 23.0,
1151
+ 25.0,
1152
+ 18.0
1153
+ ],
1154
+ "mean_linear": [
1155
+ 0.0089,
1156
+ 0.0109,
1157
+ 0.007
1158
+ ],
1159
+ "n_pixels": 4033810,
1160
+ "n_frames": 268
1161
+ },
1162
+ "floor": {
1163
+ "mean_srgb": [
1164
+ 165.7,
1165
+ 171.0,
1166
+ 165.5
1167
+ ],
1168
+ "median_srgb": [
1169
+ 166.0,
1170
+ 169.0,
1171
+ 165.0
1172
+ ],
1173
+ "mean_linear": [
1174
+ 0.3797,
1175
+ 0.4072,
1176
+ 0.3786
1177
+ ],
1178
+ "n_pixels": 2727704,
1179
+ "n_frames": 268
1180
+ },
1181
+ "arm_white": {
1182
+ "mean_srgb": [
1183
+ 133.9,
1184
+ 135.7,
1185
+ 115.5
1186
+ ],
1187
+ "median_srgb": [
1188
+ 131.0,
1189
+ 133.0,
1190
+ 113.0
1191
+ ],
1192
+ "mean_linear": [
1193
+ 0.2381,
1194
+ 0.2451,
1195
+ 0.1732
1196
+ ],
1197
+ "n_pixels": 64104,
1198
+ "n_frames": 30
1199
+ },
1200
+ "servo_black": {
1201
+ "mean_srgb": [
1202
+ 19.2,
1203
+ 20.3,
1204
+ 10.2
1205
+ ],
1206
+ "median_srgb": [
1207
+ 14.0,
1208
+ 15.0,
1209
+ 4.0
1210
+ ],
1211
+ "mean_linear": [
1212
+ 0.0066,
1213
+ 0.0072,
1214
+ 0.0031
1215
+ ],
1216
+ "n_pixels": 22631,
1217
+ "n_frames": 30
1218
+ }
1219
+ },
1220
+ "wrist": {
1221
+ "cube": {
1222
+ "mean_srgb": [
1223
+ 17.3,
1224
+ 169.8,
1225
+ 81.1
1226
+ ],
1227
+ "median_srgb": [
1228
+ 16.0,
1229
+ 175.0,
1230
+ 84.0
1231
+ ],
1232
+ "mean_linear": [
1233
+ 0.0057,
1234
+ 0.4008,
1235
+ 0.0825
1236
+ ],
1237
+ "n_pixels": 761124,
1238
+ "n_frames": 268
1239
+ },
1240
+ "plate": {
1241
+ "mean_srgb": [
1242
+ 217.2,
1243
+ 36.2,
1244
+ 38.6
1245
+ ],
1246
+ "median_srgb": [
1247
+ 209.0,
1248
+ 28.0,
1249
+ 30.0
1250
+ ],
1251
+ "mean_linear": [
1252
+ 0.6956,
1253
+ 0.0178,
1254
+ 0.02
1255
+ ],
1256
+ "n_pixels": 565562,
1257
+ "n_frames": 239
1258
+ },
1259
+ "mat": {
1260
+ "mean_srgb": [
1261
+ 44.1,
1262
+ 48.7,
1263
+ 42.9
1264
+ ],
1265
+ "median_srgb": [
1266
+ 41.0,
1267
+ 46.0,
1268
+ 41.0
1269
+ ],
1270
+ "mean_linear": [
1271
+ 0.0252,
1272
+ 0.0303,
1273
+ 0.0241
1274
+ ],
1275
+ "n_pixels": 31770838,
1276
+ "n_frames": 268
1277
+ },
1278
+ "floor": {
1279
+ "mean_srgb": [
1280
+ 227.4,
1281
+ 231.1,
1282
+ 229.1
1283
+ ],
1284
+ "median_srgb": [
1285
+ 233.0,
1286
+ 237.0,
1287
+ 238.0
1288
+ ],
1289
+ "mean_linear": [
1290
+ 0.7714,
1291
+ 0.7995,
1292
+ 0.7845
1293
+ ],
1294
+ "n_pixels": 7946048,
1295
+ "n_frames": 268
1296
+ },
1297
+ "arm_white": {
1298
+ "mean_srgb": [
1299
+ 224.1,
1300
+ 221.7,
1301
+ 211.2
1302
+ ],
1303
+ "median_srgb": [
1304
+ 232.0,
1305
+ 228.0,
1306
+ 217.0
1307
+ ],
1308
+ "mean_linear": [
1309
+ 0.7459,
1310
+ 0.7281,
1311
+ 0.6527
1312
+ ],
1313
+ "n_pixels": 3867581,
1314
+ "n_frames": 267
1315
+ },
1316
+ "servo_black": {
1317
+ "mean_srgb": [
1318
+ 33.8,
1319
+ 35.2,
1320
+ 29.0
1321
+ ],
1322
+ "median_srgb": [
1323
+ 34.0,
1324
+ 34.0,
1325
+ 28.0
1326
+ ],
1327
+ "mean_linear": [
1328
+ 0.0158,
1329
+ 0.017,
1330
+ 0.0123
1331
+ ],
1332
+ "n_pixels": 1524759,
1333
+ "n_frames": 268
1334
+ }
1335
+ },
1336
+ "notes": "decoded H.264 (yuv420p) frames, OpenCV BGR->RGB; pre-grasp frames of all 15 episodes, every 10th frame; both cameras run auto exposure / white balance (UVC defaults), so values are scene-and-time dependent"
1337
+ },
1338
+ "tent_edges_on_table": {
1339
+ "back_left_vertical": {
1340
+ "mean_xy": [
1341
+ -2.234706001456275,
1342
+ 6.98376444778672
1343
+ ],
1344
+ "direction_deg": 109.08381857975152,
1345
+ "end_a": [
1346
+ -0.021687390447613808,
1347
+ 0.5871060353188051
1348
+ ],
1349
+ "end_b": [
1350
+ -48.69972327331576,
1351
+ 141.28938760837914
1352
+ ],
1353
+ "note": "vertical edge: the table-plane intersection is not meaningful"
1354
+ },
1355
+ "back_floor": {
1356
+ "mean_xy": [
1357
+ 0.30721218712751286,
1358
+ 0.4567102786016847
1359
+ ],
1360
+ "direction_deg": -3.7004140781073005,
1361
+ "end_a": [
1362
+ 0.0084632714954897,
1363
+ 0.4760316724527963
1364
+ ],
1365
+ "end_b": [
1366
+ 0.5825967452130373,
1367
+ 0.4388999595381722
1368
+ ],
1369
+ "note": "on the table plane"
1370
+ },
1371
+ "back_right_vertical": {
1372
+ "mean_xy": [
1373
+ 0.9756942034541046,
1374
+ 1.4019532616387078
1375
+ ],
1376
+ "direction_deg": 69.71156536833297,
1377
+ "end_a": [
1378
+ 0.6557709144107051,
1379
+ 0.5365514200079403
1380
+ ],
1381
+ "end_b": [
1382
+ 1.7179692999327356,
1383
+ 3.40982907902605
1384
+ ],
1385
+ "note": "vertical edge: the table-plane intersection is not meaningful"
1386
+ },
1387
+ "right_floor": {
1388
+ "mean_xy": [
1389
+ 0.5876447776861765,
1390
+ -0.10260227903720404
1391
+ ],
1392
+ "direction_deg": 86.70338202892243,
1393
+ "end_a": [
1394
+ 0.569074900570323,
1395
+ -0.4249936638565325
1396
+ ],
1397
+ "end_b": [
1398
+ 0.6147059702089496,
1399
+ 0.36720671742788813
1400
+ ],
1401
+ "note": "on the table plane"
1402
+ },
1403
+ "table_edge_left": {
1404
+ "mean_xy": [
1405
+ -0.04226150334414614,
1406
+ -0.21611951812681693
1407
+ ],
1408
+ "direction_deg": 83.6005831319696,
1409
+ "end_a": [
1410
+ -0.061883061925573496,
1411
+ -0.39106572733405925
1412
+ ],
1413
+ "end_b": [
1414
+ -0.030536527553528495,
1415
+ -0.11157939920084983
1416
+ ],
1417
+ "note": "on the table plane"
1418
+ },
1419
+ "front_floor": {
1420
+ "mean_xy": [
1421
+ 0.27012521237733517,
1422
+ -0.45649238436423
1423
+ ],
1424
+ "direction_deg": -3.716054733062346,
1425
+ "end_a": [
1426
+ -0.005963368187689111,
1427
+ -0.43856084960281133
1428
+ ],
1429
+ "end_b": [
1430
+ 0.539232197708343,
1431
+ -0.4739704750991963
1432
+ ],
1433
+ "note": "on the table plane"
1434
+ },
1435
+ "mat_top": {
1436
+ "mean_xy": [
1437
+ 0.2861046520066711,
1438
+ 0.23055037181577712
1439
+ ],
1440
+ "direction_deg": -2.737206262162437,
1441
+ "end_a": [
1442
+ 0.16402190284641244,
1443
+ 0.23638710396283494
1444
+ ],
1445
+ "end_b": [
1446
+ 0.4075864354175589,
1447
+ 0.2247423716241574
1448
+ ],
1449
+ "note": "on the table plane"
1450
+ },
1451
+ "mat_right": {
1452
+ "mean_xy": [
1453
+ 0.42148444966605875,
1454
+ -0.046558767729531846
1455
+ ],
1456
+ "direction_deg": 86.45692253859843,
1457
+ "end_a": [
1458
+ 0.41113510721034996,
1459
+ -0.21370656978292524
1460
+ ],
1461
+ "end_b": [
1462
+ 0.43455407082900666,
1463
+ 0.16452309185781186
1464
+ ],
1465
+ "note": "on the table plane"
1466
+ },
1467
+ "mat_bottom": {
1468
+ "mean_xy": [
1469
+ 0.2552528264025261,
1470
+ -0.23683183930144378
1471
+ ],
1472
+ "direction_deg": -3.8099873219972737,
1473
+ "end_a": [
1474
+ 0.1257419110986377,
1475
+ -0.22820705868060664
1476
+ ],
1477
+ "end_b": [
1478
+ 0.3814098086244724,
1479
+ -0.24523326471719378
1480
+ ],
1481
+ "note": "on the table plane"
1482
+ },
1483
+ "mat_left": {
1484
+ "mean_xy": [
1485
+ 0.11482926580671213,
1486
+ -0.026502364341103993
1487
+ ],
1488
+ "direction_deg": 85.91625620665677,
1489
+ "end_a": [
1490
+ 0.10287798261399214,
1491
+ -0.193897329196473
1492
+ ],
1493
+ "end_b": [
1494
+ 0.12966845983645967,
1495
+ 0.1813419585684814
1496
+ ],
1497
+ "note": "on the table plane"
1498
+ }
1499
+ },
1500
+ "notes": "World = arm base frame (so101.xml). The table / tent floor is NOT at z = 0: fitted plane z = c0 + c1 x + c2 y (scene.table_plane; -4.7 mm at the base, about -16 mm at x = 0.3 m; tilt 2.1 deg down along +x, 1.1 deg up along +y). The black mat lies on it (rectangle 0.308 x 0.460 m, centre (0.273, -0.004), yaw -3.9 deg). Tent floor (white) edges on the table plane: table edge behind the robot at x ~ -0.04 (the base is clamped there, nothing beyond it), back wall bottom at y ~ +0.46, front edge at y ~ -0.45, right wall bottom at x ~ 0.59 (tent_edges_on_table); walls white, an LED strip along the top of the far (+x) side, the room (dark, a yellow wall) visible beyond the open table edge. All tent / mat edges are rotated by about -3.5 deg about z relative to the base axes (either the base is turned on the table or the pan zero is off by that much). Cube 30 mm (resting centre 15 mm above the local table), plate 50 x 50 mm, thickness held at 2 mm (prior; not resolved by the data). The real wrist camera is NOT at the MJCF wrist_cam pose: fitted pose in camera_mount is ~4.7 cm further back along the gripper axis and ~1.7 cm further out than the MJCF camera (the external view shows the camera board on a taller bracket). Image time lags the joint state by time_offset_frames (about 1.3-1.4 frames = 42-48 ms) in both cameras."
1501
+ },
1502
+ "real_start_pose": {
1503
+ "note": "all 15 episodes start from the folded rest pose; LeRobot deg median [8.3, -88.1, 81.1, 71.7, 3.9, 0.7] (gripper 31-40 in green_cube_red_plate, 0.6-5.7 in green_cube_red_plate_1); mapped to sim deg median [8.3, -90.0, 72.6, 70.6, -71.9] (arm) - far from the sim task starts (median ~[1, -5, -15, 92, 11] deg)"
1504
+ },
1505
+ "camera_model_comparison": "Same observations and pipeline. External radial-tangential (k1 k2 p1 p2 k3) vs fisheye: fit 1.63/1.28/1.46 vs 1.57/1.24/1.25 px (resting cube/carry/plate); cross-camera holdout 1.87/2.51/1.43 vs 1.77/3.09/1.31 px (pooled 1.92 vs 2.11, n=26, within noise); radial-tangential puts the image corners at 63 deg off-axis vs 82-86 deg. Wrist radial-tangential: holdout similar but the periphery fails (mat corners rms 1e8 px, plates 204 px on the common set). Fisheye kept for both; external k4 and wrist k3,k4 held at 0 because the free wrist polynomial folded back at 69 deg off-axis (corners at 86-89 deg); the reduced models are monotonic to 100 deg with equal or lower residuals.",
1506
+ "holdout_protocol": "Episodes green_cube_red_plate ep2, green_cube_red_plate_1 ep3 and ep7 left out of the global fit; their placements re-estimated from the OTHER camera + kinematics only, then predicted in the evaluated camera; wrist mat corners in held-out frames depend on global parameters only.",
1507
+ "uncertainties": [
1508
+ "pan offset unobservable (gauge), held 0; tent edges suggest ~+3.5 deg, homing pose -6.9 deg",
1509
+ "table tilt (2.1 deg) and shoulder_lift offset partly interchangeable; flat-table alternative 14 % worse (joint_map.alternatives.flat_table)",
1510
+ "wrist_roll offset -75.8 deg relies on the jaw-tip model (jaw residual 4.6 px rms); external view does not separate -76 from -90",
1511
+ "real wrist camera 4.7 cm further back / 1.7 cm further out than the MJCF wrist_cam, optical axis 10 deg different",
1512
+ "MJCF jaw geometry: hold width differs ~2.3 deg (alternatives.gripper_lin_hold_width)",
1513
+ "plate thickness not resolved (2 mm prior); cube yaw at rest taken from the jaw yaw at the grasp; released cubes drop 2-12 mm",
1514
+ "external holdout samples small (6 static, 8 carry, 12 plate corners); wrist intrinsics beyond ~70 deg off-axis extrapolated",
1515
+ "both cameras auto-expose: colours drift with the view"
1516
+ ],
1517
+ "overlays": [
1518
+ "overlay_external_0.png",
1519
+ "overlay_external_1.png",
1520
+ "overlay_external_zoom_0.png",
1521
+ "overlay_external_zoom_1.png",
1522
+ "overlay_wrist_0.png",
1523
+ "overlay_wrist_1.png",
1524
+ "evidence_roll_offset_external.png"
1525
+ ]
1526
+ }
so101_pick_place/code/configs/so101_pick_place/dyn_fit_d2q.json ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "d": 2,
3
+ "jitter": 0.4,
4
+ "i_time_s": 0.2,
5
+ "i_max_deg": 3.0,
6
+ "i_e_max_deg": 1.0,
7
+ "i_v_min": 0.02,
8
+ "servo": {
9
+ "delay_ms": [
10
+ 25,
11
+ 25,
12
+ 20,
13
+ 25,
14
+ 20,
15
+ 45
16
+ ],
17
+ "tau_ms": [
18
+ 50,
19
+ 50,
20
+ 45,
21
+ 40,
22
+ 40,
23
+ 45
24
+ ],
25
+ "deadband_deg": [
26
+ 0.35,
27
+ 0.3,
28
+ 0.74,
29
+ 0.37,
30
+ 0.44,
31
+ 0.37
32
+ ],
33
+ "deadband_per_Nm_deg": [
34
+ 0.0,
35
+ 1.7,
36
+ 1.3,
37
+ 0.8,
38
+ 0.0,
39
+ 0.0
40
+ ],
41
+ "breakaway_extra_deg": [
42
+ 0.14,
43
+ 0.0,
44
+ 0.02,
45
+ 0.09,
46
+ 0.09,
47
+ 0.29
48
+ ],
49
+ "compliance_rad_per_Nm": [
50
+ 0.0,
51
+ 0.06,
52
+ 0.055,
53
+ 0.055,
54
+ 0.0,
55
+ 0.0
56
+ ],
57
+ "bias_deg": [
58
+ -0.07,
59
+ -0.22,
60
+ 0.18,
61
+ 0.0,
62
+ -0.07,
63
+ 0.03
64
+ ],
65
+ "vmax_rad_s": [
66
+ 3.0,
67
+ 2.3,
68
+ 3.0,
69
+ 3.0,
70
+ 1.0,
71
+ 2.2
72
+ ],
73
+ "cube_mass_kg": 0.03
74
+ },
75
+ "note": "fitted servo evaluation setting (servo_fit_params.json proposed) + robot loop delay d 2 jitter 0.4 + guard integral",
76
+ "delay_mode": "queue"
77
+ }
so101_pick_place/code/configs/so101_pick_place/nrd/base_c0.json ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "seed": 61,
3
+ "model_step_s": 0.02,
4
+ "history": 4,
5
+ "network": {
6
+ "width": 128,
7
+ "heads": 4,
8
+ "ffn": 512,
9
+ "layers": 4
10
+ },
11
+ "integrate_kinds": [
12
+ "sphere",
13
+ "rigid",
14
+ "articulated"
15
+ ],
16
+ "check_episodes": 1500,
17
+ "evaluate_every": 10000,
18
+ "free_phase_step": 5,
19
+ "core_bins": 8,
20
+ "ridge": 1e-06,
21
+ "near_negative_s": 0.05,
22
+ "collision": {
23
+ "lr": 0.001,
24
+ "updates": 30000,
25
+ "batch": 2048,
26
+ "warmup": 1000
27
+ },
28
+ "skip_ridge": 0.001,
29
+ "push_prob": 0.5,
30
+ "push_start": 0.25,
31
+ "push_max_steps": 3,
32
+ "push_max_dev": 0.5,
33
+ "rollout_scale_factor": 4.0,
34
+ "cotrain": {
35
+ "updates": 120000,
36
+ "lr": 0.001,
37
+ "warmup": 2000,
38
+ "core_batch": 4096,
39
+ "contact_batch": 4096,
40
+ "traj_every": 8,
41
+ "traj_batch": 128,
42
+ "horizon_start_s": 0.1,
43
+ "horizon_max_s": 1.0,
44
+ "horizon_ramp": 0.5,
45
+ "traj_ramp": 0.25
46
+ },
47
+ "push_guard": {
48
+ "unit": "all_hit",
49
+ "bodies": "affected"
50
+ },
51
+ "history_noise": {
52
+ "floor_step_rms": 0.05,
53
+ "rate_kick": {
54
+ "size": 1.0,
55
+ "mix": [
56
+ 0.1,
57
+ 4.0
58
+ ]
59
+ }
60
+ },
61
+ "loss_scale": {
62
+ "rule": "step_type"
63
+ },
64
+ "contact_huber": 1.0,
65
+ "contact_sampling": "sqrt_groups",
66
+ "collision_cotrain": {
67
+ "weight": 1.0
68
+ },
69
+ "aux_geometry": {
70
+ "fk": "configs/contact_nrd/derived/so101_grasp_fk.json",
71
+ "body": "cube",
72
+ "frame": "arm",
73
+ "pairs": [
74
+ "fixed_jaw_cube",
75
+ "moving_jaw_cube"
76
+ ],
77
+ "weight": 1.0,
78
+ "generated": true
79
+ },
80
+ "collision_sampling": "sqrt_families"
81
+ }
so101_pick_place/code/configs/so101_pick_place/nrd/ft_c1_s62.json ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "seed": 62,
3
+ "model_step_s": 0.02,
4
+ "history": 4,
5
+ "network": {
6
+ "width": 128,
7
+ "heads": 4,
8
+ "ffn": 512,
9
+ "layers": 4
10
+ },
11
+ "integrate_kinds": [
12
+ "sphere",
13
+ "rigid",
14
+ "articulated"
15
+ ],
16
+ "check_episodes": 1500,
17
+ "evaluate_every": 2500,
18
+ "free_phase_step": 5,
19
+ "core_bins": 8,
20
+ "ridge": 1e-06,
21
+ "near_negative_s": 0.05,
22
+ "collision": {
23
+ "lr": 0.001,
24
+ "updates": 3000,
25
+ "batch": 2048,
26
+ "warmup": 100
27
+ },
28
+ "skip_ridge": 0.001,
29
+ "push_prob": 0.5,
30
+ "push_start": 0.0,
31
+ "push_max_steps": 3,
32
+ "push_max_dev": 0.5,
33
+ "rollout_scale_factor": 4.0,
34
+ "cotrain": {
35
+ "updates": 20000,
36
+ "lr": 0.0001,
37
+ "warmup": 500,
38
+ "core_batch": 4096,
39
+ "contact_batch": 4096,
40
+ "traj_every": 8,
41
+ "traj_batch": 128,
42
+ "horizon_start_s": 1.0,
43
+ "horizon_max_s": 1.0,
44
+ "horizon_ramp": 0.5,
45
+ "traj_ramp": 0.025
46
+ },
47
+ "push_guard": {
48
+ "unit": "all_hit",
49
+ "bodies": "affected"
50
+ },
51
+ "history_noise": {
52
+ "floor_step_rms": 0.05,
53
+ "rate_kick": {
54
+ "size": 1.0,
55
+ "mix": [
56
+ 0.1,
57
+ 4.0
58
+ ]
59
+ }
60
+ },
61
+ "loss_scale": {
62
+ "rule": "step_type"
63
+ },
64
+ "contact_huber": 1.0,
65
+ "contact_sampling": "sqrt_groups",
66
+ "collision_cotrain": {
67
+ "weight": 1.0
68
+ },
69
+ "aux_geometry": {
70
+ "fk": "configs/contact_nrd/derived/so101_grasp_fk.json",
71
+ "body": "cube",
72
+ "frame": "arm",
73
+ "pairs": [
74
+ "fixed_jaw_cube",
75
+ "moving_jaw_cube"
76
+ ],
77
+ "weight": 1.0,
78
+ "generated": true
79
+ },
80
+ "collision_sampling": "sqrt_families",
81
+ "note": "Converged-state data round c1 of the SO101 policy study (2026-10-12): fine-tune of the sibling study's converged-state grasp NRD (state = joint/cube rates predicted, poses integrated; no derived or relative input channels; training-only geometry heads) full_ns_rk_cc_geo_cs_s62_plus/best.pt on production_plus + noisy_v1 + expert_v2 + policy_v3 x2.5 (the round-3 merge). Recipe = the source run's options; fine-tune schedule as rounds 2-3: 20,000 co-training updates at lr 1e-4, warmup 500, traj_ramp 0.025, horizon 1.0 s, a check every 2,500 updates. best.pt on the merged validation; last.pt = fixed budget.",
82
+ "init_from": {
83
+ "run": "artifacts/so101_pick_place/nrd/c0_s62",
84
+ "checkpoint": "original/best.pt",
85
+ "collision_updates": 0,
86
+ "collision_lr": 0.0001,
87
+ "collision_warmup": 0,
88
+ "check_first": true
89
+ }
90
+ }
so101_pick_place/code/configs/so101_pick_place/parts_override_v2.json ADDED
@@ -0,0 +1,1667 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "name": "camera_bracket_plate",
4
+ "body": "camera_mount",
5
+ "group": "board",
6
+ "polygon": [
7
+ [
8
+ 0.013159,
9
+ 0.029292,
10
+ -0.007253
11
+ ],
12
+ [
13
+ -0.006522,
14
+ 0.033162,
15
+ -0.006874
16
+ ],
17
+ [
18
+ -0.010424,
19
+ 0.026461,
20
+ -0.032272
21
+ ],
22
+ [
23
+ 0.012545,
24
+ 0.021276,
25
+ -0.034992
26
+ ]
27
+ ],
28
+ "offset": [
29
+ -0.000541,
30
+ -0.002832,
31
+ 0.00083
32
+ ],
33
+ "color": [
34
+ 0.0351,
35
+ 0.0333,
36
+ 0.0318
37
+ ]
38
+ },
39
+ {
40
+ "name": "bracket_ledge",
41
+ "body": "camera_mount",
42
+ "group": "printed",
43
+ "polygon": [
44
+ [
45
+ -0.011327,
46
+ 0.024812,
47
+ -0.037403
48
+ ],
49
+ [
50
+ 0.003322,
51
+ 0.021372,
52
+ -0.039591
53
+ ],
54
+ [
55
+ 0.005342,
56
+ 0.022598,
57
+ -0.034092
58
+ ],
59
+ [
60
+ 0.005291,
61
+ 0.023963,
62
+ -0.02947
63
+ ],
64
+ [
65
+ -0.008956,
66
+ 0.027183,
67
+ -0.027769
68
+ ]
69
+ ],
70
+ "offset": [
71
+ -5.4e-05,
72
+ -0.000283,
73
+ 8.3e-05
74
+ ],
75
+ "color": [
76
+ 0.2834,
77
+ 0.2723,
78
+ 0.2586
79
+ ]
80
+ },
81
+ {
82
+ "name": "plate_screw0_head_lo",
83
+ "body": "camera_mount",
84
+ "group": "board",
85
+ "polygon": [
86
+ [
87
+ -0.005842,
88
+ 0.02694,
89
+ -0.028015
90
+ ],
91
+ [
92
+ -0.005547,
93
+ 0.02713,
94
+ -0.027175
95
+ ],
96
+ [
97
+ -0.00495,
98
+ 0.027216,
99
+ -0.026494
100
+ ],
101
+ [
102
+ -0.004144,
103
+ 0.027185,
104
+ -0.026073
105
+ ],
106
+ [
107
+ -0.003251,
108
+ 0.027042,
109
+ -0.025978
110
+ ],
111
+ [
112
+ -0.002406,
113
+ 0.026809,
114
+ -0.026222
115
+ ],
116
+ [
117
+ -0.001738,
118
+ 0.026521,
119
+ -0.02677
120
+ ],
121
+ [
122
+ -0.00135,
123
+ 0.026222,
124
+ -0.027536
125
+ ],
126
+ [
127
+ -0.001299,
128
+ 0.025958,
129
+ -0.028405
130
+ ]
131
+ ],
132
+ "offset": [
133
+ 0.000108,
134
+ 0.000566,
135
+ -0.000166
136
+ ],
137
+ "color": [
138
+ 0.5459,
139
+ 0.4098,
140
+ 0.3793
141
+ ]
142
+ },
143
+ {
144
+ "name": "plate_screw0_head_hi",
145
+ "body": "camera_mount",
146
+ "group": "board",
147
+ "polygon": [
148
+ [
149
+ -0.001299,
150
+ 0.025958,
151
+ -0.028405
152
+ ],
153
+ [
154
+ -0.001595,
155
+ 0.025768,
156
+ -0.029245
157
+ ],
158
+ [
159
+ -0.002191,
160
+ 0.025682,
161
+ -0.029927
162
+ ],
163
+ [
164
+ -0.002997,
165
+ 0.025713,
166
+ -0.030347
167
+ ],
168
+ [
169
+ -0.003891,
170
+ 0.025856,
171
+ -0.030443
172
+ ],
173
+ [
174
+ -0.004736,
175
+ 0.026089,
176
+ -0.030198
177
+ ],
178
+ [
179
+ -0.005403,
180
+ 0.026377,
181
+ -0.029651
182
+ ],
183
+ [
184
+ -0.005792,
185
+ 0.026676,
186
+ -0.028884
187
+ ],
188
+ [
189
+ -0.005842,
190
+ 0.02694,
191
+ -0.028015
192
+ ]
193
+ ],
194
+ "offset": [
195
+ 0.000108,
196
+ 0.000566,
197
+ -0.000166
198
+ ],
199
+ "color": [
200
+ 0.1267,
201
+ 0.0951,
202
+ 0.088
203
+ ]
204
+ },
205
+ {
206
+ "name": "plate_screw0_recess",
207
+ "body": "camera_mount",
208
+ "group": "board",
209
+ "polygon": [
210
+ [
211
+ -0.003453,
212
+ 0.027358,
213
+ -0.027383
214
+ ],
215
+ [
216
+ -0.00397,
217
+ 0.027409,
218
+ -0.027544
219
+ ],
220
+ [
221
+ -0.004347,
222
+ 0.027368,
223
+ -0.027933
224
+ ],
225
+ [
226
+ -0.004486,
227
+ 0.027244,
228
+ -0.028443
229
+ ],
230
+ [
231
+ -0.004347,
232
+ 0.027072,
233
+ -0.02894
234
+ ],
235
+ [
236
+ -0.00397,
237
+ 0.026898,
238
+ -0.029289
239
+ ],
240
+ [
241
+ -0.003453,
242
+ 0.026767,
243
+ -0.029397
244
+ ],
245
+ [
246
+ -0.002937,
247
+ 0.026716,
248
+ -0.029235
249
+ ],
250
+ [
251
+ -0.00256,
252
+ 0.026758,
253
+ -0.028847
254
+ ],
255
+ [
256
+ -0.002421,
257
+ 0.026881,
258
+ -0.028337
259
+ ],
260
+ [
261
+ -0.00256,
262
+ 0.027053,
263
+ -0.02784
264
+ ],
265
+ [
266
+ -0.002937,
267
+ 0.027228,
268
+ -0.027491
269
+ ]
270
+ ],
271
+ "offset": [
272
+ 1.8e-05,
273
+ 9.4e-05,
274
+ -2.8e-05
275
+ ],
276
+ "color": [
277
+ 0.0915,
278
+ 0.0915,
279
+ 0.0915
280
+ ]
281
+ },
282
+ {
283
+ "name": "plate_screw1_head_lo",
284
+ "body": "camera_mount",
285
+ "group": "board",
286
+ "polygon": [
287
+ [
288
+ 0.002901,
289
+ 0.025022,
290
+ -0.028861
291
+ ],
292
+ [
293
+ 0.003073,
294
+ 0.025251,
295
+ -0.027969
296
+ ],
297
+ [
298
+ 0.003578,
299
+ 0.025382,
300
+ -0.027193
301
+ ],
302
+ [
303
+ 0.004339,
304
+ 0.025396,
305
+ -0.026648
306
+ ],
307
+ [
308
+ 0.005241,
309
+ 0.025291,
310
+ -0.026419
311
+ ],
312
+ [
313
+ 0.006145,
314
+ 0.025083,
315
+ -0.02654
316
+ ],
317
+ [
318
+ 0.006914,
319
+ 0.024803,
320
+ -0.026993
321
+ ],
322
+ [
323
+ 0.007432,
324
+ 0.024494,
325
+ -0.027709
326
+ ],
327
+ [
328
+ 0.007619,
329
+ 0.024204,
330
+ -0.028579
331
+ ]
332
+ ],
333
+ "offset": [
334
+ 0.000108,
335
+ 0.000566,
336
+ -0.000166
337
+ ],
338
+ "color": [
339
+ 0.5459,
340
+ 0.4098,
341
+ 0.3793
342
+ ]
343
+ },
344
+ {
345
+ "name": "plate_screw1_head_hi",
346
+ "body": "camera_mount",
347
+ "group": "board",
348
+ "polygon": [
349
+ [
350
+ 0.007619,
351
+ 0.024204,
352
+ -0.028579
353
+ ],
354
+ [
355
+ 0.007447,
356
+ 0.023975,
357
+ -0.02947
358
+ ],
359
+ [
360
+ 0.006942,
361
+ 0.023844,
362
+ -0.030247
363
+ ],
364
+ [
365
+ 0.006181,
366
+ 0.02383,
367
+ -0.030791
368
+ ],
369
+ [
370
+ 0.00528,
371
+ 0.023935,
372
+ -0.03102
373
+ ],
374
+ [
375
+ 0.004376,
376
+ 0.024143,
377
+ -0.030899
378
+ ],
379
+ [
380
+ 0.003606,
381
+ 0.024423,
382
+ -0.030446
383
+ ],
384
+ [
385
+ 0.003089,
386
+ 0.024731,
387
+ -0.02973
388
+ ],
389
+ [
390
+ 0.002901,
391
+ 0.025022,
392
+ -0.028861
393
+ ]
394
+ ],
395
+ "offset": [
396
+ 0.000108,
397
+ 0.000566,
398
+ -0.000166
399
+ ],
400
+ "color": [
401
+ 0.1267,
402
+ 0.0951,
403
+ 0.088
404
+ ]
405
+ },
406
+ {
407
+ "name": "plate_screw1_recess",
408
+ "body": "camera_mount",
409
+ "group": "board",
410
+ "polygon": [
411
+ [
412
+ 0.005378,
413
+ 0.02553,
414
+ -0.027864
415
+ ],
416
+ [
417
+ 0.004847,
418
+ 0.025583,
419
+ -0.02803
420
+ ],
421
+ [
422
+ 0.004458,
423
+ 0.02554,
424
+ -0.028429
425
+ ],
426
+ [
427
+ 0.004316,
428
+ 0.025413,
429
+ -0.028954
430
+ ],
431
+ [
432
+ 0.004458,
433
+ 0.025236,
434
+ -0.029465
435
+ ],
436
+ [
437
+ 0.004847,
438
+ 0.025057,
439
+ -0.029824
440
+ ],
441
+ [
442
+ 0.005378,
443
+ 0.024923,
444
+ -0.029935
445
+ ],
446
+ [
447
+ 0.005908,
448
+ 0.02487,
449
+ -0.029769
450
+ ],
451
+ [
452
+ 0.006297,
453
+ 0.024913,
454
+ -0.02937
455
+ ],
456
+ [
457
+ 0.006439,
458
+ 0.02504,
459
+ -0.028845
460
+ ],
461
+ [
462
+ 0.006297,
463
+ 0.025217,
464
+ -0.028334
465
+ ],
466
+ [
467
+ 0.005908,
468
+ 0.025396,
469
+ -0.027975
470
+ ]
471
+ ],
472
+ "offset": [
473
+ 1.8e-05,
474
+ 9.4e-05,
475
+ -2.8e-05
476
+ ],
477
+ "color": [
478
+ 0.0915,
479
+ 0.0915,
480
+ 0.0915
481
+ ]
482
+ },
483
+ {
484
+ "name": "jaw_face",
485
+ "body": "moving_jaw_so101_v1",
486
+ "group": "printed",
487
+ "polygon": [
488
+ [
489
+ 0.005621,
490
+ -0.015293,
491
+ -0.005075
492
+ ],
493
+ [
494
+ 0.008601,
495
+ -0.004752,
496
+ -0.005329
497
+ ],
498
+ [
499
+ 0.009052,
500
+ -0.00086,
501
+ -0.005422
502
+ ],
503
+ [
504
+ 0.007741,
505
+ 0.004273,
506
+ -0.005542
507
+ ],
508
+ [
509
+ 0.005927,
510
+ 0.006911,
511
+ -0.005603
512
+ ],
513
+ [
514
+ -0.003481,
515
+ 0.005917,
516
+ -0.00557
517
+ ],
518
+ [
519
+ -0.004889,
520
+ 0.004254,
521
+ -0.005529
522
+ ],
523
+ [
524
+ -0.008993,
525
+ -0.003032,
526
+ -0.005351
527
+ ],
528
+ [
529
+ -0.009368,
530
+ -0.012449,
531
+ -0.005127
532
+ ],
533
+ [
534
+ -0.008874,
535
+ -0.015844,
536
+ -0.005047
537
+ ]
538
+ ],
539
+ "offset": [
540
+ -0.0,
541
+ -5e-06,
542
+ -0.0002
543
+ ],
544
+ "color": [
545
+ 0.3914,
546
+ 0.3812,
547
+ 0.3731
548
+ ]
549
+ },
550
+ {
551
+ "name": "jaw_screw0_rim",
552
+ "body": "moving_jaw_so101_v1",
553
+ "group": "servo",
554
+ "polygon": [
555
+ [
556
+ -0.003848,
557
+ -0.010599,
558
+ -0.005377
559
+ ],
560
+ [
561
+ -0.004753,
562
+ -0.010419,
563
+ -0.00538
564
+ ],
565
+ [
566
+ -0.00552,
567
+ -0.009907,
568
+ -0.005392
569
+ ],
570
+ [
571
+ -0.006033,
572
+ -0.00914,
573
+ -0.005409
574
+ ],
575
+ [
576
+ -0.006213,
577
+ -0.008235,
578
+ -0.005431
579
+ ],
580
+ [
581
+ -0.006033,
582
+ -0.00733,
583
+ -0.005452
584
+ ],
585
+ [
586
+ -0.00552,
587
+ -0.006563,
588
+ -0.005471
589
+ ],
590
+ [
591
+ -0.004753,
592
+ -0.00605,
593
+ -0.005484
594
+ ],
595
+ [
596
+ -0.003848,
597
+ -0.00587,
598
+ -0.005489
599
+ ],
600
+ [
601
+ -0.002943,
602
+ -0.00605,
603
+ -0.005486
604
+ ],
605
+ [
606
+ -0.002175,
607
+ -0.006563,
608
+ -0.005475
609
+ ],
610
+ [
611
+ -0.001663,
612
+ -0.00733,
613
+ -0.005457
614
+ ],
615
+ [
616
+ -0.001482,
617
+ -0.008235,
618
+ -0.005435
619
+ ],
620
+ [
621
+ -0.001663,
622
+ -0.00914,
623
+ -0.005414
624
+ ],
625
+ [
626
+ -0.002175,
627
+ -0.009907,
628
+ -0.005395
629
+ ],
630
+ [
631
+ -0.002943,
632
+ -0.010419,
633
+ -0.005382
634
+ ]
635
+ ],
636
+ "offset": [
637
+ -1e-06,
638
+ -1.4e-05,
639
+ -0.0006
640
+ ],
641
+ "color": [
642
+ 0.3224,
643
+ 0.2602,
644
+ 0.2444
645
+ ]
646
+ },
647
+ {
648
+ "name": "jaw_screw0_head",
649
+ "body": "moving_jaw_so101_v1",
650
+ "group": "servo",
651
+ "polygon": [
652
+ [
653
+ -0.003848,
654
+ -0.009669,
655
+ -0.006049
656
+ ],
657
+ [
658
+ -0.004558,
659
+ -0.009479,
660
+ -0.006053
661
+ ],
662
+ [
663
+ -0.005077,
664
+ -0.00896,
665
+ -0.006065
666
+ ],
667
+ [
668
+ -0.005267,
669
+ -0.00825,
670
+ -0.006081
671
+ ],
672
+ [
673
+ -0.005077,
674
+ -0.007541,
675
+ -0.006098
676
+ ],
677
+ [
678
+ -0.004558,
679
+ -0.007022,
680
+ -0.006111
681
+ ],
682
+ [
683
+ -0.003848,
684
+ -0.006832,
685
+ -0.006117
686
+ ],
687
+ [
688
+ -0.003139,
689
+ -0.007022,
690
+ -0.006113
691
+ ],
692
+ [
693
+ -0.002619,
694
+ -0.007541,
695
+ -0.006101
696
+ ],
697
+ [
698
+ -0.002429,
699
+ -0.00825,
700
+ -0.006084
701
+ ],
702
+ [
703
+ -0.002619,
704
+ -0.00896,
705
+ -0.006067
706
+ ],
707
+ [
708
+ -0.003139,
709
+ -0.009479,
710
+ -0.006054
711
+ ]
712
+ ],
713
+ "offset": [
714
+ -0.0,
715
+ -5e-06,
716
+ -0.0002
717
+ ],
718
+ "color": [
719
+ 0.1218,
720
+ 0.0983,
721
+ 0.0923
722
+ ]
723
+ },
724
+ {
725
+ "name": "jaw_screw0_recess",
726
+ "body": "moving_jaw_so101_v1",
727
+ "group": "servo",
728
+ "polygon": [
729
+ [
730
+ -0.003849,
731
+ -0.008847,
732
+ -0.006319
733
+ ],
734
+ [
735
+ -0.004267,
736
+ -0.008674,
737
+ -0.006322
738
+ ],
739
+ [
740
+ -0.00444,
741
+ -0.008256,
742
+ -0.006332
743
+ ],
744
+ [
745
+ -0.004267,
746
+ -0.007838,
747
+ -0.006342
748
+ ],
749
+ [
750
+ -0.003849,
751
+ -0.007665,
752
+ -0.006347
753
+ ],
754
+ [
755
+ -0.00343,
756
+ -0.007838,
757
+ -0.006343
758
+ ],
759
+ [
760
+ -0.003257,
761
+ -0.008256,
762
+ -0.006333
763
+ ],
764
+ [
765
+ -0.00343,
766
+ -0.008674,
767
+ -0.006323
768
+ ]
769
+ ],
770
+ "offset": [
771
+ -0.0,
772
+ -2e-06,
773
+ -0.0001
774
+ ],
775
+ "color": [
776
+ 0.0915,
777
+ 0.0915,
778
+ 0.0915
779
+ ]
780
+ },
781
+ {
782
+ "name": "jaw_screw1_rim",
783
+ "body": "moving_jaw_so101_v1",
784
+ "group": "servo",
785
+ "polygon": [
786
+ [
787
+ 0.00538,
788
+ -0.009933,
789
+ -0.005402
790
+ ],
791
+ [
792
+ 0.004475,
793
+ -0.009753,
794
+ -0.005406
795
+ ],
796
+ [
797
+ 0.003708,
798
+ -0.00924,
799
+ -0.005417
800
+ ],
801
+ [
802
+ 0.003195,
803
+ -0.008473,
804
+ -0.005435
805
+ ],
806
+ [
807
+ 0.003015,
808
+ -0.007568,
809
+ -0.005456
810
+ ],
811
+ [
812
+ 0.003195,
813
+ -0.006663,
814
+ -0.005478
815
+ ],
816
+ [
817
+ 0.003708,
818
+ -0.005896,
819
+ -0.005496
820
+ ],
821
+ [
822
+ 0.004475,
823
+ -0.005384,
824
+ -0.005509
825
+ ],
826
+ [
827
+ 0.00538,
828
+ -0.005204,
829
+ -0.005515
830
+ ],
831
+ [
832
+ 0.006286,
833
+ -0.005384,
834
+ -0.005511
835
+ ],
836
+ [
837
+ 0.007053,
838
+ -0.005896,
839
+ -0.0055
840
+ ],
841
+ [
842
+ 0.007566,
843
+ -0.006664,
844
+ -0.005482
845
+ ],
846
+ [
847
+ 0.007746,
848
+ -0.007568,
849
+ -0.005461
850
+ ],
851
+ [
852
+ 0.007566,
853
+ -0.008473,
854
+ -0.005439
855
+ ],
856
+ [
857
+ 0.007053,
858
+ -0.00924,
859
+ -0.00542
860
+ ],
861
+ [
862
+ 0.006286,
863
+ -0.009753,
864
+ -0.005407
865
+ ]
866
+ ],
867
+ "offset": [
868
+ -1e-06,
869
+ -1.4e-05,
870
+ -0.0006
871
+ ],
872
+ "color": [
873
+ 0.3224,
874
+ 0.2602,
875
+ 0.2444
876
+ ]
877
+ },
878
+ {
879
+ "name": "jaw_screw1_head",
880
+ "body": "moving_jaw_so101_v1",
881
+ "group": "servo",
882
+ "polygon": [
883
+ [
884
+ 0.00538,
885
+ -0.009002,
886
+ -0.006075
887
+ ],
888
+ [
889
+ 0.00467,
890
+ -0.008812,
891
+ -0.006078
892
+ ],
893
+ [
894
+ 0.004151,
895
+ -0.008293,
896
+ -0.00609
897
+ ],
898
+ [
899
+ 0.003961,
900
+ -0.007584,
901
+ -0.006107
902
+ ],
903
+ [
904
+ 0.004151,
905
+ -0.006874,
906
+ -0.006124
907
+ ],
908
+ [
909
+ 0.00467,
910
+ -0.006355,
911
+ -0.006137
912
+ ],
913
+ [
914
+ 0.00538,
915
+ -0.006165,
916
+ -0.006142
917
+ ],
918
+ [
919
+ 0.006089,
920
+ -0.006355,
921
+ -0.006138
922
+ ],
923
+ [
924
+ 0.006609,
925
+ -0.006874,
926
+ -0.006126
927
+ ],
928
+ [
929
+ 0.006799,
930
+ -0.007584,
931
+ -0.00611
932
+ ],
933
+ [
934
+ 0.006609,
935
+ -0.008293,
936
+ -0.006093
937
+ ],
938
+ [
939
+ 0.006089,
940
+ -0.008812,
941
+ -0.00608
942
+ ]
943
+ ],
944
+ "offset": [
945
+ -0.0,
946
+ -5e-06,
947
+ -0.0002
948
+ ],
949
+ "color": [
950
+ 0.1218,
951
+ 0.0983,
952
+ 0.0923
953
+ ]
954
+ },
955
+ {
956
+ "name": "jaw_screw1_recess",
957
+ "body": "moving_jaw_so101_v1",
958
+ "group": "servo",
959
+ "polygon": [
960
+ [
961
+ 0.00538,
962
+ -0.008181,
963
+ -0.006344
964
+ ],
965
+ [
966
+ 0.004961,
967
+ -0.008008,
968
+ -0.006348
969
+ ],
970
+ [
971
+ 0.004788,
972
+ -0.00759,
973
+ -0.006358
974
+ ],
975
+ [
976
+ 0.004961,
977
+ -0.007172,
978
+ -0.006368
979
+ ],
980
+ [
981
+ 0.00538,
982
+ -0.006999,
983
+ -0.006372
984
+ ],
985
+ [
986
+ 0.005798,
987
+ -0.007172,
988
+ -0.006369
989
+ ],
990
+ [
991
+ 0.005971,
992
+ -0.00759,
993
+ -0.006359
994
+ ],
995
+ [
996
+ 0.005798,
997
+ -0.008008,
998
+ -0.006349
999
+ ]
1000
+ ],
1001
+ "offset": [
1002
+ -0.0,
1003
+ -2e-06,
1004
+ -0.0001
1005
+ ],
1006
+ "color": [
1007
+ 0.0915,
1008
+ 0.0915,
1009
+ 0.0915
1010
+ ]
1011
+ },
1012
+ {
1013
+ "name": "jaw_screw2_rim",
1014
+ "body": "moving_jaw_so101_v1",
1015
+ "group": "servo",
1016
+ "polygon": [
1017
+ [
1018
+ -0.003348,
1019
+ -0.000881,
1020
+ -0.005608
1021
+ ],
1022
+ [
1023
+ -0.004253,
1024
+ -0.000701,
1025
+ -0.005612
1026
+ ],
1027
+ [
1028
+ -0.00502,
1029
+ -0.000188,
1030
+ -0.005623
1031
+ ],
1032
+ [
1033
+ -0.005533,
1034
+ 0.000579,
1035
+ -0.005641
1036
+ ],
1037
+ [
1038
+ -0.005713,
1039
+ 0.001484,
1040
+ -0.005662
1041
+ ],
1042
+ [
1043
+ -0.005533,
1044
+ 0.002389,
1045
+ -0.005684
1046
+ ],
1047
+ [
1048
+ -0.00502,
1049
+ 0.003156,
1050
+ -0.005703
1051
+ ],
1052
+ [
1053
+ -0.004253,
1054
+ 0.003668,
1055
+ -0.005716
1056
+ ],
1057
+ [
1058
+ -0.003348,
1059
+ 0.003848,
1060
+ -0.005721
1061
+ ],
1062
+ [
1063
+ -0.002443,
1064
+ 0.003668,
1065
+ -0.005717
1066
+ ],
1067
+ [
1068
+ -0.001676,
1069
+ 0.003156,
1070
+ -0.005706
1071
+ ],
1072
+ [
1073
+ -0.001163,
1074
+ 0.002389,
1075
+ -0.005688
1076
+ ],
1077
+ [
1078
+ -0.000983,
1079
+ 0.001484,
1080
+ -0.005667
1081
+ ],
1082
+ [
1083
+ -0.001163,
1084
+ 0.000579,
1085
+ -0.005645
1086
+ ],
1087
+ [
1088
+ -0.001676,
1089
+ -0.000188,
1090
+ -0.005627
1091
+ ],
1092
+ [
1093
+ -0.002443,
1094
+ -0.000701,
1095
+ -0.005614
1096
+ ]
1097
+ ],
1098
+ "offset": [
1099
+ -1e-06,
1100
+ -1.4e-05,
1101
+ -0.0006
1102
+ ],
1103
+ "color": [
1104
+ 0.3224,
1105
+ 0.2602,
1106
+ 0.2444
1107
+ ]
1108
+ },
1109
+ {
1110
+ "name": "jaw_screw2_head",
1111
+ "body": "moving_jaw_so101_v1",
1112
+ "group": "servo",
1113
+ "polygon": [
1114
+ [
1115
+ -0.003349,
1116
+ 5e-05,
1117
+ -0.006281
1118
+ ],
1119
+ [
1120
+ -0.004058,
1121
+ 0.00024,
1122
+ -0.006284
1123
+ ],
1124
+ [
1125
+ -0.004578,
1126
+ 0.000759,
1127
+ -0.006296
1128
+ ],
1129
+ [
1130
+ -0.004768,
1131
+ 0.001468,
1132
+ -0.006313
1133
+ ],
1134
+ [
1135
+ -0.004578,
1136
+ 0.002178,
1137
+ -0.00633
1138
+ ],
1139
+ [
1140
+ -0.004058,
1141
+ 0.002697,
1142
+ -0.006343
1143
+ ],
1144
+ [
1145
+ -0.003349,
1146
+ 0.002887,
1147
+ -0.006348
1148
+ ],
1149
+ [
1150
+ -0.002639,
1151
+ 0.002697,
1152
+ -0.006344
1153
+ ],
1154
+ [
1155
+ -0.00212,
1156
+ 0.002178,
1157
+ -0.006333
1158
+ ],
1159
+ [
1160
+ -0.00193,
1161
+ 0.001468,
1162
+ -0.006316
1163
+ ],
1164
+ [
1165
+ -0.00212,
1166
+ 0.000759,
1167
+ -0.006299
1168
+ ],
1169
+ [
1170
+ -0.002639,
1171
+ 0.00024,
1172
+ -0.006286
1173
+ ]
1174
+ ],
1175
+ "offset": [
1176
+ -0.0,
1177
+ -5e-06,
1178
+ -0.0002
1179
+ ],
1180
+ "color": [
1181
+ 0.1218,
1182
+ 0.0983,
1183
+ 0.0923
1184
+ ]
1185
+ },
1186
+ {
1187
+ "name": "jaw_screw2_recess",
1188
+ "body": "moving_jaw_so101_v1",
1189
+ "group": "servo",
1190
+ "polygon": [
1191
+ [
1192
+ -0.003349,
1193
+ 0.000871,
1194
+ -0.00655
1195
+ ],
1196
+ [
1197
+ -0.003767,
1198
+ 0.001044,
1199
+ -0.006554
1200
+ ],
1201
+ [
1202
+ -0.00394,
1203
+ 0.001462,
1204
+ -0.006564
1205
+ ],
1206
+ [
1207
+ -0.003767,
1208
+ 0.00188,
1209
+ -0.006574
1210
+ ],
1211
+ [
1212
+ -0.003349,
1213
+ 0.002054,
1214
+ -0.006578
1215
+ ],
1216
+ [
1217
+ -0.002931,
1218
+ 0.00188,
1219
+ -0.006575
1220
+ ],
1221
+ [
1222
+ -0.002758,
1223
+ 0.001462,
1224
+ -0.006565
1225
+ ],
1226
+ [
1227
+ -0.002931,
1228
+ 0.001044,
1229
+ -0.006555
1230
+ ]
1231
+ ],
1232
+ "offset": [
1233
+ -0.0,
1234
+ -2e-06,
1235
+ -0.0001
1236
+ ],
1237
+ "color": [
1238
+ 0.0915,
1239
+ 0.0915,
1240
+ 0.0915
1241
+ ]
1242
+ },
1243
+ {
1244
+ "name": "jaw_screw3_rim",
1245
+ "body": "moving_jaw_so101_v1",
1246
+ "group": "servo",
1247
+ "polygon": [
1248
+ [
1249
+ 0.005854,
1250
+ -0.00057,
1251
+ -0.005625
1252
+ ],
1253
+ [
1254
+ 0.004949,
1255
+ -0.00039,
1256
+ -0.005629
1257
+ ],
1258
+ [
1259
+ 0.004181,
1260
+ 0.000123,
1261
+ -0.00564
1262
+ ],
1263
+ [
1264
+ 0.003669,
1265
+ 0.00089,
1266
+ -0.005658
1267
+ ],
1268
+ [
1269
+ 0.003489,
1270
+ 0.001795,
1271
+ -0.005679
1272
+ ],
1273
+ [
1274
+ 0.003669,
1275
+ 0.0027,
1276
+ -0.005701
1277
+ ],
1278
+ [
1279
+ 0.004181,
1280
+ 0.003467,
1281
+ -0.00572
1282
+ ],
1283
+ [
1284
+ 0.004949,
1285
+ 0.003979,
1286
+ -0.005733
1287
+ ],
1288
+ [
1289
+ 0.005854,
1290
+ 0.004159,
1291
+ -0.005738
1292
+ ],
1293
+ [
1294
+ 0.006759,
1295
+ 0.003979,
1296
+ -0.005734
1297
+ ],
1298
+ [
1299
+ 0.007526,
1300
+ 0.003467,
1301
+ -0.005723
1302
+ ],
1303
+ [
1304
+ 0.008039,
1305
+ 0.0027,
1306
+ -0.005705
1307
+ ],
1308
+ [
1309
+ 0.008219,
1310
+ 0.001795,
1311
+ -0.005684
1312
+ ],
1313
+ [
1314
+ 0.008039,
1315
+ 0.00089,
1316
+ -0.005662
1317
+ ],
1318
+ [
1319
+ 0.007526,
1320
+ 0.000123,
1321
+ -0.005644
1322
+ ],
1323
+ [
1324
+ 0.006759,
1325
+ -0.00039,
1326
+ -0.005631
1327
+ ]
1328
+ ],
1329
+ "offset": [
1330
+ -1e-06,
1331
+ -1.4e-05,
1332
+ -0.0006
1333
+ ],
1334
+ "color": [
1335
+ 0.3224,
1336
+ 0.2602,
1337
+ 0.2444
1338
+ ]
1339
+ },
1340
+ {
1341
+ "name": "jaw_screw3_head",
1342
+ "body": "moving_jaw_so101_v1",
1343
+ "group": "servo",
1344
+ "polygon": [
1345
+ [
1346
+ 0.005853,
1347
+ 0.000361,
1348
+ -0.006298
1349
+ ],
1350
+ [
1351
+ 0.005144,
1352
+ 0.000551,
1353
+ -0.006301
1354
+ ],
1355
+ [
1356
+ 0.004624,
1357
+ 0.00107,
1358
+ -0.006313
1359
+ ],
1360
+ [
1361
+ 0.004434,
1362
+ 0.001779,
1363
+ -0.00633
1364
+ ],
1365
+ [
1366
+ 0.004624,
1367
+ 0.002489,
1368
+ -0.006347
1369
+ ],
1370
+ [
1371
+ 0.005144,
1372
+ 0.003008,
1373
+ -0.00636
1374
+ ],
1375
+ [
1376
+ 0.005853,
1377
+ 0.003198,
1378
+ -0.006365
1379
+ ],
1380
+ [
1381
+ 0.006563,
1382
+ 0.003008,
1383
+ -0.006361
1384
+ ],
1385
+ [
1386
+ 0.007082,
1387
+ 0.002489,
1388
+ -0.00635
1389
+ ],
1390
+ [
1391
+ 0.007272,
1392
+ 0.001779,
1393
+ -0.006333
1394
+ ],
1395
+ [
1396
+ 0.007082,
1397
+ 0.00107,
1398
+ -0.006316
1399
+ ],
1400
+ [
1401
+ 0.006563,
1402
+ 0.000551,
1403
+ -0.006303
1404
+ ]
1405
+ ],
1406
+ "offset": [
1407
+ -0.0,
1408
+ -5e-06,
1409
+ -0.0002
1410
+ ],
1411
+ "color": [
1412
+ 0.1218,
1413
+ 0.0983,
1414
+ 0.0923
1415
+ ]
1416
+ },
1417
+ {
1418
+ "name": "jaw_screw3_recess",
1419
+ "body": "moving_jaw_so101_v1",
1420
+ "group": "servo",
1421
+ "polygon": [
1422
+ [
1423
+ 0.005853,
1424
+ 0.001182,
1425
+ -0.006567
1426
+ ],
1427
+ [
1428
+ 0.005435,
1429
+ 0.001355,
1430
+ -0.006571
1431
+ ],
1432
+ [
1433
+ 0.005262,
1434
+ 0.001773,
1435
+ -0.006581
1436
+ ],
1437
+ [
1438
+ 0.005435,
1439
+ 0.002191,
1440
+ -0.006591
1441
+ ],
1442
+ [
1443
+ 0.005853,
1444
+ 0.002365,
1445
+ -0.006595
1446
+ ],
1447
+ [
1448
+ 0.006271,
1449
+ 0.002191,
1450
+ -0.006592
1451
+ ],
1452
+ [
1453
+ 0.006444,
1454
+ 0.001773,
1455
+ -0.006582
1456
+ ],
1457
+ [
1458
+ 0.006271,
1459
+ 0.001355,
1460
+ -0.006572
1461
+ ]
1462
+ ],
1463
+ "offset": [
1464
+ -0.0,
1465
+ -2e-06,
1466
+ -0.0001
1467
+ ],
1468
+ "color": [
1469
+ 0.0915,
1470
+ 0.0915,
1471
+ 0.0915
1472
+ ]
1473
+ },
1474
+ {
1475
+ "name": "jaw_hub",
1476
+ "body": "moving_jaw_so101_v1",
1477
+ "group": "servo",
1478
+ "polygon": [
1479
+ [
1480
+ 0.001013,
1481
+ -0.003026,
1482
+ -0.005562
1483
+ ],
1484
+ [
1485
+ 0.000422,
1486
+ -0.002868,
1487
+ -0.005565
1488
+ ],
1489
+ [
1490
+ -1.1e-05,
1491
+ -0.002435,
1492
+ -0.005575
1493
+ ],
1494
+ [
1495
+ -0.000169,
1496
+ -0.001844,
1497
+ -0.005589
1498
+ ],
1499
+ [
1500
+ -1.1e-05,
1501
+ -0.001253,
1502
+ -0.005603
1503
+ ],
1504
+ [
1505
+ 0.000422,
1506
+ -0.00082,
1507
+ -0.005614
1508
+ ],
1509
+ [
1510
+ 0.001013,
1511
+ -0.000662,
1512
+ -0.005618
1513
+ ],
1514
+ [
1515
+ 0.001605,
1516
+ -0.00082,
1517
+ -0.005615
1518
+ ],
1519
+ [
1520
+ 0.002037,
1521
+ -0.001253,
1522
+ -0.005605
1523
+ ],
1524
+ [
1525
+ 0.002196,
1526
+ -0.001844,
1527
+ -0.005591
1528
+ ],
1529
+ [
1530
+ 0.002037,
1531
+ -0.002435,
1532
+ -0.005577
1533
+ ],
1534
+ [
1535
+ 0.001605,
1536
+ -0.002868,
1537
+ -0.005566
1538
+ ]
1539
+ ],
1540
+ "offset": [
1541
+ -0.0,
1542
+ -2e-06,
1543
+ -0.0001
1544
+ ],
1545
+ "color": [
1546
+ 0.2,
1547
+ 0.2,
1548
+ 0.2
1549
+ ]
1550
+ },
1551
+ {
1552
+ "name": "fixed_jaw_upper",
1553
+ "body": "camera_mount",
1554
+ "group": "printed",
1555
+ "polygon": [
1556
+ [
1557
+ -0.02361,
1558
+ 0.004371,
1559
+ -0.085465
1560
+ ],
1561
+ [
1562
+ -0.011907,
1563
+ 0.01023,
1564
+ -0.077948
1565
+ ],
1566
+ [
1567
+ -0.004197,
1568
+ 0.026704,
1569
+ -0.035982
1570
+ ],
1571
+ [
1572
+ -0.030809,
1573
+ 0.017707,
1574
+ -0.040375
1575
+ ]
1576
+ ],
1577
+ "offset": [
1578
+ -5.2e-05,
1579
+ 0.000183,
1580
+ -6.2e-05
1581
+ ],
1582
+ "color": [
1583
+ 0.361,
1584
+ 0.3367,
1585
+ 0.3077
1586
+ ]
1587
+ },
1588
+ {
1589
+ "name": "fixed_jaw_lower",
1590
+ "body": "camera_mount",
1591
+ "group": "printed",
1592
+ "polygon": [
1593
+ [
1594
+ -0.030809,
1595
+ 0.017707,
1596
+ -0.040375
1597
+ ],
1598
+ [
1599
+ -0.011578,
1600
+ 0.024061,
1601
+ -0.037634
1602
+ ],
1603
+ [
1604
+ -0.006998,
1605
+ 0.032751,
1606
+ -0.015921
1607
+ ],
1608
+ [
1609
+ -0.024394,
1610
+ 0.028871,
1611
+ -0.012921
1612
+ ],
1613
+ [
1614
+ -0.032714,
1615
+ 0.019284,
1616
+ -0.034174
1617
+ ]
1618
+ ],
1619
+ "offset": [
1620
+ -5.2e-05,
1621
+ 0.000183,
1622
+ -6.2e-05
1623
+ ],
1624
+ "color": [
1625
+ 0.3109,
1626
+ 0.2981,
1627
+ 0.2695
1628
+ ]
1629
+ },
1630
+ {
1631
+ "name": "jaw_upper",
1632
+ "body": "moving_jaw_so101_v1",
1633
+ "group": "printed",
1634
+ "polygon": [
1635
+ [
1636
+ -0.006786,
1637
+ -0.052277,
1638
+ 0.010364
1639
+ ],
1640
+ [
1641
+ 0.001207,
1642
+ -0.052485,
1643
+ 0.010668
1644
+ ],
1645
+ [
1646
+ 0.005265,
1647
+ -0.0145,
1648
+ -0.006154
1649
+ ],
1650
+ [
1651
+ -0.008904,
1652
+ -0.014856,
1653
+ -0.006371
1654
+ ]
1655
+ ],
1656
+ "offset": [
1657
+ 5e-06,
1658
+ -8.1e-05,
1659
+ -0.000183
1660
+ ],
1661
+ "color": [
1662
+ 0.4154,
1663
+ 0.3873,
1664
+ 0.3587
1665
+ ]
1666
+ }
1667
+ ]
so101_pick_place/code/configs/so101_pick_place/real_scene_v2.json ADDED
@@ -0,0 +1,627 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "real_scene_v2",
3
+ "calib": "/home/harry/so101_r2s_claude/calib/calib_v1.json",
4
+ "student_view": {
5
+ "external": {
6
+ "crop": [
7
+ 52,
8
+ 103,
9
+ 288,
10
+ 288
11
+ ],
12
+ "out": [
13
+ 224,
14
+ 224
15
+ ],
16
+ "interp": "area"
17
+ },
18
+ "wrist": {
19
+ "crop": [
20
+ 0,
21
+ 0,
22
+ 640,
23
+ 480
24
+ ],
25
+ "out": [
26
+ 224,
27
+ 224
28
+ ],
29
+ "interp": "area"
30
+ }
31
+ },
32
+ "geometry": {
33
+ "floor_xy": [
34
+ -0.045,
35
+ 0.59,
36
+ -0.456,
37
+ 0.457
38
+ ],
39
+ "walls": [
40
+ [
41
+ [
42
+ -0.045,
43
+ 0.457
44
+ ],
45
+ [
46
+ 0.59,
47
+ 0.457
48
+ ],
49
+ 0.53
50
+ ],
51
+ [
52
+ [
53
+ 0.59,
54
+ 0.457
55
+ ],
56
+ [
57
+ 0.59,
58
+ -0.456
59
+ ],
60
+ 0.38
61
+ ]
62
+ ],
63
+ "wall_thickness": 0.005,
64
+ "strip": {
65
+ "from": [
66
+ 0.585,
67
+ -0.42,
68
+ 0.33
69
+ ],
70
+ "to": [
71
+ 0.585,
72
+ 0.42,
73
+ 0.43
74
+ ],
75
+ "size": [
76
+ 0.03,
77
+ 0.01
78
+ ]
79
+ },
80
+ "room": {
81
+ "center": [
82
+ 0.3,
83
+ 0.0,
84
+ 0.6
85
+ ],
86
+ "half": [
87
+ 2.5,
88
+ 2.5,
89
+ 1.8
90
+ ],
91
+ "floor_z": -0.75
92
+ },
93
+ "ceiling": null,
94
+ "table_plane": null,
95
+ "mat_thickness": 0.001,
96
+ "plate_thickness": 0.001,
97
+ "parts": [
98
+ {
99
+ "name": "camera_bracket_plate",
100
+ "body": "camera_mount",
101
+ "group": "board",
102
+ "polygon": [
103
+ [
104
+ 0.013618,
105
+ 0.025993,
106
+ -0.007363
107
+ ],
108
+ [
109
+ -0.007618,
110
+ 0.030169,
111
+ -0.006955
112
+ ],
113
+ [
114
+ -0.011829,
115
+ 0.022939,
116
+ -0.03436
117
+ ],
118
+ [
119
+ 0.012955,
120
+ 0.017344,
121
+ -0.037294
122
+ ]
123
+ ],
124
+ "offset": [
125
+ 0.000541,
126
+ 0.002832,
127
+ -0.00083
128
+ ]
129
+ }
130
+ ]
131
+ },
132
+ "colors": {
133
+ "printed": [
134
+ 0.713,
135
+ 0.6798,
136
+ 0.6153
137
+ ],
138
+ "servo": [
139
+ 0.1196,
140
+ 0.1331,
141
+ 0.1162
142
+ ],
143
+ "cube": [
144
+ 0.06,
145
+ 0.361,
146
+ 0.1295
147
+ ],
148
+ "plate": [
149
+ 0.6544,
150
+ 0.0844,
151
+ 0.0855
152
+ ],
153
+ "floor": [
154
+ 0.85,
155
+ 0.85,
156
+ 0.85
157
+ ],
158
+ "mat": [
159
+ 0.0796,
160
+ 0.0837,
161
+ 0.0814
162
+ ],
163
+ "walls": [
164
+ 0.6021,
165
+ 0.5967,
166
+ 0.5836
167
+ ],
168
+ "board": [
169
+ 0.1038,
170
+ 0.0912,
171
+ 0.0908
172
+ ],
173
+ "room": [
174
+ 0.1637,
175
+ 0.1546,
176
+ 0.0971
177
+ ],
178
+ "room_floor": [
179
+ 0.1356,
180
+ 0.131,
181
+ 0.0932
182
+ ],
183
+ "strip": [
184
+ 0.2689,
185
+ 0.2689,
186
+ 0.2689
187
+ ]
188
+ },
189
+ "light": {
190
+ "lights": [
191
+ {
192
+ "type": "point",
193
+ "position": [
194
+ 0.55,
195
+ 0.0,
196
+ 0.39
197
+ ],
198
+ "shadow": false
199
+ },
200
+ {
201
+ "type": "directional",
202
+ "direction": [
203
+ 0.0,
204
+ 0.0,
205
+ -1.0
206
+ ],
207
+ "shadow": false,
208
+ "intensity": 0.2331,
209
+ "center": [
210
+ 0.25,
211
+ 0.0,
212
+ 0.0
213
+ ]
214
+ },
215
+ {
216
+ "type": "directional",
217
+ "direction": [
218
+ -1.0,
219
+ 0.0,
220
+ -0.35
221
+ ],
222
+ "shadow": false,
223
+ "intensity": 0.2322,
224
+ "center": [
225
+ 0.25,
226
+ 0.0,
227
+ 0.0
228
+ ]
229
+ },
230
+ {
231
+ "type": "directional",
232
+ "direction": [
233
+ 1.0,
234
+ 0.0,
235
+ -0.35
236
+ ],
237
+ "shadow": false,
238
+ "intensity": 0.152,
239
+ "center": [
240
+ 0.25,
241
+ 0.0,
242
+ 0.0
243
+ ]
244
+ },
245
+ {
246
+ "type": "directional",
247
+ "direction": [
248
+ 0.0,
249
+ -1.0,
250
+ -0.35
251
+ ],
252
+ "shadow": false,
253
+ "intensity": 0.6659,
254
+ "center": [
255
+ 0.25,
256
+ 0.0,
257
+ 0.0
258
+ ]
259
+ },
260
+ {
261
+ "type": "directional",
262
+ "direction": [
263
+ 0.0,
264
+ 1.0,
265
+ -0.35
266
+ ],
267
+ "shadow": false,
268
+ "intensity": 0.4755,
269
+ "center": [
270
+ 0.25,
271
+ 0.0,
272
+ 0.0
273
+ ]
274
+ },
275
+ {
276
+ "type": "directional",
277
+ "direction": [
278
+ 0.0,
279
+ 0.0,
280
+ 1.0
281
+ ],
282
+ "shadow": false,
283
+ "intensity": 0.6029,
284
+ "center": [
285
+ 0.25,
286
+ 0.0,
287
+ 0.0
288
+ ]
289
+ },
290
+ {
291
+ "type": "directional",
292
+ "direction": [
293
+ -1.0,
294
+ -1.0,
295
+ -1.0
296
+ ],
297
+ "shadow": false,
298
+ "intensity": 0.2813,
299
+ "center": [
300
+ 0.25,
301
+ 0.0,
302
+ 0.0
303
+ ]
304
+ },
305
+ {
306
+ "type": "directional",
307
+ "direction": [
308
+ -1.0,
309
+ 1.0,
310
+ -1.0
311
+ ],
312
+ "shadow": false,
313
+ "intensity": 0.2956,
314
+ "center": [
315
+ 0.25,
316
+ 0.0,
317
+ 0.0
318
+ ]
319
+ },
320
+ {
321
+ "type": "directional",
322
+ "direction": [
323
+ 1.0,
324
+ -1.0,
325
+ -1.0
326
+ ],
327
+ "shadow": false,
328
+ "intensity": 0.2438,
329
+ "center": [
330
+ 0.25,
331
+ 0.0,
332
+ 0.0
333
+ ]
334
+ },
335
+ {
336
+ "type": "directional",
337
+ "direction": [
338
+ 1.0,
339
+ 1.0,
340
+ -1.0
341
+ ],
342
+ "shadow": false,
343
+ "intensity": 0.2614,
344
+ "center": [
345
+ 0.25,
346
+ 0.0,
347
+ 0.0
348
+ ]
349
+ },
350
+ {
351
+ "type": "directional",
352
+ "direction": [
353
+ -1.0,
354
+ -1.0,
355
+ 1.0
356
+ ],
357
+ "shadow": false,
358
+ "intensity": 0.9642,
359
+ "center": [
360
+ 0.25,
361
+ 0.0,
362
+ 0.0
363
+ ]
364
+ },
365
+ {
366
+ "type": "directional",
367
+ "direction": [
368
+ -1.0,
369
+ 1.0,
370
+ 1.0
371
+ ],
372
+ "shadow": false,
373
+ "intensity": 0.5733,
374
+ "center": [
375
+ 0.25,
376
+ 0.0,
377
+ 0.0
378
+ ]
379
+ },
380
+ {
381
+ "type": "directional",
382
+ "direction": [
383
+ 1.0,
384
+ -1.0,
385
+ 1.0
386
+ ],
387
+ "shadow": false
388
+ },
389
+ {
390
+ "type": "directional",
391
+ "direction": [
392
+ 1.0,
393
+ -1.0,
394
+ 1.0
395
+ ],
396
+ "shadow": false
397
+ },
398
+ {
399
+ "type": "directional",
400
+ "direction": [
401
+ 1.0,
402
+ -1.0,
403
+ 1.0
404
+ ],
405
+ "shadow": false,
406
+ "intensity": 0.2441,
407
+ "center": [
408
+ 0.25,
409
+ 0.0,
410
+ 0.0
411
+ ]
412
+ },
413
+ {
414
+ "type": "directional",
415
+ "direction": [
416
+ 1.0,
417
+ 1.0,
418
+ 1.0
419
+ ],
420
+ "shadow": false,
421
+ "intensity": 0.5668,
422
+ "center": [
423
+ 0.25,
424
+ 0.0,
425
+ 0.0
426
+ ]
427
+ }
428
+ ],
429
+ "ambient": true,
430
+ "shadows": false,
431
+ "sky": [
432
+ 20,
433
+ 20,
434
+ 20
435
+ ]
436
+ },
437
+ "tone": {
438
+ "external": {
439
+ "exposure": 0.39731,
440
+ "wb": [
441
+ 0.90161,
442
+ 1.0,
443
+ 0.92806
444
+ ],
445
+ "black": [
446
+ -0.02908,
447
+ -0.04135,
448
+ -0.04141
449
+ ],
450
+ "gamma": 1.35405,
451
+ "vignette": 2.1107
452
+ },
453
+ "wrist": {
454
+ "exposure": 0.48968,
455
+ "wb": [
456
+ 0.98961,
457
+ 1.0,
458
+ 0.96236
459
+ ],
460
+ "black": [
461
+ -0.04404,
462
+ -0.0359,
463
+ -0.04162
464
+ ],
465
+ "gamma": 1.05565,
466
+ "vignette": 0.18174
467
+ }
468
+ },
469
+ "fit": {
470
+ "source": "/home/harry/so101_r2s_claude/scene/out/fit_B5.json",
471
+ "config": "B",
472
+ "rms_nominal_fit": 26.994945526123047,
473
+ "rms_nominal_heldout": 27.508882522583008,
474
+ "frame_exposure_log_std": [
475
+ 0.03232957050204277,
476
+ 0.0951780155301094
477
+ ]
478
+ },
479
+ "dr": {
480
+ "bright": {
481
+ "printed": [
482
+ 0.85,
483
+ 1.15
484
+ ],
485
+ "servo": [
486
+ 0.7,
487
+ 1.5
488
+ ],
489
+ "cube": [
490
+ 0.8,
491
+ 1.2
492
+ ],
493
+ "plate": [
494
+ 0.8,
495
+ 1.2
496
+ ],
497
+ "floor": [
498
+ 0.9,
499
+ 1.08
500
+ ],
501
+ "mat": [
502
+ 0.7,
503
+ 1.5
504
+ ],
505
+ "walls": [
506
+ 0.8,
507
+ 1.12
508
+ ],
509
+ "board": [
510
+ 0.7,
511
+ 1.5
512
+ ],
513
+ "room": [
514
+ 0.2,
515
+ 2.5
516
+ ],
517
+ "room_floor": [
518
+ 0.2,
519
+ 2.5
520
+ ],
521
+ "strip": [
522
+ 1.0,
523
+ 1.0
524
+ ]
525
+ },
526
+ "tint": {
527
+ "printed": 0.04,
528
+ "servo": 0.08,
529
+ "cube": 0.08,
530
+ "plate": 0.08,
531
+ "floor": 0.03,
532
+ "mat": 0.1,
533
+ "walls": 0.04,
534
+ "board": 0.08,
535
+ "room": 0.45,
536
+ "room_floor": 0.45,
537
+ "strip": 0.0
538
+ },
539
+ "cam_pos": {
540
+ "external": 0.008,
541
+ "wrist": 0.003
542
+ },
543
+ "cam_rot": {
544
+ "external": 0.026,
545
+ "wrist": 0.035
546
+ },
547
+ "mat_xy": 0.01,
548
+ "mat_yaw": 0.052,
549
+ "wall_xy": 0.02,
550
+ "light_deg": 15.0,
551
+ "light_pos": 0.05,
552
+ "exposure": {
553
+ "external": [
554
+ 0.8,
555
+ 1.35
556
+ ],
557
+ "wrist": [
558
+ 0.7,
559
+ 1.7
560
+ ]
561
+ },
562
+ "wb": {
563
+ "external": 0.06,
564
+ "wrist": 0.06
565
+ },
566
+ "black": [
567
+ -0.01,
568
+ 0.01
569
+ ],
570
+ "gamma": [
571
+ 0.85,
572
+ 1.25
573
+ ],
574
+ "vignette": {
575
+ "external": [
576
+ -0.8,
577
+ 0.8
578
+ ],
579
+ "wrist": [
580
+ -0.2,
581
+ 0.8
582
+ ]
583
+ },
584
+ "focal": 0.03,
585
+ "pp_px": 3.0,
586
+ "focal_levels": 7
587
+ },
588
+ "image_fx": {
589
+ "nominal_blur_px": 0.55,
590
+ "nominal_chroma_px": {
591
+ "external": 2.0,
592
+ "wrist": 0.0
593
+ },
594
+ "p_noise": 0.8,
595
+ "noise": [
596
+ 0.002,
597
+ 0.012
598
+ ],
599
+ "p_blur": 0.3,
600
+ "blur_px": [
601
+ 0.2,
602
+ 0.8
603
+ ],
604
+ "p_motion": 0.2,
605
+ "motion_px": [
606
+ 1.0,
607
+ 3.0
608
+ ],
609
+ "p_jpeg": 0.8,
610
+ "jpeg_quality": [
611
+ 50,
612
+ 95
613
+ ]
614
+ },
615
+ "render": {
616
+ "supersample": 1
617
+ },
618
+ "notes": [
619
+ {
620
+ "doc": "/home/harry/so101_r2s_claude/docs/scene_match.md",
621
+ "geometry": "training geometry: table / mat top at z = 0 (sim physics), plate 1 mm. The paired real-state check used the measured table plane (geometry.table_plane = 'calib') and the plate thickness of calib_v1 (3.9 mm).",
622
+ "load": "RealScene.from_path(this file); RealDR.from_scene(real); camera_fx.ImageFX.from_dict(real.image_fx) (random effects only: the renderer applies the nominal blur / chroma itself)",
623
+ "student_view": "the real-robot code must use this student_view (hw_lib.view_specs reads the dict it is given)"
624
+ },
625
+ "v2 (2026-10-22, main session, after ~/so101_r2s_claude/scene/REVIEW.md sec. 3): v1 + room / room_floor nominal colour darker and more yellow (x 0.8, 0.75, 0.55 per channel; review: real room darker and more yellow than 81 % of the draws), room brightness 0.2-2.5 and tint +-0.45, wider tone-map exposure (external 0.8-1.35, wrist 0.7-1.7: clipped highlights, real wrist frames have 9.4 % pixels >= 245) and gamma 0.85-1.25 (real contrast at rank 0.81 / 0.93 of the v1 draws). Geometry, lights, nominal tone map and image_fx unchanged."
626
+ ]
627
+ }
so101_pick_place/code/configs/so101_pick_place/so101_follower_lerobot_calib.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "shoulder_pan": {
3
+ "id": 1,
4
+ "drive_mode": 0,
5
+ "homing_offset": 1252,
6
+ "range_min": 999,
7
+ "range_max": 2937
8
+ },
9
+ "shoulder_lift": {
10
+ "id": 2,
11
+ "drive_mode": 0,
12
+ "homing_offset": -1476,
13
+ "range_min": 811,
14
+ "range_max": 3194
15
+ },
16
+ "elbow_flex": {
17
+ "id": 3,
18
+ "drive_mode": 0,
19
+ "homing_offset": 1483,
20
+ "range_min": 840,
21
+ "range_max": 3030
22
+ },
23
+ "wrist_flex": {
24
+ "id": 4,
25
+ "drive_mode": 0,
26
+ "homing_offset": -673,
27
+ "range_min": 914,
28
+ "range_max": 3263
29
+ },
30
+ "wrist_roll": {
31
+ "id": 5,
32
+ "drive_mode": 0,
33
+ "homing_offset": -182,
34
+ "range_min": 0,
35
+ "range_max": 4095
36
+ },
37
+ "gripper": {
38
+ "id": 6,
39
+ "drive_mode": 0,
40
+ "homing_offset": 758,
41
+ "range_min": 2033,
42
+ "range_max": 3551
43
+ }
44
+ }
so101_pick_place/code/configs/so101_pick_place/teacher/env_jt_b140.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"starts": "artifacts/so101_pick_place/rl_inputs/banks/bank_pp_split0.npz"}
so101_pick_place/code/configs/so101_pick_place/teacher/env_jt_h110.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"starts": "artifacts/so101_pick_place/rl_inputs/banks/bank_pp_split0.npz", "task": {"hold_cap_s": 2.5}, "note": "training-only: at most 2.5 s held in the air (evaluation rule 3.5 s)"}
so101_pick_place/code/configs/so101_policy/ppo/curriculum_tol_v3.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "Tolerance ladder v3 (build4_ppo2.md, 2026-10-12 00:10): curriculum_tol_v2 with std_reset false at every promotion. In the kinematic-world sweep both CARRY-macro runs (kE, kF) collapsed right after the promotion to 15 mm (validation 67 / 71 % at 30 mm -> 7 / 11 % at 15 mm, 10 iterations later): the promotion raised the move std from 0.18 back to 0.3 (train_cfg std_reset), and with the CARRY macro a[0:2] x 0.32 m turns that into about 10 cm of carry-target noise. The default-carry run kC did not collapse (89.6 -> 95.1 %).",
3
+ "stages": [
4
+ {"name": "tol30", "task": {"tol_xy": 0.030, "tol_yaw": 0.5235987755982988}, "promote": 0.6, "min_iters": 20},
5
+ {"name": "tol15", "task": {"tol_xy": 0.015, "tol_yaw": 0.2617993877991494}, "promote": 0.75, "min_iters": 20, "std_reset": false},
6
+ {"name": "tol10", "task": {"tol_xy": 0.010, "tol_yaw": 0.17453292519943295}, "std_reset": false}
7
+ ]
8
+ }
so101_pick_place/code/configs/so101_policy/ppo/env_v2.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "env_v2 (2026-10-11 23:10, build4_ppo2.md): env_v1 + the decoder PPO options that apply in EVERY world (decoder module docstring, 'PPO options'): grasp_gate (a GRASP trigger whose descent end puts the cube outside 4.5 mm / 10 mm / 2.5 deg is ignored at no cost: the permanent rule instead of the grasp assist), grasp_latch (a started GRASP is not aborted by a[4]) and abort_action (a 7th action a[6] = the explicit abort; review_code_v2 R3). Task rules pinned (review R6): self_rule and ghost_rule on (the TaskConfig defaults since 21:24). Default free-motion carry (decoder cosine blend). Starts: production_plus split 0 task-family first states (25,197).",
3
+ "starts": "artifacts/so101_pick_place/nrd_data/production_plus",
4
+ "start_split": 0,
5
+ "pool_size": 65536,
6
+ "nrd_cuda_graph": true,
7
+ "task": {"self_rule": true, "ghost_rule": true},
8
+ "decoder": {"grasp_gate": true, "grasp_latch": true, "abort_action": true},
9
+ "grasp_shaping": {},
10
+ "obs_rate_noise": [0.0, 0.0]
11
+ }
so101_pick_place/code/configs/so101_policy/ppo/joint_ppo_v3.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "build9 joint teacher PPO v3 (2026-10-14 16:20): joint_ppo_v2 with std 0.05 normalised (arm offset about 1.5 mrad), floor 0.02, cap 0.2.",
3
+ "algorithm": {
4
+ "clip_param": 0.2,
5
+ "desired_kl": 0.005,
6
+ "entropy_coef": 0.0,
7
+ "gamma": 0.99,
8
+ "lam": 0.95,
9
+ "learning_rate": 3e-05,
10
+ "max_grad_norm": 1.0,
11
+ "num_learning_epochs": 5,
12
+ "num_mini_batches": 8,
13
+ "schedule": "adaptive",
14
+ "use_clipped_value_loss": true,
15
+ "value_loss_coef": 1.0
16
+ },
17
+ "num_steps_per_env": 32,
18
+ "critic_lr": 0.0003,
19
+ "init_std": [
20
+ 0.05,
21
+ 0.05
22
+ ],
23
+ "std_floor": [
24
+ 0.02,
25
+ 0.02
26
+ ],
27
+ "std_cap": [
28
+ 0.2,
29
+ 0.2
30
+ ],
31
+ "std_reset": [
32
+ 0.05,
33
+ 0.05
34
+ ]
35
+ }
so101_pick_place/code/configs/so101_policy/ppo/r2s/joint_ppo_v3_kl02.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "real2sim teacher fine-tune 2026-10-22: joint_ppo_v3 with desired_kl 0.02 (v3: 0.005; in the fine-tunes under the robot dynamics stage the adaptive lr fell to 2.25e-6 at kl 0.007 and success stayed flat).",
3
+ "algorithm": {
4
+ "clip_param": 0.2,
5
+ "desired_kl": 0.02,
6
+ "entropy_coef": 0.0,
7
+ "gamma": 0.99,
8
+ "lam": 0.95,
9
+ "learning_rate": 0.0001,
10
+ "max_grad_norm": 1.0,
11
+ "num_learning_epochs": 5,
12
+ "num_mini_batches": 8,
13
+ "schedule": "adaptive",
14
+ "use_clipped_value_loss": true,
15
+ "value_loss_coef": 1.0
16
+ },
17
+ "num_steps_per_env": 32,
18
+ "critic_lr": 0.0003,
19
+ "init_std": [
20
+ 0.05,
21
+ 0.05
22
+ ],
23
+ "std_floor": [
24
+ 0.02,
25
+ 0.02
26
+ ],
27
+ "std_cap": [
28
+ 0.2,
29
+ 0.2
30
+ ],
31
+ "std_reset": [
32
+ 0.05,
33
+ 0.05
34
+ ]
35
+ }
so101_pick_place/code/configs/so101_policy/ppo/r2s/teacher_roll_v12_fr10.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "starts": "artifacts/so101_pick_place/rl_inputs/banks/bank_pp_h45mix.npz",
3
+ "horizon": 1500,
4
+ "task": {
5
+ "hold_cap_s": 20.0
6
+ },
7
+ "hold_obs_s": 3.5,
8
+ "roll_hi_deg": 98.0,
9
+ "floor_raise": [
10
+ 0.01,
11
+ 0.0,
12
+ 0.0
13
+ ],
14
+ "note": "real2sim round v12 (2026-10-26), table-drop track, teacher env for a flat 10 mm raise (table plane (-0.010, 0, 0)): teacher_roll_v8.json (D's teacher env, everything else unchanged: start bank bank_pp_h45mix, 30 s episodes, hold cap 20 s, held-time scale 3.5 s, roll cap 98, nominal NRD worlds) + floor_raise (JointEnvConfig.floor_raise): the action-layer floor 1.5 mm above z = c0 + c1 x + c2 y at the grasp point instead of z = 0; the table, cube, task rules and observation stay at the sim table. This is the robot's flat arm-frame floor seen in the true frame by a student distilled with the same fixed table plane (online config table_bias {\"plane\": -floor_raise}, student_floor \"observed\"; vision_viral.py online refuses a labelling teacher with another floor raise). No grasp_shift. arm_table OFF (v9c rule), with evidence (~/so101_r2s_claude/v12/table/baseline_summary.json, D's teacher, 100 tasks per set): under any raise (5 / 10 / 15 mm, plane) the rule (margin 0, tau 20 ms, grasp only) would fire in 0 of 1,200 NRD and 0 of 1,200 MuJoCo episodes (raise 0: 13 / 300 and 9 / 300), MuJoCo arm-table ends 0 of 1,500 and the true lowest gripper point before the lift >= 1.8 mm: the rule would not change the reward. D's teacher at this raise, lenient % home_dev100 / dev100 / home45_dev100: NRD 94/89/91, CPU MuJoCo 93/90/90 (raise 0: NRD 99/100/99, MuJoCo 95/90/91). The floor is not a hard stop: the guard lets a target go as low as the measured pose, and the arm sags below the floor before the lift; D's teacher, lowest true gripper point before the lift minus the raised floor (1.5 mm above the raise; corrected 2026-10-26, review finding 7): NRD p50 -3.8 / p10 -5.1 / min -6.8 mm, CPU MuJoCo p50 -3.6 / min -6.1 mm (raise 0: NRD p50 +0.3 mm, the table holds it). The real robot (eval episodes 10-24..10-26, n 68 holds, flat floor): p50 -4.4, p10 -11.6, min -14.0 mm (D: p50 -3.8 mm, n 18). The dev evaluations log this gap (floor gap p50 / p10; teacher gate: p10 not below the robot's -11.6 mm). Failures of D's teacher at this raise (NRD, 300 tasks): 16 'unsupported' ends (raise 0: 1). Launch (2026-10-26, seed 122, ~/so101_r2s_claude/v12/launch/submit_v12_teacher.py, repo_v12): r2s_teacher_ppo.sbatch ENVCFG=<this file> INIT=<D's teacher runs/tppo_roll_v8_s21/ckpt/model_00200.pt> TRAINCFG=configs/so101_policy/ppo/r2s/joint_ppo_v3_kl02.json, 8,192 worlds, 200 iterations, DEV_TASKS=home45_dev100 DEV_EXTRA='dev100 home_dev100' EXTRA=--dev-match-env (the dev evaluations take the floor raise)."
15
+ }
so101_pick_place/code/configs/so101_policy/ppo/r2s/teacher_roll_v8.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "starts": "artifacts/so101_pick_place/rl_inputs/banks/bank_pp_h45mix.npz",
3
+ "horizon": 1500,
4
+ "task": {
5
+ "hold_cap_s": 20.0
6
+ },
7
+ "hold_obs_s": 3.5,
8
+ "roll_hi_deg": 98.0,
9
+ "note": "real2sim round v8 (2026-10-23), wrist-roll cap. Robot: the guard clamps the roll command at +101.2 sim deg (the motor's calibrated range ends at +-180 real deg, minus the guard's 3 deg margin; real = sim + 75.8 deg); the sim target range goes to 159.9 deg; 9 of 115 robot student episodes stopped there (4 of 11 carries across the base). Why 98 and not 100: at the clamp the servo reaches only 100.69 deg (0.52 deg short: dead band / breakaway). A steady command above ~100.7 lets the guard's integral correction wind up to its 3 deg limit against the clamp, Guard.prev = 101.21 - 3.00 = 98.21, |q - prev| = 2.48 deg >= 0.9 x LEAD = 2.455 deg, and after 25 steps 'stall: wrist_roll blocked' (both robot stalls: ~/so101_r2s_claude/robot_logs/eval_20261023_141614/ep_06 and eval_20261023_144431/ep_01; student targets 100.7-101.8 deg). The sim cannot show this (RobotDyn clamps at the cap, no stall rule). 98 leaves 2.7 deg below the reachable 100.7 for the student's output error. roll_hi_deg caps every wrist-roll target of the env (JointEnvConfig.roll_hi_deg: action layer, world target, start-bank rows above it dropped); the teacher's observation is unchanged. Start bank bank_pp_h45mix.npz (vision_viral_teacher.py starts): bank_pp_split0 once (25,197 rows) + the HOME45 training starts (train_H45_8k = the HOME45 half of train_mix45_16k) 3 times = 49,773 rows, 49 % HOME45 (the robot starts at HOME45, where the cap costs most). PPO fine-tune from jt_h110 in NOMINAL NRD worlds (no robot dynamics stage) with v7's 30 s episodes (hold cap 20 s, observation scale 3.5 s = the online env); joint_ppo_v3_kl02.json, 200 iterations; r2s_teacher_ppo.sbatch with DEV_TASKS=home45_dev100 DEV_EXTRA=dev100 EXTRA=--dev-match-env (RUN/dev_evals.jsonl). jt_h110 with the cap 98 (NRD nominal, 30 s, ~/so101_r2s_claude/roll_v8/jt_roll_count_98.json): lenient HOME45 train 97.6 -> 88.8 % (25 % of the episodes command above 98), home45_dev100 95 -> 84 %, home45_fresh100 96 -> 93 %, start bank 98.4 -> 96.7 % (11.5 %), dev100 99 -> 96 %; the failures are time-outs (cap 100: 140 of 241 HOME45 over-cap episodes go above it first at the grasp alignment, 101 in the carry). The cap is a clamp, no penalty: PPO gets no gradient on the raw command above it, so the log's 'roll over cap' need not fall. Gate (vision_viral_teacher.py eval --roll-hi-deg 98 --horizon 1500 --hold-cap-s 20 --hold-obs-s 3.5; NRD and MuJoCo; home45_dev100, home45_fresh100, dev100): lenient back near the uncapped jt_h110 (NRD 95 / 96 / 99 %) and roll_q_at_cap (episodes whose measured roll comes within 0.5 deg of the cap) well below jt_h110's 44 / 34 / 13 %."
10
+ }
so101_pick_place/code/configs/so101_policy/ppo/train_v2.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "train_v2 (2026-10-11 23:10, build4_ppo2.md): train_v1 with the trigger bias -1 (P(a[4] > 0) = 16 % per decision at std 1: with the decoder's grasp gate an out-of-box trigger costs nothing, so the trigger may explore more than at bias -2 = 2.3 %), the abort group (a[6], decoder abort_action: init std 0.5, floor 0.2, cap 1.0, bias -3) and 8 minibatches of 32 decisions x num_envs.",
3
+ "algorithm": {"clip_param": 0.2, "desired_kl": 0.01, "entropy_coef": 0.002, "gamma": 0.99, "lam": 0.95,
4
+ "learning_rate": 0.0003, "max_grad_norm": 1.0, "num_learning_epochs": 5, "num_mini_batches": 8,
5
+ "schedule": "adaptive", "use_clipped_value_loss": true, "value_loss_coef": 1.0},
6
+ "policy": {"actor_hidden_dims": [512, 256, 128], "critic_hidden_dims": [512, 256, 128], "activation": "elu",
7
+ "actor_out_gain": 0.01, "action_bias": [0.0, 0.0, 0.0, 0.0, -1.0, 0.0, -3.0], "norm_clip": 10.0},
8
+ "num_steps_per_env": 32,
9
+ "critic_lr": 0.0003,
10
+ "init_std": [0.3, 1.0, 0.5, 0.5],
11
+ "std_floor": [0.15, 0.3, 0.2, 0.2],
12
+ "std_cap": [0.3, 2.0, 1.0, 1.0],
13
+ "std_reset": [0.3, 1.0, 0.5, 0.5]
14
+ }
so101_pick_place/code/configs/so101_policy/vision/viral_r2s_home.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "real2sim HOME task starts v2 (2026-10-22, tray.make_tasks stage H): the arm at rest at the real robot's HOME pose (scripts/so101_policy/real2sim/hw/hw_lib.HOME_SIM_DEG = 0, -5, -15, 92, 45, 30 sim deg: pan, lift, elbow, wrist_flex, wrist_roll, jaw) + U(-3, 3) deg per joint, U(-15, 15) deg on the wrist roll (the roll calibration is uncertain by about 15 deg; jt_h110 >= 97 % at roll 30-60), the cube resting at the xy / yaw of a random row of jt_h110's PPO start bank, the goal by stage C's rule. v1 (roll 0) gave jt_h110 93-95 % lenient CPU MuJoCo, roll 45 98.1 % (~/so101_r2s_claude/teacher_check/logs/report_final.log).",
3
+ "home_deg": [
4
+ 0.0,
5
+ -5.0,
6
+ -15.0,
7
+ 92.0,
8
+ 45.0,
9
+ 30.0
10
+ ],
11
+ "noise_deg": [
12
+ 3.0,
13
+ 3.0,
14
+ 3.0,
15
+ 3.0,
16
+ 15.0,
17
+ 3.0
18
+ ],
19
+ "bank": "artifacts/so101_pick_place/rl_inputs/banks/bank_pp_split0.npz"
20
+ }
so101_pick_place/code/configs/so101_policy/vision/viral_r2s_online_relabel_roll_v8.json ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "viral_r2s_online_relabel_v4.json + the wrist-roll cap (real2sim round v8, 2026-10-23): roll_hi_deg 98 (sim deg; the robot guard clamps at 101.2, where the servo reaches only 100.69 deg: a command above ~100.7 winds the guard's integral correction up and the stall rule stops the robot; 98 leaves 2.7 deg for the student's output error; configs/so101_policy/ppo/r2s/teacher_roll_v8.json note) caps every wrist-roll target of the online env, the JT's labels get the same cap (the student never learns a roll command above it), task rows that start above it leave the pool (train_mix45_16k: 1 of 16,384, seed 687570 at 119.9 deg) and the in-run evaluations use it. Teacher: the roll-capped fine-tune (teacher_roll_v8.json) via r2s_online.sbatch TEACHER_JT=<its checkpoint>; the run refuses a JT trained without the cap (vision_viral.py online --allow-uncapped-jt overrides): jt_h110's plans go above 98 in 25 % of the HOME45 episodes, and capped labels alone do not teach another grasp roll (HOME45 lenient 97.6 -> 88.8 %). Log columns roll_over_student / roll_over_teacher = share of the finished episodes whose command went above the cap. | v4 note: Root cause (2026-10-22): the student's step size follows the MEASURED qdot; the real arm is ~5x slower, so the steps shrink and the arm holds still above the plate (robot-like sim: today's student 50 %, 88-94 % with its qdot input x2-3). Track C1: robot dynamics in the student slots (no command delay: it dropped commands and broke the grasp in dyn v2; gain 0.3-1, lag 20-150 ms, sag 0-1.5 deg + the guard's integral correction), the JT labels those worlds with the COMMANDED speed in its qdot observation (relabel_cmd_speed) so its labels keep the nominal pace; robot-like qdot input in half of the worlds, image lag 1-4, 30 s episodes.",
3
+ "envs": 1024,
4
+ "teacher_share": 0.5,
5
+ "noise_share": 0.5,
6
+ "noise": 1.0,
7
+ "nominal_share": 0.2,
8
+ "default_light_p": 0.25,
9
+ "buffer": 100000,
10
+ "steps_per_iter": 8,
11
+ "lr": 0.0001,
12
+ "lr_backbone": 5e-05,
13
+ "iterations": 3000,
14
+ "eval_every": 1000,
15
+ "save_every": 250,
16
+ "log_every": 25,
17
+ "dyn": {
18
+ "p": 0.8,
19
+ "d_lo": 0,
20
+ "d_hi": 0,
21
+ "jitter": 0.0,
22
+ "s_lo": 0.3,
23
+ "s_hi": 1.0,
24
+ "tau_lo": 0.02,
25
+ "tau_hi": 0.15,
26
+ "sag_max_deg": 1.5,
27
+ "noise_max": 0.0,
28
+ "i_time_s": 0.2,
29
+ "i_max_deg": 3.0,
30
+ "i_e_max_deg": 1.0,
31
+ "i_v_min": 0.02
32
+ },
33
+ "dyn_student_only": true,
34
+ "qd_robot_p": 0.5,
35
+ "qd_window": 3,
36
+ "horizon": 1500,
37
+ "hold_cap_s": 20.0,
38
+ "hold_obs_s": 3.5,
39
+ "lag_range": [
40
+ 1,
41
+ 4
42
+ ],
43
+ "relabel_cmd_speed": true,
44
+ "roll_hi_deg": 98.0
45
+ }
so101_pick_place/code/configs/so101_policy/vision/viral_r2s_online_relabel_v4.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "Root cause (2026-10-22): the student's step size follows the MEASURED qdot; the real arm is ~5x slower, so the steps shrink and the arm holds still above the plate (robot-like sim: today's student 50 %, 88-94 % with its qdot input x2-3). Track C1: robot dynamics in the student slots (no command delay: it dropped commands and broke the grasp in dyn v2; gain 0.3-1, lag 20-150 ms, sag 0-1.5 deg + the guard's integral correction), the JT labels those worlds with the COMMANDED speed in its qdot observation (relabel_cmd_speed) so its labels keep the nominal pace; robot-like qdot input in half of the worlds, image lag 1-4, 30 s episodes.",
3
+ "envs": 1024,
4
+ "teacher_share": 0.5,
5
+ "noise_share": 0.5,
6
+ "noise": 1.0,
7
+ "nominal_share": 0.2,
8
+ "default_light_p": 0.25,
9
+ "buffer": 100000,
10
+ "steps_per_iter": 8,
11
+ "lr": 0.0001,
12
+ "lr_backbone": 5e-05,
13
+ "iterations": 3000,
14
+ "eval_every": 1000,
15
+ "save_every": 250,
16
+ "log_every": 25,
17
+ "dyn": {
18
+ "p": 0.8,
19
+ "d_lo": 0,
20
+ "d_hi": 0,
21
+ "jitter": 0.0,
22
+ "s_lo": 0.3,
23
+ "s_hi": 1.0,
24
+ "tau_lo": 0.02,
25
+ "tau_hi": 0.15,
26
+ "sag_max_deg": 1.5,
27
+ "noise_max": 0.0,
28
+ "i_time_s": 0.2,
29
+ "i_max_deg": 3.0,
30
+ "i_e_max_deg": 1.0,
31
+ "i_v_min": 0.02
32
+ },
33
+ "dyn_student_only": true,
34
+ "qd_robot_p": 0.5,
35
+ "qd_window": 3,
36
+ "horizon": 1500,
37
+ "hold_cap_s": 20.0,
38
+ "hold_obs_s": 3.5,
39
+ "lag_range": [
40
+ 1,
41
+ 4
42
+ ],
43
+ "relabel_cmd_speed": true
44
+ }
so101_pick_place/code/configs/so101_policy/vision/viral_r2s_online_v1.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "real2sim online loop v1 (2026-10-21): build9's viral_online_v1 (the o16 / o17 loop: 1,024 NRD worlds, slots 0-511 JT-driven, half of them with 1 x std noise, 20 % nominal-visual slots, the scene light in 25 % of the decisions, 100,000-sample GPU buffer, 8 steps of 128 per decision, constant lr 1e-4 / 5e-5) for 3,000 decisions (o16 was cancelled after 3,000 of 6,000; constant lr, so the same schedule). Use with --config viral_r2s_v1.json (jaw lead 0).",
3
+ "envs": 1024,
4
+ "teacher_share": 0.5,
5
+ "noise_share": 0.5,
6
+ "noise": 1.0,
7
+ "nominal_share": 0.2,
8
+ "default_light_p": 0.25,
9
+ "buffer": 100000,
10
+ "steps_per_iter": 8,
11
+ "lr": 0.0001,
12
+ "lr_backbone": 0.00005,
13
+ "iterations": 3000,
14
+ "eval_every": 1000,
15
+ "save_every": 250,
16
+ "log_every": 25
17
+ }
so101_pick_place/code/configs/so101_policy/vision/viral_r2s_online_v12_tb10.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "real2sim round v12 table-drop student tb10 (2026-10-26): D's online config viral_r2s_online_relabel_roll_v8.json + ONE fixed table plane under every world, a flat table 10 mm below the sim table (table_bias plane c = [-0.01, 0.0, 0.0], p 1, no random draw), table_render on (the images show the lower table), student_floor observed (the online env's floor is flat in the student's observed frame = the robot's flat arm-frame floor; true-frame floor raised by -plane). Nothing else changed (plate, scene, tasks, commanded-speed relabel, robot dynamics, roll cap 98 as D). Labelling teacher: the v12 fine-tune teacher_roll_v12_fr10.json (floor raise 10 mm); the run refuses a teacher with another floor raise. The in-run evaluations run on this plane with 1,500 steps and the 20 s hold cap by default (vision_viral.inrun_eval_setup) | D's note: viral_r2s_online_relabel_v4.json + the wrist-roll cap (real2sim round v8, 2026-10-23): roll_hi_deg 98 (sim deg; the robot guard clamps at 101.2, where the servo reaches only 100.69 deg: a command above ~100.7 winds the guard's integral correction up and the stall rule stops the robot; 98 leaves 2.7 deg for the student's output error; configs/so101_policy/ppo/r2s/teacher_roll_v8.json note) caps every wrist-roll target of the online env, the JT's labels get the same cap (the student never learns a roll command above it), task rows that start above it leave the pool (train_mix45_16k: 1 of 16,384, seed 687570 at 119.9 deg) and the in-run evaluations use it. Teacher: the roll-capped fine-tune (teacher_roll_v8.json) via r2s_online.sbatch TEACHER_JT=<its checkpoint>; the run refuses a JT trained without the cap (vision_viral.py online --allow-uncapped-jt overrides): jt_h110's plans go above 98 in 25 % of the HOME45 episodes, and capped labels alone do not teach another grasp roll (HOME45 lenient 97.6 -> 88.8 %). Log columns roll_over_student / roll_over_teacher = share of the finished episodes whose command went above the cap. | v4 note: Root cause (2026-10-22): the student's step size follows the MEASURED qdot; the real arm is ~5x slower, so the steps shrink and the arm holds still above the plate (robot-like sim: today's student 50 %, 88-94 % with its qdot input x2-3). Track C1: robot dynamics in the student slots (no command delay: it dropped commands and broke the grasp in dyn v2; gain 0.3-1, lag 20-150 ms, sag 0-1.5 deg + the guard's integral correction), the JT labels those worlds with the COMMANDED speed in its qdot observation (relabel_cmd_speed) so its labels keep the nominal pace; robot-like qdot input in half of the worlds, image lag 1-4, 30 s episodes.",
3
+ "envs": 1024,
4
+ "teacher_share": 0.5,
5
+ "noise_share": 0.5,
6
+ "noise": 1.0,
7
+ "nominal_share": 0.2,
8
+ "default_light_p": 0.25,
9
+ "buffer": 100000,
10
+ "steps_per_iter": 8,
11
+ "lr": 0.0001,
12
+ "lr_backbone": 5e-05,
13
+ "iterations": 3000,
14
+ "eval_every": 1000,
15
+ "save_every": 250,
16
+ "log_every": 25,
17
+ "dyn": {
18
+ "p": 0.8,
19
+ "d_lo": 0,
20
+ "d_hi": 0,
21
+ "jitter": 0.0,
22
+ "s_lo": 0.3,
23
+ "s_hi": 1.0,
24
+ "tau_lo": 0.02,
25
+ "tau_hi": 0.15,
26
+ "sag_max_deg": 1.5,
27
+ "noise_max": 0.0,
28
+ "i_time_s": 0.2,
29
+ "i_max_deg": 3.0,
30
+ "i_e_max_deg": 1.0,
31
+ "i_v_min": 0.02
32
+ },
33
+ "dyn_student_only": true,
34
+ "qd_robot_p": 0.5,
35
+ "qd_window": 3,
36
+ "horizon": 1500,
37
+ "hold_cap_s": 20.0,
38
+ "hold_obs_s": 3.5,
39
+ "lag_range": [
40
+ 1,
41
+ 4
42
+ ],
43
+ "relabel_cmd_speed": true,
44
+ "roll_hi_deg": 98.0,
45
+ "table_bias": {
46
+ "plane": [
47
+ -0.01,
48
+ 0.0,
49
+ 0.0
50
+ ],
51
+ "p": 1.0
52
+ },
53
+ "table_render": true,
54
+ "student_floor": "observed"
55
+ }
so101_pick_place/code/configs/so101_policy/vision/viral_r2s_v1.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "note": "real2sim student v1 (2026-10-21, ~/so101_r2s_claude/docs/integrate.md): build9's network and round-based recipe (viral_v2 + qd_noise 0.3 = d2, jaw lead 0) with the REAL cameras and scene: external + wrist calibrated fisheye cameras (crop of the 640 x 480 frame -> 224 px, the deployment's student_view rule), the light-box scene of the scene file (body groups, RealDR randomisation, its lights, optional tone map, its image_fx camera effects), image lag 2 control steps (40 ms; real 42-48 ms) at evaluation, drawn 1-3 per world per episode in training; extra student-side effects (vignetting, white balance, gamma); DRConfig colour augmentation kept, its noise / blur off (image_fx has them). scene: the final file of the render agent; calib: '' = the scene file's own calib entry (override on AMD with --set calib=...). 2026-10-22: scene -> real_scene_v2.json (v1 + wider room colour, exposure and gamma randomisation after the scene review). DRConfig contrast p 0.5, 0.75-1.6 (was p 0.4, 0.6-1.4): real contrast was at rank 0.81 (external) / 0.93 (wrist) of the draws.",
3
+ "chunk": 10,
4
+ "n_exec": 5,
5
+ "res": 224,
6
+ "cameras": [
7
+ "external",
8
+ "wrist"
9
+ ],
10
+ "qd_noise": 0.3,
11
+ "encoder": "resnet18",
12
+ "stages": 3,
13
+ "keypoints": 32,
14
+ "pool_dim": 64,
15
+ "hidden": [
16
+ 512,
17
+ 512
18
+ ],
19
+ "aux_weight": 1.0,
20
+ "aux_hidden": 256,
21
+ "jaw_lead": 0,
22
+ "batch": 128,
23
+ "render_batch": 256,
24
+ "lr": 0.0003,
25
+ "lr_backbone": 0.0001,
26
+ "weight_decay": 0.0001,
27
+ "warmup": 300,
28
+ "grad_clip": 10.0,
29
+ "amp": true,
30
+ "dr": {
31
+ "p_noise": 0.0,
32
+ "p_blur": 0.0,
33
+ "p_contrast": 0.5,
34
+ "contrast": [
35
+ 0.75,
36
+ 1.6
37
+ ]
38
+ },
39
+ "dr_frac": 1.0,
40
+ "reuse": 2,
41
+ "scene": "configs/so101_pick_place/real_scene_v2.json",
42
+ "calib": "",
43
+ "crops": {},
44
+ "real_dr": {},
45
+ "cam_fx": {
46
+ "p_vignette": 0.3,
47
+ "vignette": [
48
+ 0.0,
49
+ 0.3
50
+ ],
51
+ "p_wb": 0.3,
52
+ "wb": 0.08,
53
+ "p_gamma": 0.3,
54
+ "gamma": [
55
+ 0.85,
56
+ 1.2
57
+ ]
58
+ },
59
+ "lag": 2,
60
+ "lag_range": [
61
+ 1,
62
+ 3
63
+ ]
64
+ }
so101_pick_place/code/contact_nrd/so101_grasp/.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ vendor/
2
+ __pycache__/
so101_pick_place/code/contact_nrd/so101_grasp/fetch_sources.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fetch the pinned MuJoCo Menagerie SO101 model (sparse, shallow) and verify every file against the manifest.
2
+
3
+ python -I contact_nrd/so101_grasp/fetch_sources.py
4
+
5
+ The checkout goes to vendor/ (gitignored) and is never edited: the collector builds its scene around the
6
+ unchanged so101.xml. The fetched folder holds only data (MJCF, STL meshes, text); nothing in it is executed.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import hashlib
11
+ import json
12
+ from pathlib import Path
13
+ import subprocess
14
+ import tempfile
15
+
16
+
17
+ ROOT = Path(__file__).resolve().parent
18
+
19
+
20
+ def git(*args: str, cwd: Path | None = None) -> str:
21
+ return subprocess.check_output(["git", *args], cwd=cwd, text=True).strip()
22
+
23
+
24
+ def main() -> None:
25
+ manifest = json.loads((ROOT / "source_manifest.json").read_text())
26
+ source = manifest["source"]
27
+ target = ROOT / source["local_path"]
28
+ target.parent.mkdir(parents=True, exist_ok=True)
29
+ if not target.exists():
30
+ with tempfile.TemporaryDirectory(prefix="menagerie-fetch-", dir=target.parent) as tmp:
31
+ stage = Path(tmp) / "mujoco_menagerie"
32
+ stage.mkdir()
33
+ git("init", "--quiet", cwd=stage)
34
+ git("remote", "add", "origin", source["url"], cwd=stage)
35
+ git("sparse-checkout", "set", "--no-cone", *source["sparse_paths"], cwd=stage)
36
+ git("fetch", "--quiet", "--depth", "1", "--filter=blob:none", "origin", source["revision"], cwd=stage)
37
+ git("checkout", "--quiet", "--detach", "FETCH_HEAD", cwd=stage)
38
+ stage.rename(target)
39
+ if Path(git("rev-parse", "--show-toplevel", cwd=target)).resolve() != target.resolve():
40
+ raise SystemExit(f"Expected a standalone upstream checkout: {target}")
41
+ if git("rev-parse", "HEAD", cwd=target) != source["revision"]:
42
+ raise SystemExit("Existing checkout has another revision; leave it intact and use a separate folder.")
43
+ if git("status", "--porcelain", cwd=target):
44
+ raise SystemExit("Existing upstream checkout has changes; leave it intact and use a separate folder.")
45
+ present = sorted(str(p.relative_to(target)) for p in target.rglob("*") if p.is_file() and ".git" not in p.parts)
46
+ expected = sorted(item["path"] for item in manifest["files"])
47
+ if present != expected:
48
+ raise SystemExit(f"Checkout files differ from the manifest: {sorted(set(present) ^ set(expected))}")
49
+ for item in manifest["files"]:
50
+ path = target / item["path"]
51
+ digest = hashlib.sha256(path.read_bytes()).hexdigest()
52
+ if digest != item["sha256"] or path.stat().st_size != item["bytes"]:
53
+ raise SystemExit(f"Source verification failed: {path}")
54
+ if any(p.endswith(".py") for p in present):
55
+ raise SystemExit("The fetched model holds Python files; it should hold data only.")
56
+ print(f"Verified mujoco_menagerie {source['revision']} and {len(manifest['files'])} pinned files.")
57
+ print(f"Model: {target / manifest['model']['path']}")
58
+
59
+
60
+ if __name__ == "__main__":
61
+ main()
so101_pick_place/code/contact_nrd/so101_grasp/source_manifest.json ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 1,
3
+ "fetched_and_audited_utc": "2026-10-09T00:07:22.978008+00:00",
4
+ "nedm_baseline_revision": "41be3efccb7eb2f74e6741610853557b288a86bc",
5
+ "source": {
6
+ "name": "mujoco_menagerie (robotstudio_so101)",
7
+ "url": "https://github.com/google-deepmind/mujoco_menagerie.git",
8
+ "revision": "0059d4335f8156206f63a35662313385f7ad6d74",
9
+ "revision_date": "2026-10-07T13:07:25-07:00",
10
+ "local_path": "vendor/mujoco_menagerie",
11
+ "sparse_paths": [
12
+ "/robotstudio_so101/",
13
+ "/LICENSE"
14
+ ]
15
+ },
16
+ "files": [
17
+ {
18
+ "path": "LICENSE",
19
+ "bytes": 434514,
20
+ "sha256": "b1334631b1d7bd73394f95d3241d5110f98f7310ad08b17d3b113518dd967a5b"
21
+ },
22
+ {
23
+ "path": "robotstudio_so101/CHANGELOG.md",
24
+ "bytes": 391,
25
+ "sha256": "ac7f6205e40f0fb2bc08ff3ff4c5e5092dacf8d78cb03f024ae9aae33738acc4"
26
+ },
27
+ {
28
+ "path": "robotstudio_so101/LICENSE",
29
+ "bytes": 11357,
30
+ "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4"
31
+ },
32
+ {
33
+ "path": "robotstudio_so101/README.md",
34
+ "bytes": 1142,
35
+ "sha256": "e2344e7c14290bed85c7907247aecb8bf6cb4392e3de0d7c45680efe9bb9b5a9"
36
+ },
37
+ {
38
+ "path": "robotstudio_so101/assets/base_motor_holder_so101_v1.stl",
39
+ "bytes": 1877084,
40
+ "sha256": "8cd2f241037ea377af1191fffe0dd9d9006beea6dcc48543660ed41647072424"
41
+ },
42
+ {
43
+ "path": "robotstudio_so101/assets/base_so101_v2.stl",
44
+ "bytes": 471584,
45
+ "sha256": "bb12b7026575e1f70ccc7240051f9d943553bf34e5128537de6cd86fae33924d"
46
+ },
47
+ {
48
+ "path": "robotstudio_so101/assets/motor_holder_so101_base_v1.stl",
49
+ "bytes": 1129384,
50
+ "sha256": "31242ae6fb59d8b15c66617b88ad8e9bded62d57c35d11c0c43a70d2f4caa95b"
51
+ },
52
+ {
53
+ "path": "robotstudio_so101/assets/motor_holder_so101_wrist_v1.stl",
54
+ "bytes": 1052184,
55
+ "sha256": "887f92e6013cb64ea3a1ab8675e92da1e0beacfd5e001f972523540545e08011"
56
+ },
57
+ {
58
+ "path": "robotstudio_so101/assets/moving_jaw_so101_gripper_part0_v1.stl",
59
+ "bytes": 50684,
60
+ "sha256": "3a92e115d1934d4c45cff808c4eff2ea10361a137a7f89940033a1f8a821b88c"
61
+ },
62
+ {
63
+ "path": "robotstudio_so101/assets/moving_jaw_so101_gripper_part1_v1.stl",
64
+ "bytes": 342684,
65
+ "sha256": "d10f6c671d26f62988ec95efee9370a0657b5833b3c5f8aad59fd69a87ef2aee"
66
+ },
67
+ {
68
+ "path": "robotstudio_so101/assets/moving_jaw_so101_gripper_v1.stl",
69
+ "bytes": 690384,
70
+ "sha256": "e8a5dc040b98e27453a5b74f9087d1dbca14589cf9a17c4de7868d5ab98413cd"
71
+ },
72
+ {
73
+ "path": "robotstudio_so101/assets/moving_jaw_so101_v1.stl",
74
+ "bytes": 1413584,
75
+ "sha256": "785a9dded2f474bc1d869e0d3dae398a3dcd9c0c345640040472210d2861fa9d"
76
+ },
77
+ {
78
+ "path": "robotstudio_so101/assets/rotation_pitch_so101_v1.stl",
79
+ "bytes": 883684,
80
+ "sha256": "9be900cc2a2bf718102841ef82ef8d2873842427648092c8ed2ca1e2ef4ffa34"
81
+ },
82
+ {
83
+ "path": "robotstudio_so101/assets/sts3215_03a_no_horn_v1.stl",
84
+ "bytes": 865884,
85
+ "sha256": "75ef3781b752e4065891aea855e34dc161a38a549549cd0970cedd07eae6f887"
86
+ },
87
+ {
88
+ "path": "robotstudio_so101/assets/sts3215_03a_v1.stl",
89
+ "bytes": 954084,
90
+ "sha256": "a37c871fb502483ab96c256baf457d36f2e97afc9205313d9c5ab275ef941cd0"
91
+ },
92
+ {
93
+ "path": "robotstudio_so101/assets/under_arm_so101_v1.stl",
94
+ "bytes": 1975884,
95
+ "sha256": "d01d1f2de365651dcad9d6669e94ff87ff7652b5bb2d10752a66a456a86dbc71"
96
+ },
97
+ {
98
+ "path": "robotstudio_so101/assets/upper_arm_so101_v1.stl",
99
+ "bytes": 1303484,
100
+ "sha256": "475056e03a17e71919b82fd88ab9a0b898ab50164f2a7943652a6b2941bb2d4f"
101
+ },
102
+ {
103
+ "path": "robotstudio_so101/assets/waveshare_mounting_plate_so101_v2.stl",
104
+ "bytes": 62784,
105
+ "sha256": "e197e24005a07d01bbc06a8c42311664eaeda415bf859f68fa247884d0f1a6e9"
106
+ },
107
+ {
108
+ "path": "robotstudio_so101/assets/wrist_roll_follower_so101_camera_mount.stl",
109
+ "bytes": 122884,
110
+ "sha256": "58c457b33a26d9c9bb337aa351173e7123f84719a93f486541adef6eba57ae21"
111
+ },
112
+ {
113
+ "path": "robotstudio_so101/assets/wrist_roll_follower_so101_gripper_part0_v1.stl",
114
+ "bytes": 73784,
115
+ "sha256": "370eb470a6ab48b08febcaeb5274d2bcc91246692532ce12c795fb82977def72"
116
+ },
117
+ {
118
+ "path": "robotstudio_so101/assets/wrist_roll_follower_so101_gripper_v1.stl",
119
+ "bytes": 741684,
120
+ "sha256": "65f32debcf265420c0160afe004f8befc5df4b3e578fd59ebaa62eade0371224"
121
+ },
122
+ {
123
+ "path": "robotstudio_so101/assets/wrist_roll_follower_so101_v1.stl",
124
+ "bytes": 1439884,
125
+ "sha256": "4b17b410a12d64ec39554abc3e8054d8a97384b2dc4a8d95a5ecb2a93670f5f4"
126
+ },
127
+ {
128
+ "path": "robotstudio_so101/assets/wrist_roll_pitch_so101_v2.stl",
129
+ "bytes": 2699784,
130
+ "sha256": "6c7ec5525b4d8b9e397a30ab4bb0037156a5d5f38a4adf2c7d943d6c56eda5ae"
131
+ },
132
+ {
133
+ "path": "robotstudio_so101/scene.xml",
134
+ "bytes": 825,
135
+ "sha256": "d3037f0fd36b61a9b6805b2c79831e7a392276d0f490145d01f718542eee9150"
136
+ },
137
+ {
138
+ "path": "robotstudio_so101/scene_box.xml",
139
+ "bytes": 1469,
140
+ "sha256": "14c3826f23889587e63b88ef9a0e7d72318ffe13078fad8287c56dbdb9ba9ad8"
141
+ },
142
+ {
143
+ "path": "robotstudio_so101/so101.png",
144
+ "bytes": 1010575,
145
+ "sha256": "fca552381f318dab5b1f9a69007e79d905d91c9d1bebbfdf267b78d924a9c46d"
146
+ },
147
+ {
148
+ "path": "robotstudio_so101/so101.xml",
149
+ "bytes": 17206,
150
+ "sha256": "982c02c027ec0c62d3459d0a6eb00dfb7dc13a451992e72ce99addc71f209805"
151
+ }
152
+ ],
153
+ "model": {
154
+ "path": "robotstudio_so101/so101.xml",
155
+ "license": "Apache-2.0 (robotstudio_so101/LICENSE)",
156
+ "used_unchanged": true,
157
+ "note": "The collector loads so101.xml with mujoco.MjSpec and adds the table, the cube, the options and the contact exclusions in code; the vendor files are not edited."
158
+ }
159
+ }
so101_pick_place/code/docs/hf_dataset_card.md ADDED
@@ -0,0 +1,866 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: bsd-3-clause
3
+ pretty_name: NeDM Neural Reduced Dynamics Datasets
4
+ tags:
5
+ - robotics
6
+ - vehicle-dynamics
7
+ - project-chrono
8
+ - simulation
9
+ - time-series
10
+ - reduced-order-model
11
+ - reinforcement-learning
12
+ - terramechanics
13
+ task_categories:
14
+ - time-series-forecasting
15
+ - robotics
16
+ size_categories:
17
+ - 100M<n<1B
18
+ configs:
19
+ - config_name: hmmwv_flat
20
+ default: true
21
+ data_files:
22
+ - split: train
23
+ path: raw/hmmwv_flat/train/*.parquet
24
+ - split: val
25
+ path: raw/hmmwv_flat/val/*.parquet
26
+ - config_name: hmmwv_bumpy
27
+ data_files:
28
+ - split: train
29
+ path: raw/hmmwv_bumpy/train/*.parquet
30
+ - split: val
31
+ path: raw/hmmwv_bumpy/val/*.parquet
32
+ - config_name: hmmwv_crm
33
+ data_files:
34
+ - split: train
35
+ path: raw/hmmwv_crm/train/*.parquet
36
+ - split: val
37
+ path: raw/hmmwv_crm/val/*.parquet
38
+ - config_name: arm
39
+ data_files:
40
+ - split: train
41
+ path: raw/arm/train/*.parquet
42
+ - split: val
43
+ path: raw/arm/val/*.parquet
44
+ - config_name: tracked
45
+ data_files:
46
+ - split: train
47
+ path: raw/tracked/train/*.parquet
48
+ - split: val
49
+ path: raw/tracked/val/*.parquet
50
+ - config_name: hmmwv_flat_episodes
51
+ data_files: raw/hmmwv_flat/episodes.parquet
52
+ - config_name: hmmwv_bumpy_episodes
53
+ data_files: raw/hmmwv_bumpy/episodes.parquet
54
+ - config_name: hmmwv_crm_episodes
55
+ data_files: raw/hmmwv_crm/episodes.parquet
56
+ - config_name: arm_episodes
57
+ data_files: raw/arm/episodes.parquet
58
+ - config_name: tracked_episodes
59
+ data_files: raw/tracked/episodes.parquet
60
+ ---
61
+
62
+ # NeDM datasets: the paper, the traversing study, the contact NRD, the G1 footstep policy and the SO101 pick and place
63
+
64
+ This repository holds separate releases. **Part A** is the set of datasets behind the NeDM paper, unchanged since its
65
+ release (Hub tag `paper-v1`). **Part B**, everything under `traversing/`, holds the drives, training files, models and
66
+ evaluation records of the traversing study, follow-on work that is not part of the paper. **Part C**, everything under
67
+ `contact_nrd/`, holds the training data, test sets and models of the contact NRD, also follow-on work. **Part D**,
68
+ everything under `g1_footstep_rl/`, holds the policies, RL inputs and MuJoCo results of a G1 footstep policy trained in
69
+ the contact NRD, also follow-on work. **Part E**, everything under `so101_pick_place/`, holds the NRD, data,
70
+ checkpoints and real-robot records of an SO101 pick-and-place camera policy trained only in a contact NRD, also
71
+ follow-on work.
72
+
73
+ Contents:
74
+
75
+ - [Part A: datasets of the paper](#part-a-datasets-of-the-paper): `raw/`, `processed/`, `assets/` and
76
+ `release_manifest.json`
77
+ - [Part B: traversing study](#part-b-traversing-study): `traversing/`
78
+ - [Part C: contact NRD](#part-c-contact-nrd): `contact_nrd/`
79
+ - [Part D: G1 footstep policy](#part-d-g1-footstep-policy): `g1_footstep_rl/`
80
+ - [Part E: SO101 pick and place](#part-e-so101-pick-and-place): `so101_pick_place/`
81
+
82
+ ## Part A: datasets of the paper
83
+
84
+ ### NeDM — Neural Reduced Dynamics Datasets
85
+
86
+ High-fidelity [Project Chrono](https://projectchrono.org) trajectories used to train the
87
+ neural reduced dynamics models (NN-ROMs) in
88
+
89
+ > **Learning the Right Abstraction: Neural Reduced Dynamics for Complex Robot Control**
90
+ > Harry Zhang and Dan Negrut, 2026 (preprint).
91
+ > Project page: <https://uwsbel.github.io/NeDM/> · Code: <https://github.com/uwsbel/NeDM>
92
+
93
+ Every dataset here is exactly what the paper's models were trained and validated on. Two tiers
94
+ are published (70 GB in total):
95
+
96
+ * **`raw/`** — every recorded channel of every episode (Parquet, float32), plus a per-episode
97
+ index and the byte-exact collection metadata (driver profiles, seeds, terrain, termination
98
+ causes). This is the reusable resource: build your own reduced states from it.
99
+ * **`processed/`** — the four training caches the deployed models read (`.npy`), so the
100
+ paper's training configs run without touching the raw data.
101
+
102
+ ### Datasets
103
+
104
+ | Config | System | Terrain / task | Rate | Episodes (train / val) | Rows | Raw Parquet | Columns |
105
+ |---|---|---|---|---|---|---|---|
106
+ | `hmmwv_flat` | HMMWV (`HMMWV_Full`, TMEASY tires, SMC contact) | flat rigid, μ = 0.9, 900 × 900 m | 100 Hz | 32,768 (26,124 / 6,644) | 160,551,861 | 44.0 GB, 128 shards | 105 |
107
+ | `hmmwv_bumpy` | HMMWV (same vehicle) | rigid heightmap, 100 random 500 × 500 m fields, ±0.6 m | 100 Hz | 1,360 (1,104 / 256) | 4,511,778 | 1.3 GB, 4 shards | 105 |
108
+ | `hmmwv_crm` | HMMWV (rigid-mesh tires) | CRM deformable soil (SPH), 150 × 150 × 0.25 m | 100 Hz | 2,000 (1,582 / 418) | 2,884,961 | 0.8 GB, 4 parts | 105 |
109
+ | `arm` | 4-DOF LRV arm mounted on an M113 (base held) | free-space joint motion, PD torque control | 50 Hz | 15,000 (12,716 / 2,284) | 920,640 | 0.09 GB, 15 shards | 47 |
110
+ | `tracked` | M113 tracked vehicle, arm welded at home | flat rigid drive, 10 manoeuvre families | 50 Hz | 2,160 (1,808 / 352) | 1,683,484 | 0.2 GB, 60 shards | 42 |
111
+
112
+ Roles in the paper: `hmmwv_flat` + `hmmwv_crm` train the terrain-conditioned HMMWV NN-ROM
113
+ (Study Case I); `hmmwv_bumpy` is the zero-shot out-of-distribution test regime and never enters
114
+ training, model selection, normalisation or reward tuning; `tracked` and `arm` train the two
115
+ Study Case II NN-ROMs. All five were collected with PyChrono 10.0.0 (conda `projectchrono`
116
+ channel) using the collectors in the code repository (`src/nedm/hmmwv_data.py`,
117
+ `scripts/collection/collect_hmmwv_crm_dataset.py`, `src/nedm/arm_data.py`,
118
+ `src/nedm/tracked_vehicle_data.py`).
119
+
120
+ #### Splits
121
+
122
+ Train/val is decided **per episode at collection time** and stored in the `split` column:
123
+ `sha1(episode_id)[:8] / 0xFFFFFFFF < validation_ratio → val` (ratio 0.20 for the HMMWV sets,
124
+ 0.15 for `arm` and `tracked`). Whole episodes stay together; the assignment depends only on the
125
+ episode id, so it is stable under re-sharding. `train` and `val` files never share an episode.
126
+
127
+ ### Layout
128
+
129
+ ```
130
+ raw/<config>/train/<shard>.parquet transitions, one file per raw collection shard
131
+ raw/<config>/val/<shard>.parquet
132
+ raw/<config>/episodes.parquet one row per episode: index entry + JSON sidecar (see below)
133
+ raw/<config>/metadata.tar.gz byte-exact originals: dataset_index.json, collector_config.resolved.json,
134
+ episodes/<id>.json sidecars, shard-plan manifests
135
+ processed/<cache>/ .npy training caches + metadata.json (state layout, normalisation)
136
+ assets/bumpy_terrain/bumpy_field_NNN.bmp the 100 heightmaps behind hmmwv_bumpy (256×256, 8-bit, gray 128 = 0 m)
137
+ release_manifest.json sha256 / size / row count of every file, tool versions, source commit
138
+ ```
139
+
140
+ Rows are ordered by episode (collection order) then `sample_index`; each episode is contiguous
141
+ inside exactly one file. Column names and order are the collector's CSV columns, unchanged. All
142
+ physical channels are `float32` (`time_s` is `float64`; `sample_index`, `collision` are `int32`;
143
+ identifiers are dictionary-encoded strings). Files are zstd-compressed with BYTE_STREAM_SPLIT
144
+ float encoding and ≤ 262,144-row row groups.
145
+
146
+ #### Column groups
147
+
148
+ **HMMWV (`hmmwv_flat`, `hmmwv_bumpy`, `hmmwv_crm` — identical 105 columns).** Units are in the
149
+ names (`_m`, `_mps`, `_mps2`, `_rad`, `_radps`, `_n`, `_nm`); world frame is Chrono's ISO
150
+ (x forward, z up), body frame is the chassis frame.
151
+
152
+ | Group | Columns |
153
+ |---|---|
154
+ | identifiers | `episode_id`, `scenario_name`, `scenario_family`, `split`, `sample_index`, `time_s` |
155
+ | driver command (the action) | `driver_steering` ∈ [−1, 1], `driver_throttle` ∈ [0, 1], `driver_braking` ∈ [0, 1] |
156
+ | chassis pose | `pos_{x,y,z}_m`, `quat_e0..e3`, `roll_rad`, `pitch_rad`, `yaw_rad` |
157
+ | chassis motion | `vel_world_{x,y,z}_mps`, `vel_body_{x,y,z}_mps`, `acc_world_*`, `acc_body_*`, `ang_vel_world_{x,y,z}_radps`, `ang_vel_body_{x,y,z}_radps`, `speed_mps`, `body_slip_rad`, `roll_rate_radps`, `yaw_rate_radps` |
158
+ | per-tire block, prefix `tire_{fl,fr,rl,rr}_` (16 × 4) | `longitudinal_slip`, `slip_angle_rad`, `camber_angle_rad`, `force_world_{x,y,z}_n`, `moment_world_{x,y,z}_nm`, `force_wheel_{fx,fy,fz}_n`, `spindle_omega_radps`, `wheel_vx_mps`, `slip_ratio`, `deflection_m` |
159
+
160
+ `force_wheel_*` and `slip_ratio` are derived from spindle state and the world-frame force so they
161
+ are computed identically on rigid and CRM terrain (on CRM the tire force comes from the FSI
162
+ solver, `tire_force_source: crm_fsi`). The paper's 15-D HMMWV state is
163
+ `vel_body_x_mps, vel_body_y_mps, roll_rad, pitch_rad, roll_rate_radps, ang_vel_body_y_radps, yaw_rate_radps`
164
+ + `tire_*_force_wheel_fz_n` (4) + `tire_*_spindle_omega_radps` (4); action is the driver triple;
165
+ pose for open-loop rollout scoring is `pos_x_m, pos_y_m, yaw_rad`. Recording starts after a
166
+ settle/warm-up window (`warmup_s` 2.5 s rigid, 0.2 s CRM), so `time_s` does not start at 0.
167
+
168
+ **Arm (`arm`, 47 columns).** Each row is one 50 Hz control step written as a transition
169
+ `(s, a, s')`: `q_0..3`, `qd_0..3` (joint angle rad / rate rad/s), `qcmd_0..3` (current joint
170
+ command), `act_0..3` (Δq_cmd), `qcmd_next_0..3` (command applied over this step — the paper's
171
+ action), `q_next_0..3`, `qd_next_0..3`, end-effector position in world (`ee_{x,y,z}`,
172
+ `ee_next_*`) and in the vehicle base frame (`ee_base_{x,y,z}`, `ee_next_base_*`), plus
173
+ `collision` (0/1), `collision_kind` (`ground` / `track` / `joint_limit` / empty), `contact_force_n`.
174
+ Episodes start from the home pose with random command increments and terminate on the first
175
+ contact or joint-limit hit, so lengths are 9–500 steps (mean ≈ 58). The paper's 8-D state is
176
+ `[q, qd]` with the end effector recovered by forward kinematics.
177
+
178
+ **Tracked (`tracked`, 42 columns).** The HMMWV chassis block without `body_slip_rad` and without
179
+ tire channels, plus `left_sprocket_speed_radps`, `right_sprocket_speed_radps`. The paper's 3-D
180
+ state is `vel_body_x_mps, vel_body_y_mps, yaw_rate_radps`; action is the driver triple.
181
+
182
+ #### `episodes.parquet` and the metadata bundle
183
+
184
+ `episodes.parquet` flattens each episode's `dataset_index.json` entry and its JSON sidecar
185
+ (nested values are JSON strings): `episode_id`, `split`, `scenario_family`, `rows`,
186
+ `duration_s`, `warmup_s`, `source_shard`, `parquet_file`, and per dataset e.g.
187
+ `height_map_index` / `height_map` / `terminated_out_of_bounds` (bumpy), `terminated_near_boundary`,
188
+ `crm_particles`, `crm_force_summary`, full `driver` profile (CRM), `collision_kind`,
189
+ `collision_links`, `start_q` (arm), `diverged` (tracked), `tire_nominal_radius_m`.
190
+
191
+ `metadata.tar.gz` is the untouched original metadata: per shard `dataset_index.json` and
192
+ `collector_config.resolved.json` (every materialised scenario: driver profile, seed, family,
193
+ terrain and solver settings), every per-episode sidecar, and the shard-plan manifests. It is what
194
+ lets the release be turned back into the collectors' original directory tree (below).
195
+
196
+ ### Loading
197
+
198
+ **Streaming with 🤗 `datasets`** (no download of the 44 GB flat set required):
199
+
200
+ ```python
201
+ from datasets import load_dataset
202
+ ds = load_dataset("harryzhang1018/NeDM", "hmmwv_crm", split="val", streaming=True)
203
+ for row in ds.take(3):
204
+ print(row["episode_id"], row["time_s"], row["vel_body_x_mps"], row["tire_fl_force_wheel_fz_n"])
205
+ episodes = load_dataset("harryzhang1018/NeDM", "hmmwv_bumpy_episodes", split="train")
206
+ ```
207
+
208
+ **Arrow / DuckDB** — one shard at a time, with row-group statistics for pushdown:
209
+
210
+ ```python
211
+ import pyarrow.parquet as pq
212
+ t = pq.read_table("raw/hmmwv_flat/train/shard_017.parquet",
213
+ columns=["episode_id", "time_s", "vel_body_x_mps", "yaw_rate_radps"],
214
+ filters=[("scenario_family", "==", "chirp_steer")])
215
+ ```
216
+
217
+ **Reproducing the paper** with the code repository (`conda env create -f environment.nedm.yml`):
218
+
219
+ ```bash
220
+ # training caches -> artifacts/training_datasets/, then any config in configs/ runs verbatim
221
+ PYTHONPATH=src python scripts/release/download_nedm_datasets.py --dataset all --no-raw --processed
222
+ PYTHONPATH=src python scripts/training/train_hmmwv_dynamics.py --config configs/tracked_transformer_v1.json
223
+
224
+ # raw Parquet -> the collectors' original per-episode CSV tree under artifacts/datasets/,
225
+ # so scripts/preprocess/* and the RL reference builders run unchanged
226
+ PYTHONPATH=src python scripts/release/download_nedm_datasets.py --dataset arm --rehydrate
227
+ ```
228
+
229
+ The rehydrated CSVs carry the float32 values the trainer uses; caches rebuilt from them are
230
+ bit-identical to the ones in `processed/` (this is checked in the release validation).
231
+
232
+ ### Processed caches
233
+
234
+ | Cache | Trained model | State | Action | Transitions (train / val) | Size |
235
+ |---|---|---|---|---|---|
236
+ | `hmmwv_tire_rigid_300g_normal_force_omega_seq_v1` | terrain-conditioned HMMWV NN-ROM (flat share) | 15-D | 3-D | 128,043,338 / 32,475,755 | 23.1 GB |
237
+ | `hmmwv_crm_2000_normal_force_omega_seq_v1` | terrain-conditioned HMMWV NN-ROM (CRM share) | 15-D | 3-D | 2,280,431 / 602,530 | 0.4 GB |
238
+ | `arm_dyn_v3_8d_seq16_v1` | arm NN-ROM | 8-D `[q, q̇]` | 4-D `q_cmd` | 763,886 / 141,754 | 87 MB |
239
+ | `tracked_drive_v2_seq16_v1` | tracked-base NN-ROM | 3-D `[vx, vy, r]` | 3-D | 1,407,465 / 273,859 | 81 MB |
240
+
241
+ Each cache holds contiguous `float32` arrays `{train,val}_{states,actions,targets,rollout}.npy`
242
+ (`targets = states[t+1] − states[t]`, `rollout` = pose per recorded row), `episode_starts` /
243
+ `episode_lengths`, `{train,val}_episodes.json` (episode ids and provenance) and `metadata.json`
244
+ (`state_fields`, `action_fields`, `dt_s`, train-split mean/std used for normalisation). Values are
245
+ raw physical units; the model applies the statistics.
246
+
247
+ ### Known limitations
248
+
249
+ * `hmmwv_bumpy` episodes are short (mean 3.3 k rows) because 78 % end on the 0.9 × 500 m
250
+ keep-in guard; the regime is meant as a test set.
251
+ * The arm collection is restricted to free-space motion (episodes end at first contact) and
252
+ under-samples the lower/rear workspace.
253
+ * CRM episodes are 12–18 s long (SPH cost) and use rigid-mesh tires; the CRM tire "force" is the
254
+ fluid–solid interaction force.
255
+ * Simulation is deterministic and noise-free; there is no sensor model.
256
+
257
+ ### Citation
258
+
259
+ ```bibtex
260
+ @article{zhang2026abstraction,
261
+ title = {Learning the Right Abstraction: Neural Reduced Dynamics for Complex Robot Control},
262
+ author = {Zhang, Harry and Negrut, Dan},
263
+ journal = {Preprint},
264
+ year = {2026}
265
+ }
266
+ ```
267
+
268
+ License: BSD-3-Clause (same as the code). Simulation assets are Project Chrono's HMMWV and M113
269
+ models; the LRV arm geometry is in the code repository (`src/arm_model/`).
270
+
271
+ ## Part B: traversing study
272
+
273
+ ### What the study is
274
+
275
+ Follow-on work to the paper, not part of it. A vehicle in [Project Chrono](https://projectchrono.org) has to reach a
276
+ goal across generated hill-and-crater terrain, on rigid ground and on CRM deformable soil. A neural network trained on
277
+ thousands of recorded Chrono drives predicts, for a candidate route and speed profile, where along the route the
278
+ vehicle is likely to fail: roll back on a climb, stall, dig into the soil or tip over. A route search picks the route
279
+ with the lowest predicted risk, and Chrono's stock PID path follower drives it. Separately, a route tracker is trained
280
+ with PPO inside a learned neural reduced dynamics model (NRD) and compared with that PID follower. The milestones, how
281
+ they were measured and what they do not show are documented in
282
+ [`traversing/` of the code repository](https://github.com/uwsbel/NeDM/tree/main/traversing). This part holds what
283
+ reproduces those results: the recorded drives, the exact training files built from them, every trained model behind a
284
+ result-table column, and the evaluation inputs and per-drive records. Every file is a byte-exact copy of the study's
285
+ record, or a deterministic archive of such copies; nothing was re-encoded.
286
+
287
+ Terms used below:
288
+
289
+ - **Milestones** (the `milestone` labels of each item):
290
+ - `m1`: a Chrono depth camera in the planning loop (live multi-waypoint missions, rigid ground);
291
+ - `m2`: one risk model for rigid ground and soil, not told which one it is on (HMMWV on f104);
292
+ - `m3`: a learned route tracker against Chrono's PID follower;
293
+ - `m4a`: the HMMWV planner on arenas it never trained on;
294
+ - `m4b`: the pipeline on other vehicles (Gator, Polaris; the M113 only in a smoke test).
295
+ - **Arenas.** f104 is the 80 m x 80 m hill-and-crater arena where most training drives were recorded. g203, g217 and
296
+ g228 are sibling arenas from the same terrain generator: the depth-camera model of m1 trained on all three (g216 and
297
+ g231 were its held-out arenas), the m4a planners on g203 and g228 (g217 was their development arena). The unseen
298
+ arenas are eight more made with new seeds and never used in training.
299
+ - **Ground.** Rigid means a rigid heightmap. Soil means Chrono's CRM particle soil: a 0.24 m layer over a rigid floor,
300
+ one setting throughout.
301
+ - **Groups and route ids.** A start/goal pair is a group. Each group has several routes: designed routes (sideways
302
+ offsets x speed profiles, ids ending `_route_NN`) and planner-style routes (`_op_NN`), for example
303
+ `f104_v2_group_0000_route_03`. The soil collections and the other vehicles reuse these ids; the Gator and Polaris
304
+ drive folders carry a `gator__` or `polaris__` prefix.
305
+ - **Drive.** One Chrono run of one route with the stock PID path follower, after a 0.8 s braked settle, recorded every
306
+ 50 ms. It stops at the goal (2.5 m radius), on rollover, on leaving the terrain, on prolonged blockage, on soil when a
307
+ wheel digs through the whole layer, or at the 120 s horizon.
308
+
309
+ ### Layout
310
+
311
+ ```
312
+ traversing/README.md short index: every item with bundle, milestone, packing, files, bytes, restore path
313
+ traversing/release_manifest.json every file (bytes, sha256, item, kind) and every item (bundle, milestone, ...)
314
+ traversing/models/<item>/... trained networks with their training records
315
+ traversing/evaluation/<item>/... evaluation suites, locked route picks, task lists, per-drive records and results
316
+ traversing/processed/<item>/... the exact training files the models were fitted on
317
+ traversing/raw/<item>/... the recorded Chrono drives the training files were built from
318
+ traversing/assets/<item>/... arena heightmaps, the f104 terrain grid, the soil setting and vehicle variants
319
+ ```
320
+
321
+ Each item is packed in one of two ways:
322
+
323
+ - **`files`.** Every file is uploaded as is, at `traversing/<bundle>/<item>/<path>`, where `<path>` is its path under
324
+ the item's source folder. Used for models, single large training files and small sets of evaluation files.
325
+ - **`tar`.** Folders of many small files (mostly drive folders) go into `part-00000.tar.gz`, `part-00001.tar.gz`, ...
326
+ of about 1 GiB of uncompressed files each; a drive folder never spans two shards. Each member is stored under its
327
+ restore path relative to the code repository's root, so extracting a shard at the root of a checkout puts it in
328
+ place. The archives are deterministic (members sorted by path, time stamps 0, owner 0, mode 0644, regular files
329
+ only, PAX format, gzip level 6 without name or time). Next to the shards:
330
+ - `index.csv.gz`: one row per member, with columns `path, bytes, sha256, shard`;
331
+ - `ids.txt.gz`: the list of drive folders, for items selected by such a list;
332
+ - `episodes.csv.gz`: raw collections only, one row per drive (see below).
333
+
334
+ `release_manifest.json` is the reference for everything under `traversing/`:
335
+
336
+ - `source_commit`: the experiment commit the files come from,
337
+ [`901d6c9`](https://github.com/uwsbel/NeDM/tree/901d6c9423a16c0fafc3d60056065415d5a725f2);
338
+ - `items`: per item its bundle, milestones, description, `needed_for` (`rerun`, `recount` or `retrain`), packing,
339
+ `restore_root`, member count and bytes, Hub files, parameter counts of its checkpoints (`known_params`), and the other
340
+ items it needs (`requires`);
341
+ - `files`: per Hub file its bytes, SHA256, item and kind (`file`, `tar_shard`, `index` or `episodes`). Shards also
342
+ record `tar_bytes` and `tar_sha256` of the uncompressed stream, since the compressed bytes depend on the zlib
343
+ version;
344
+ - `path_remap`: how paths written inside released task files map to restore paths, and the symbolic links the
345
+ planners expect (the release holds no links; `ln -s` recreates them from this list).
346
+
347
+ The code repository keeps a copy pinned to a Hub commit, `traversing/manifests/hf_release_manifest.json`, whose
348
+ `hf_revision` is `6620faead5225ac9aa5ae8ab19bc2ef2db38a863`.
349
+
350
+ ### Items
351
+
352
+ <!-- BEGIN fill_card.py: items (generated from traversing/release_manifest.json; do not edit by hand) -->
353
+
354
+ **119 items, 732 files, 56.6 GB** (models 30 items, 206 MB; evaluation 33 items, 5.8 GB; processed 28 items, 33.9 GB; raw 25 items, 16.8 GB; assets 3 items, 8.1 MB). The raw collections with an episodes table hold 189,335 drives. Sizes are Hub bytes (compressed for tar shards); `release_manifest.json` has every file's exact size and SHA256. The descriptions are the manifest's: they name the column of the result tables in `traversing/results/` that each model or record stands behind, and the study's own file and model names.
355
+
356
+ #### Models
357
+
358
+ | Item | Milestone | What it is | Files | Size |
359
+ |---|---|---|---|---|
360
+ | `m1_nav_direct_depth_risk_ensemble` | m1 | Navigation risk ensemble: 3 seeds (s0-s2) of the direct-depth corridor model (channels range_abs, sec1, speed, valid) that scored every candidate route in all 120 navigation missions (all 4 decision-timing arms). | 4 | 3.1 MB |
361
+ | `m2_joint_station_history_transformer` | m2 | Joint station+history transformer trained on the same rows (deploy_a3_haux_txjoint, 5 seeds s0-s4) behind transformer_1s, transformer_0p5s and transformer_0p5s_grad (soil). | 6 | 8.4 MB |
362
+ | `m2_oracle_world_label_model` | m2 | Shared model given the true world label (T, 5 seeds s0-s4) behind oracle_tag_standing, oracle_tag_3s, oracle_tag_1s, oracle_tag_0p5s. | 6 | 5.3 MB |
363
+ | `m2_pooled_no_label_no_history_model` | m2 | Shared model with neither history nor label (P, 5 seeds s0-s4) behind pooled_3s, pooled_1s, pooled_0p5s. | 6 | 5.3 MB |
364
+ | `m2_rigid_only_planner_standing_start` | m2 | Earlier deployed rigid-only planner (night-2 N2, 5 seeds s0-s4) behind column specialist_rigid_standing (study arm Srigid, sampling arm B) in both m2 tables. | 6 | 5.2 MB |
365
+ | `m2_rigid_specialist_same_rows` | m2 | Single-world rigid model trained on the same re-anchored rows (Sp_rigid, 5 seeds s0-s4) behind specialist_rigid_3s. | 6 | 5.3 MB |
366
+ | `m2_shared_history_early_rows_final_model` | m2 | Model of the FINAL label-free configuration: the history design retrained with extra early-decision and moving-branch rows (deploy_a1_haux_gru, 5 seeds s0-s4). Behind shared_hist_early_rows_1s, shared_hist_early_rows_0p5s (soil and rigid) and shared_hist_early_rows_0p5s_grad (the 780/800 soil and 800/800 rigid headline). | 6 | 6.2 MB |
367
+ | `m2_shared_history_model` | m2 | Shared rigid/soil history model H (CNN-GRU + 2 s history encoder, 5 seeds s0-s4) behind shared_hist_standing, shared_hist_3s, shared_masked_3s (history masked at decision), shared_hist_1s and shared_hist_0p5s. | 6 | 5.5 MB |
368
+ | `m2_soil_only_planner_standing_start` | m2 | Earlier deployed soil-only planner (CRM_N2, 5 seeds s0-s4) behind column specialist_soil_standing (study arm Scrm, sampling arm B) in both m2 tables. | 6 | 5.2 MB |
369
+ | `m2_soil_specialist_same_rows` | m2 | Single-world soil model trained on the same re-anchored rows (Sp_crm, 5 seeds s0-s4) behind specialist_soil_3s and specialist_soil_1s. | 6 | 5.3 MB |
370
+ | `m3_tracker_learned_dynamics_model` | m3 | Tag-conditioned NRD vehicle-dynamics model (causal transformer, 17-D state, 50 ms steps, 8x8 terrain crop) inside which the round-2 PPO policy was trained; not used when driving. | 2 | 19.7 MB |
371
+ | `m3_tracker_round2_numpy_actor` | m3 | Deployed round-2 learned tracker: the PPO actor exported to NumPy (158-D observation, 3 actions), run without torch or the NRD model; behind column nrd_policy_v2 of m3_tracker_routes.csv. | 2 | 2.0 MB |
372
+ | `m3_tracker_round2_ppo_checkpoint` | m3 | Final PPO torch checkpoint (iteration 999) of the round-2 tracker, the source of the NumPy actor. Not needed to re-drive (the actor is enough) and not a training input, but it is the only artefact with which the actor export and parity check can be repeated. | 3 | 5.9 MB |
373
+ | `m4a_rigid_f104_only_ens1` | m4a | CNN-GRU route-risk ensemble, 5 seeds (s0-s4), M1a_rigid_deploy, behind columns f104_only_ens1_fixed2mps and _speedfree (rigid, M1a). The same bytes are aliased as H, the HMMWV-trained rigid model of the Gator study. | 8 | 7.8 MB |
374
+ | `m4a_rigid_f104_only_ens2` | m4a | CNN-GRU route-risk ensemble, 5 seeds (s5-s9), M1b_rigid_deploy, behind columns f104_only_ens2_fixed2mps and _speedfree (rigid, M1b). | 8 | 7.8 MB |
375
+ | `m4a_rigid_three_arenas_all_data` | m4a | CNN-GRU route-risk ensemble, 5 seeds (s0-s4), A3_rigid_deploy, behind columns three_arenas_all_data_fixed2mps and _speedfree (rigid, A3). | 8 | 12.5 MB |
376
+ | `m4a_rigid_three_arenas_same_total_ens1` | m4a | CNN-GRU route-risk ensemble, 5 seeds (s0-s4), M3a_rigid_deploy, behind columns three_arenas_same_total_ens1_fixed2mps and _speedfree (rigid, M3a). | 8 | 8.0 MB |
377
+ | `m4a_rigid_three_arenas_same_total_ens2` | m4a | CNN-GRU route-risk ensemble, 5 seeds (s5-s9), M3b_rigid_deploy, behind columns three_arenas_same_total_ens2_fixed2mps and _speedfree (rigid, M3b). | 8 | 8.0 MB |
378
+ | `m4a_rigid_two_arenas_same_total` | m4a | CNN-GRU route-risk ensemble, 5 seeds (s0-s4), M2_rigid_deploy, behind columns two_arenas_same_total_fixed2mps and _speedfree (rigid, M2). | 8 | 7.9 MB |
379
+ | `m4a_soil_f104_only_ens1` | m4a | CNN-GRU route-risk ensemble, 5 seeds (s0-s4), M1a_soil_deploy, behind column f104_only_ens1 (soil table, study M1a). The same bytes are aliased as H_soil, the Gator study's stage-1 HMMWV soil model. | 8 | 6.3 MB |
380
+ | `m4a_soil_f104_only_ens2` | m4a | CNN-GRU route-risk ensemble, 5 seeds (s5-s9), M1b_soil_deploy, behind column f104_only_ens2 (soil table, study M1b). | 8 | 6.3 MB |
381
+ | `m4a_soil_three_arenas_all_data` | m4a | CNN-GRU route-risk ensemble, 5 seeds (s0-s4), A3_soil_deploy, behind column three_arenas_all_data (soil, A3). | 8 | 7.1 MB |
382
+ | `m4a_soil_three_arenas_same_total_ens1` | m4a | CNN-GRU route-risk ensemble, 5 seeds (s0-s4), M3a_soil_deploy, behind column three_arenas_same_total_ens1 (soil, M3a). | 8 | 6.3 MB |
383
+ | `m4a_soil_three_arenas_same_total_ens2` | m4a | CNN-GRU route-risk ensemble, 5 seeds (s5-s9), M3b_soil_deploy, behind column three_arenas_same_total_ens2 (soil, M3b). | 8 | 6.3 MB |
384
+ | `m4a_soil_two_arenas_same_total` | m4a | CNN-GRU route-risk ensemble, 5 seeds (s0-s4), M2_soil_deploy, behind column two_arenas_same_total (soil, M2). | 8 | 6.3 MB |
385
+ | `m4b_gator_rigid_own_model` | m4b | Gator-trained rigid ensemble on the Gator's 24,000 f104 rigid drives (CNN-GRU, 5 seeds s0-s4, G_rigid_deploy). Behind the README bar-table Gator rigid row (800/800 on f104; arms G_free at free speed and the G_fixed2 addendum); not a compact-table column. | 8 | 7.6 MB |
386
+ | `m4b_gator_soil_own_model_full_data` | m4b | Gator-trained soil ensemble on all 15,235 Gator f104 soil drives (CNN-GRU, 5 seeds s0-s4, G_full_soil_deploy), behind gator_own_model_sampling (Gfull_free_gator) and gator_own_model_sampling_grad (Gfull_grad_gator). | 8 | 6.8 MB |
387
+ | `m4b_gator_soil_own_model_tiers0to6` | m4b | Gator-trained soil ensemble on only the first 7 routes of each group (8,399 drives; CNN-GRU, 5 seeds s0-s4, G_soil_deploy), behind gator_own_model_tiers0to6_sampling (G_free_gator). | 8 | 6.2 MB |
388
+ | `m4b_hmmwv_soil_model_full_data` | m4b | HMMWV-trained soil ensemble on the full HMMWV f104 soil file, the same ids as the Gator (CNN-GRU, 5 seeds s0-s4, H_full_soil_deploy). Behind gator_hmmwv_model_sampling (Hfull_free_gator), hmmwv_own_model_sampling (Hfull_free) and hmmwv_own_model_sampling_grad (Hfull_grad_hmmwv). | 8 | 6.9 MB |
389
+ | `m4b_polaris_soil_own_model_full_data` | m4b | Final Polaris soil ensemble on all 15,229 valid Polaris f104 soil drives (CNN-GRU, 5 seeds s0-s4, polaris_full_soil_deploy). Behind polaris_own_model_sampling_grad and polaris_own_model_sampling on f104 and on the 8 unseen arenas; polaris_corrected_driveline_grad_routes re-drives the polaris_grad routes. | 7 | 5.4 MB |
390
+
391
+ #### Evaluation
392
+
393
+ | Item | Milestone | What it is | Files | Size |
394
+ |---|---|---|---|---|
395
+ | `nav_corrected_mission_outcomes` | m1 | Corrected navigation read-out after the rescue-route fix: summary.json and the 120 per-mission outcome files (30 missions x 4 decision-timing arms) behind m1_navigation_missions.csv. | 121 | 377 kB |
396
+ | `nav_corrected_run_folders` | m1 | Per-mission decisions, candidate routes and trajectory of the 120 corrected navigation drives. | 3 | 33.8 MB |
397
+ | `nav_missions_and_task_list` | m1 | The 30 frozen waypoint missions and the 120-row task list (mission x decision-timing arm). | 31 | 67.1 kB |
398
+ | `f104_eval_suite_800` | m2, m4a, m4b | The frozen 800-pair f104 start/goal suite: suite definition, lock file, 800 case files, the designed route of each group and the locked standing-start task lists. | 2 | 5.7 MB |
399
+ | `planner_map_f104` | m2, m4a, m4b | Whole-arena overhead depth map of f104 on which every f104 planner scores its candidate routes. | 2 | 4.1 MB |
400
+ | `shared_model_decision_states` | m2 | Inputs of the moving-start decisions: straight approach routes, the approach drives, and the recorded decision poses and 2 s history arrays at 3 s, 1 s and 0.5 s, with the approach task files. | 2 | 53.5 MB |
401
+ | `shared_model_drive_folders_rigid` | m2 | Per-drive folders behind every cell of m2_shared_risk_rigid.csv (9,469 distinct drives for 9,600 cells). | 3 | 435 MB |
402
+ | `shared_model_drive_folders_soil` | m2 | Per-drive folders behind every cell of m2_shared_risk_soil.csv (18,027 distinct drives for 18,400 cells). | 4 | 903 MB |
403
+ | `shared_model_drive_task_lists` | m2 | Task lists that drove the milestone-2 table arms (standing start, 3 s, 1 s, 0.5 s and final), with the two standing-start lock files; those two locks cover unreleased route copies and cannot be checked from the release. | 14 | 25.8 MB |
404
+ | `shared_model_results_early_and_final` | m2 | Per-pair results of the 1 s and 0.5 s early-decision arms and of the final gradient-refined configuration on soil and rigid ground. | 4 | 16.7 MB |
405
+ | `shared_model_results_standing_and_3s` | m2 | Per-pair results of the standing-start arms and the 3 s-approach arms, soil and rigid. | 4 | 10.6 MB |
406
+ | `shared_model_route_picks_3s` | m2 | Locked planner output of the 3 s-approach arms. | 2 | 45.8 MB |
407
+ | `shared_model_route_picks_early` | m2 | Locked planner output of the 1 s and 0.5 s early-decision arms (sampling search only), including the rigid 0.5 s arm. | 2 | 52.7 MB |
408
+ | `shared_model_route_picks_final` | m2 | Locked planner output of the final gradient-refined arms after the 0.5 s approach (soil and rigid). | 2 | 38.3 MB |
409
+ | `shared_model_route_picks_standing` | m2 | Locked planner output of the standing-start arms: per-pair pick records with candidate scores, route files, task list, run summary and lock file. | 2 | 47.6 MB |
410
+ | `f104_reference_routes_and_cases` | m3, m4b | f104 start/goal case files and reference routes that released drive tasks point at: the 423 routes and 55 cases the tracker drives follow, and the 147 routes (88 designed, 59 on-policy) and 27 cases of the vehicle smoke test: the 144 sample-A routes (86 designed, 58 planner proposals) plus the 3 routes of the bit-identity check. | 2 | 1.4 MB |
411
+ | `tracker_drive_folders` | m3 | Drive folders of the 2,538 tracker table rows (native PID, held PID and learned tracker on 423 routes, both grounds). | 3 | 141 MB |
412
+ | `tracker_results_suite_tasks` | m3 | Per-route tracker results (both grounds), the 423-route tracking suite with strata, and the task lists that drove the PID and learned-tracker arms. | 7 | 6.2 MB |
413
+ | `planner_maps_new_arenas` | m4a, m4b | Overhead depth maps of the 11 other planner arenas (g203, g217, g228 and the 8 unseen test arenas) and the map checks. | 23 | 45.2 MB |
414
+ | `unseen_and_vehicle_picks_lock_files` | m4a, m4b | Top-level pick lock files and job lists of the unseen-arena, Gator and Polaris evaluations. | 23 | 567 kB |
415
+ | `unseen_arena_drive_folders_rigid` | m4a | Drive folders behind the 37,100 cells of m4_unseen_arenas_hmmwv_rigid.csv (36,653 distinct drives). | 5 | 1.9 GB |
416
+ | `unseen_arena_drive_folders_soil` | m4a, m4b | Drive folders behind the 9,000 non-empty cells of m4_unseen_arenas_hmmwv_soil.csv (8,746 distinct drives). | 3 | 411 MB |
417
+ | `unseen_arena_drive_task_lists` | m4a, m4b | Task lists that drove the HMMWV soil and rigid unseen-arena evaluations (including the Gator rigid f104 drives). | 18 | 31.4 MB |
418
+ | `unseen_arena_eval_indexes` | m4a, m4b | Per-drive evaluation indexes of the unseen-arena study (soil and rigid; the rigid index also holds the Gator rigid f104 rows) and the task-to-arm mapping files. | 11 | 80.5 MB |
419
+ | `unseen_arena_route_picks` | m4a, m4b | Locked planner picks of every HMMWV arm of the two unseen-arena tables, on the 8 unseen arenas, f104, the held-out and dev arenas (236 arm x arena folders). | 3 | 228 MB |
420
+ | `unseen_arena_suites` | m4a, m4b | Frozen start/goal suites of the 8 unseen test arenas, held-out g203/g228 and dev g217: case files, designed routes, per-suite lock files, manifests, the f104 in-distribution list, the declared soil subset and the spread-headroom group list. | 2 | 43.7 MB |
421
+ | `gator_rigid_f104_drive_folders` | m4b | Drive folders of the Gator rigid f104 read-out in the README bar table: the Gator-trained planner (800/800) and the straight route at 6 m/s. | 3 | 68.7 MB |
422
+ | `polaris_unseen_drive_folders` | m4b | Drive folders behind the 3,000 cells of m4_polaris_unseen_soil.csv (2,618 distinct drives). | 3 | 183 MB |
423
+ | `vehicle_drive_task_lists` | m4b | Task lists of the Gator/HMMWV all-data drives, Polaris on f104, the gradient-refined Gator/HMMWV drives, Polaris on the unseen arenas and the smoke test. | 16 | 6.6 MB |
424
+ | `vehicle_eval_indexes_and_smoke_extract` | m4b | Per-drive indexes of the Gator all-data comparison, Polaris on f104 and Polaris on the unseen arenas, their task-mapping files, the per-route smoke and collection extract, and the definition of smoke sample A. | 11 | 54.0 MB |
425
+ | `vehicle_f104_drive_folders` | m4b | Drive folders behind the 9,600 cells of m4_vehicles_f104_soil.csv (9,243 distinct drives; Gator, HMMWV and Polaris variants). | 3 | 702 MB |
426
+ | `vehicle_route_picks` | m4b | Locked picks of the vehicle arms: Gator own models, HMMWV-trained model, gradient refinements, Polaris on f104 and on the 8 unseen arenas, and the Gator rigid planner. | 3 | 86.2 MB |
427
+ | `vehicle_smoke_test_drives` | m4b | Complete drive folders of the vehicle smoke test on sample A (144 f104 soil routes) for the 7 variants with their own folders (three Polaris driveline/wheel variants, stock and re-geared M113, Gator at 1 ms and 0.5 ms steps), plus the failure record of the one crashed drive. The polaris_stock and hmmwv_stored columns of m4_vehicle_smoke.csv come from drives released in the raw collections polaris_f104_soil_collection_runs and hmmwv_soil_f104_collection (not required: about 3.7 GB). | 3 | 148 MB |
428
+
429
+ #### Processed training files
430
+
431
+ | Item | Milestone | What it is | Files | Size |
432
+ |---|---|---|---|---|
433
+ | `nav_depth_corridors_arena_g203` | m1 | Navigation corridors on sibling training arena g203. 4,925 rows. | 1 | 366 MB |
434
+ | `nav_depth_corridors_arena_g216_heldout` | m1 | Navigation corridors on held-out arena g216 (read by the trainer for its held-out route-choice score, not fitted). 4,956 rows. | 1 | 368 MB |
435
+ | `nav_depth_corridors_arena_g217` | m1 | Navigation corridors on sibling training arena g217. 5,008 rows. | 1 | 372 MB |
436
+ | `nav_depth_corridors_arena_g228` | m1 | Navigation corridors on sibling training arena g228. 4,937 rows. | 1 | 367 MB |
437
+ | `nav_depth_corridors_arena_g231_heldout` | m1 | Navigation corridors on held-out arena g231 (read by the trainer for its held-out score, not fitted). 4,889 rows. | 1 | 363 MB |
438
+ | `nav_depth_corridors_f104_extra_drives` | m1 | Navigation corridors from f104 gen_v1 / sensor_v1 test drives (fitted; f104 is a training arena). 3,111 rows. | 1 | 231 MB |
439
+ | `nav_depth_corridors_f104_training_routes` | m1 | Direct-depth route-corridor tensors for the navigation risk ensemble (matched_Dabs, 3 seeds): all 36,199 f104 rigid training routes (labels reused from the merged station set via R/sensor_v1/labels_station_ds_all.npz, corridors re-sampled from the back-projected depth grid). 36,199 rows. | 1 | 2.7 GB |
440
+ | `rigid_specialist_training_rows` | m2 | Training rows of the earlier rigid-only f104 planner N2 (column specialist_rigid_standing, arm Srigid): merged night-1 + night-2 rigid route set, 36,199 routes / 2,700 groups (train 33,840, val 764, test 1,595; 31,851 fitted per N2_meta.json). | 1 | 1.1 GB |
441
+ | `shared_model_baseline_reanchored_rows` | m2 | Re-anchored rigid + soil rows with a 2 s history on the f104 route ids: 115,868 rows (105,193 fitted). Training file of the generalist ensembles H, P, T, Sp_crm, Sp_rigid (columns oracle_tag_*, shared_hist_standing/3s/1s/0p5s, pooled_*, shared_masked_3s, specialist_soil_3s/1s, specialist_rigid_3s). | 1 | 2.1 GB |
442
+ | `shared_model_final_anchor_k60_rows` | m2 | Final shared-model training file 3 of 3: decision rows at frame 60 (3 s), the k=60 slice of anchor_k40_60_80.npz (14,972 rigid + 14,727 soil). 29,699 rows, 26,936 fitted. | 1 | 541 MB |
443
+ | `shared_model_final_reanchored_plus_branch_rows` | m2 | Final shared-model training file 1 of 3: mixed_reanchor rows plus 4,614 moving-prefix branch rows of both worlds. 120,482 rows, 109,244 fitted. | 1 | 2.2 GB |
444
+ | `shared_model_final_short_anchor_rows` | m2 | Final shared-model training file 2 of 3: early decision rows at frames 10/20/30 of every rigid and soil f104 episode. 89,998 rows, 81,634 fitted. | 1 | 1.6 GB |
445
+ | `soil_specialist_training_rows` | m2 | Training rows of the earlier soil-only f104 planner CRM_N2 (column specialist_soil_standing, arm Scrm): one row per validated HMMWV soil route (15,235); 13,821 fitted per CRM_N2_deploy.json. | 1 | 471 MB |
446
+ | `tracker_dynamics_training_cache` | m3 | Per-episode 50 ms state/action/pose/power cache of 43,235 f104 episodes (rigid 26,500 = 24,000 production + 1,500 perturbed + 1,000 round-1 policy harvest; soil 16,735 = 15,235 collection + 1,500 perturbed) plus cache_manifest.json and build_report.json. | 3 | 2.0 GB |
447
+ | `tracker_group_split_file` | m3 | Night-2 soil twin dataset whose group/split arrays define the 1,200-group split (1,089/56/55) used by the cache builder and cross-checked by the NRD trainer. | 1 | 169 MB |
448
+ | `terrain_rigid_subset_f104_only` | m4a | HMMWV rigid, f104 only, 1,089 groups. 93,397 rows, 84,787 fitted. Trained M1a and M1b (columns f104_only_ens1/ens2 _fixed2mps/_speedfree); byte-identical to H_f104_hmmwv_rigid.npz (Gator-study H). | 1 | 1.7 GB |
449
+ | `terrain_rigid_subset_three_arenas_all` | m4a | HMMWV rigid, all data: f104 1,089 + g203 1,083 + g228 1,063 groups. 278,735 rows, 250,490 fitted. Trained A3 (column three_arenas_all_data). | 1 | 5.0 GB |
450
+ | `terrain_rigid_subset_three_arenas_same_total` | m4a | HMMWV rigid, f104 + g203 + g228, same total. 112,726 rows, 84,481 fitted. Trained M3a and M3b (columns three_arenas_same_total_ens1/ens2). | 1 | 2.0 GB |
451
+ | `terrain_rigid_subset_two_arenas` | m4a | HMMWV rigid, f104 + g203, same total. 101,916 rows, 84,310 fitted. Trained M2 (column two_arenas_same_total). | 1 | 1.8 GB |
452
+ | `terrain_soil_subset_f104_only` | m4a | HMMWV soil, f104 only, 1,089 training groups, tiers 0-6. 32,152 rows, 29,210 fitted. Trained M1a_soil and M1b_soil (columns f104_only_ens1/ens2, soil) and is byte-identical to H_f104_hmmwv_soil.npz (Gator-study H_soil). | 1 | 583 MB |
453
+ | `terrain_soil_subset_three_arenas_all` | m4a | HMMWV soil, all data: f104 1,089 + g203 559 + g228 520 groups. 64,400 rows, 57,898 fitted. Trained A3_soil (column three_arenas_all_data). | 1 | 1.2 GB |
454
+ | `terrain_soil_subset_three_arenas_same_total` | m4a | HMMWV soil, f104 + g203 + g228, 363 groups each. 35,573 rows, 29,071 fitted. Trained M3a_soil and M3b_soil (columns three_arenas_same_total_ens1/ens2). | 1 | 644 MB |
455
+ | `terrain_soil_subset_two_arenas` | m4a | HMMWV soil, f104 + g203, 545 groups each. 33,227 rows, 29,048 fitted. Trained M2_soil (column two_arenas_same_total). | 1 | 603 MB |
456
+ | `gator_rigid_subset_all` | m4b | Gator rigid on f104, all 24,000 route ids. 93,551 rows, 84,922 fitted. Trained G, the Gator rigid planner cited in the README bar table (800/800). | 1 | 1.7 GB |
457
+ | `gator_soil_subset_all` | m4b | Gator soil on f104, all 15,235 validated ids (tiers 0-12). 55,826 rows, 50,822 fitted. Trained G_full_soil (columns gator_own_model_sampling, gator_own_model_sampling_grad). | 1 | 1.0 GB |
458
+ | `gator_soil_subset_tiers0to6` | m4b | Gator soil on f104, tiers 0-6 (8,399 drives). 30,827 rows, 28,057 fitted. Trained G_soil (column gator_own_model_tiers0to6_sampling). | 1 | 557 MB |
459
+ | `hmmwv_soil_subset_gator_matched_all` | m4b | HMMWV soil on f104, exactly the route ids the Gator validated (all tiers). 58,268 rows, 52,923 fitted. Trained H_full_soil (columns gator_hmmwv_model_sampling, hmmwv_own_model_sampling, hmmwv_own_model_sampling_grad). | 1 | 1.1 GB |
460
+ | `polaris_soil_subset_all` | m4b | Polaris soil on f104, all 15,229 valid ids (tiers 0-12). 57,228 rows, 52,021 fitted. Trained polaris_full_soil (all Polaris planner columns on f104 and the unseen arenas). | 2 | 1.0 GB |
461
+
462
+ #### Raw collections
463
+
464
+ | Item | Milestone | What it is | Files | Size |
465
+ |---|---|---|---|---|
466
+ | `hmmwv_rigid_f104_early_waves` | m1, m2 | Seven small early HMMWV rigid f104 waves whose drives are in the navigation model's 36,199-route f104 label file: prospective_v1 309, fixed_speed_v1 292, speed_c4 206, wide_v1 146, speed_c6 90, band_v1 73, showcase_v1 14. The last six make up the 821 rows the label file tags as MPPI arms. | 4 | 84.9 MB |
467
+ | `hmmwv_rigid_f104_first_overnight_collection` | m1, m2 | Earlier HMMWV rigid f104 production collection (1,500 groups, the first overnight wave). It is not part of the 24,000-route pool. It supplies 11,412 of the navigation model's 36,199 f104 routes and part of the rigid N2 specialist's training rows. | 4 | 681 MB |
468
+ | `hmmwv_rigid_f104_pool_designed` | m1, m2, m3, m4a | HMMWV rigid-ground pool on f104, designed routes: 1,200 start/goal groups x 12 routes. This is the first half of the 24,000-route rigid pool. Every later rigid f104 model and the tracker cache were built from this pool, and the Gator and Polaris re-drove its route ids. | 4 | 853 MB |
469
+ | `hmmwv_rigid_f104_pool_onpolicy` | m1, m2, m3, m4a | HMMWV rigid-ground pool on f104, planner-style (on-policy) routes: 1,200 groups x 8 routes. This is the second half of the 24,000-route rigid pool. | 5 | 1.1 GB |
470
+ | `hmmwv_rigid_multi_arena_test_drives` | m1 | HMMWV rigid test drives on f104, g203, g217 and g228 from the multi-arena study (planner, rule-based, fixed-speed and straight-route arms; 1,103 / 1,098 / 1,132 / 1,111). The navigation trainer (sensor_train_v2.py) fits every row from a training arena whatever its source, so these are training rows. | 4 | 250 MB |
471
+ | `hmmwv_rigid_sensor_study_test_drives` | m1 | HMMWV rigid drives from the sensor study's two test campaigns (sensor_v1/test 3,614 and test2 4,523) on the training arenas f104, g203, g217 and g228. They enter the navigation training rows through ds_v2_gen_&lt;arena&gt;.npz. | 4 | 408 MB |
472
+ | `hmmwv_rigid_sibling_arenas_designed_routes` | m1 | HMMWV rigid designed-route drives on the navigation model's three sibling training arenas g203, g217 and g228 (1,800 each, 5,400 total). The g216 and g231 drives in the same folder are held-out evaluation only and are excluded. | 4 | 330 MB |
473
+ | `hmmwv_rigid_f104_branch_anchor_records` | m2 | Per-anchor records of the HMMWV rigid f104 branch drives (&lt;episode&gt;\_\_a4, 800 anchor states): the automatic branch choice (branch_auto.json, 789) or the skip record (skipped.json, 11) and the completion marker. The drives themselves are hmmwv_rigid_f104_branch_continuations. | 3 | 519 kB |
474
+ | `hmmwv_rigid_f104_branch_continuations` | m2 | HMMWV rigid drives that branch from a moving state on f104: 2,367 continuation drives (&lt;anchor&gt;\_\_a4\_\_c&lt;j&gt;; 2,358 produce rows, 9 were skipped) from 800 anchor states. The per-anchor records are hmmwv_rigid_f104_branch_anchor_records. | 4 | 251 MB |
475
+ | `hmmwv_soil_f104_branch_continuations` | m2 | HMMWV soil drives that branch from a moving state on f104: 752 anchor states x 3 = 2,256 continuation drives (&lt;episode&gt;\_\_c&lt;j&gt;). | 4 | 246 MB |
476
+ | `hmmwv_soil_f104_collection` | m2, m3, m4a, m4b | HMMWV soil collection on f104 (Chrono's particle-based deformable soil, 0.24 m deep over a rigid floor): 15,235 validated route ids in 1,200 groups, tiers 0-12 (9,168 designed + 6,067 planner-style). The Gator and Polaris later re-drove the same ids. | 5 | 1.4 GB |
477
+ | `hmmwv_rigid_tracker_held_control_drives` | m3 | HMMWV rigid drives with perturbed controls on f104 training routes: controls held for a true 50 ms with brake taps added (1,500 drives, &lt;route&gt;\_\_b3). | 4 | 100 MB |
478
+ | `hmmwv_rigid_tracker_policy_harvest` | m3 | HMMWV rigid drives by the round-1 learned tracker on 1,000 training routes (&lt;route&gt;\_\_harvest). They were added to the dynamics cache. | 4 | 68.9 MB |
479
+ | `hmmwv_soil_tracker_held_control_drives` | m3 | HMMWV soil drives with the same held-control perturbations on f104 training routes (1,500 drives, &lt;route&gt;\_\_b3). | 4 | 130 MB |
480
+ | `arena_gator_collection_task_files` | m4a, m4b | Task files passed to the collection builds of the arena and vehicle studies: the Gator rigid pool (rigid_v2), the Gator soil builds (soil_v3 for tiers 0-12, soil_v2 for tiers 0-6, which also defines the HMMWV g203/g228 soil tiers) and the HMMWV g203/g228 rigid pools (rigid_hmmwv_v1). | 4 | 103 MB |
481
+ | `hmmwv_rigid_g203_pool` | m4a | HMMWV rigid 24,000-route pool on the extra training arena g203 (1,200 groups x 20 routes; 14,400 route_ ids + 9,600 op_ ids). ag_build_ds.py selected all 24,000 (92,225 rows). | 6 | 2.0 GB |
482
+ | `hmmwv_rigid_g228_pool` | m4a | HMMWV rigid 24,000-route pool on the extra training arena g228 (93,113 rows). | 6 | 2.0 GB |
483
+ | `hmmwv_soil_g203_tiers0to6` | m4a | HMMWV soil drives on g203, tiers 0-6 (the first 7 routes of each of 606 start/goal groups): 4,242 driven, of which 4,240 pass QA (2 rejected as crm_qa:unstalled_break). | 4 | 385 MB |
484
+ | `hmmwv_soil_g228_tiers0to6` | m4a | HMMWV soil drives on g228, tiers 0-6: 4,242 driven, all validated. | 4 | 377 MB |
485
+ | `gator_collection_qa_records` | m4b | Recorded QA of the Gator collections and the validated-id lists passed to the subset builder: soil all tiers, soil tiers 0-6 and rigid. | 8 | 9.1 MB |
486
+ | `gator_f104_rigid_collection_runs` | m4b | The Gator driving the 24,000-route rigid f104 pool (1,200 groups x 20: 14,400 designed routes and 9,600 planner-style routes), 165.7 simulated hours. Chain: ci_f104_gator_rigid.npz (93,551 rows), then subset G_f104_gator_rigid.npz, then the G_rigid ensemble (e5/deploy/G). | 6 | 2.0 GB |
487
+ | `gator_f104_soil_collection_runs` | m4b | The Gator driving the 15,235 HMMWV f104 soil route ids (tiers 0-12: 9,168 designed routes and 6,067 planner proposals), 141.1 simulated hours. These are the source of ci_f104_gator_crm.npz (tiers 0-12, 55,826 rows), which feeds the G_full_soil ensemble. They are also the source of the stage-1 file (tiers 0-6, 8,399 runs, 30,827 rows), which feeds the G_soil ensemble. | 6 | 2.3 GB |
488
+ | `polaris_collection_build_record` | m4b | The Polaris stage-2 build record (15,235 candidates, 6 rejected, 15,229 selected) and the validated id list passed to the subset builder. | 2 | 552 kB |
489
+ | `polaris_collection_task_file` | m4b | soil_v5_polaris.json: the task file passed as --tasks-crm to the Polaris stage-2 build. Its tier 0-12 rows are the 15,235 collection ids. | 1 | 15.9 MB |
490
+ | `polaris_f104_soil_collection_runs` | m4b | The Polaris (stock driveline) driving the same 15,235 f104 soil ids: 15,229 valid, 93.0 simulated hours. Chain: stage-2 ci_f104_polaris_crm.npz (tiers 0-12, 57,228 rows), then polaris_full_f104_soil.npz, then the polaris_full_soil ensemble. The 144 sample-A rows of the smoke arm 'polaris' are part of this collection. | 5 | 1.7 GB |
491
+
492
+ #### Assets
493
+
494
+ | Item | Milestone | What it is | Files | Size |
495
+ |---|---|---|---|---|
496
+ | `arena_heightmaps` | m1, m2, m3, m4a, m4b | Heightmap and metadata of every arena driven in a milestone: f104 and 17 generated arenas, plus the arena family description. | 37 | 4.8 MB |
497
+ | `crm_soil_config_and_vehicle_variants` | m2, m3, m4a, m4b | The single deformable-soil setting (crm_main.json), the M113 smoke-test soil setting (crm_m113.json) and the Polaris and M113 vehicle definition variants. | 14 | 42.0 kB |
498
+ | `f104_terrain_grid` | m3 | Metric terrain grid of f104 used for the terrain crops of the vehicle-dynamics model and the tracker training environment. | 1 | 3.3 MB |
499
+
500
+ <!-- END fill_card.py: items -->
501
+
502
+ ### What one drive folder contains
503
+
504
+ Raw collections and evaluation drives share one folder layout: one folder per drive, named by its route id, with a
505
+ suffix for drive variants (`__b3` drives with perturbed held controls, `__a4__cN` on rigid ground and `__cN` on soil for
506
+ continuations branching from a moving state, `__harvest` drives by the first learned tracker). Raw collections release only the files the dataset builders
507
+ read:
508
+
509
+ | File | Present in | Contents |
510
+ |---|---|---|
511
+ | `trajectory.npz` | every drive | the drive, one row per 50 ms interval (below) |
512
+ | `command_reference.npz` | every drive | the route the follower was given and the speed it was asked for (below) |
513
+ | `anchor_state.npz` | every drive | the vehicle at the start of recording, with a short history array (below) |
514
+ | `outcome.json` | every drive | how the drive ended: `status` (for example `goal_reached`, `timeout`, `rollover`, `prolonged_blockage_terminated`, `soil_breakthrough_terminated`), `goal_reached`, `elapsed_s`, goal distances and progress (m), path length (m), positive engine work (kJ), frame count, the follower's settings; on soil a `crm` block (particle counts, sinkage and slip summaries); for the Gator and Polaris a `vehicle` block |
515
+ | `case.json` | every drive | the start/goal task: `id`, `arena` (the arena's asset path), start pose (in `layout`), `goal_xy`, `goal_radius_m`, `horizon_s`, the route parameters of its group (sideways offsets, speeds, speed profiles), and the train/val/test `split` of its group |
516
+ | `episode_complete.json` | every drive | completion marker: elapsed time and the SHA256 of every file the collector wrote, including files not released |
517
+ | `initial_state_validation.json` | when recorded | check of the settled start: horizontal speed, roll, pitch, heading and position error against their limits |
518
+ | `crm_extra.npz` | soil drives | per 50 ms: chassis height `pos_z_m` and heightmap ground under it `bmp_ground_z_m` (m), chassis quaternion `quat` (e0..e3), wheel-centre heights `spindle_z_m` (m), `slip_ratio` and longitudinal soil force `fsi_force_wheel_fx_n` (N) per wheel (`wheel_order` fl, fr, rl, rr), and `tire_radius_m` |
519
+ | `collection_request.json` | soil drives | the collector's inputs: case and route paths with their SHA256, soil settings, seed, stop rules, and the vehicle setup for the Gator and Polaris |
520
+ | `vehicle_extra.npz` | Gator and Polaris | per 50 ms (`frame`): `belly_clearance_min_m`, the lowest of the points sampled on the chassis underside minus the undisturbed ground below it (m, negative = inside the soil or ground), `belly_points_below_surface`, `belly_argmin_point`, chassis vertical speed `chassis_vz_mps`; and those points in the chassis frame, `belly_points_chassis_m` |
521
+ | `native_height_check.json` | Gator rigid drives | Chrono's terrain height against the heightmap at 50 points (m) |
522
+ | `branch_route.json`, `branch_reference.json` | branch continuations | the continuation route from the moving state (waypoints, speeds, stations, headings) |
523
+ | `branch_auto.json`, `skipped.json` | rigid branch anchor records | the automatic branch choice at each anchor state, or why the anchor was skipped |
524
+
525
+ Evaluation drive folders are released with every recorded file except logs, and hold at least `trajectory.npz`, `outcome.json` and
526
+ `episode_complete.json`, usually `case.json`; navigation missions instead hold `decisions.json`, `routes.json` and
527
+ `trajectory.npz`.
528
+
529
+ `outcome.json` also has a `safe_goal_reached` flag. It is the collector's own flag (no obstacle contact, no 2 s
530
+ effortful stop, no rollover), not the study's label. The study's label counts rolling back on a climb and is
531
+ recomputed from `trajectory.npz`: see the outcome codes in
532
+ [`traversing/results/README.md`](https://github.com/uwsbel/NeDM/blob/main/traversing/results/README.md).
533
+
534
+ **`trajectory.npz`.** `T` rows, one per 50 ms interval; row `i` is measured at the start of interval `i` and the
535
+ action is the one applied over it.
536
+
537
+ | Key | Shape, type | Contents |
538
+ |---|---|---|
539
+ | `state` | (T, 17) float32 | the 17-number vehicle state below |
540
+ | `action` | (T, 3) float32 | applied steering in [-1, 1], throttle in [0, 1], braking in [0, 1] |
541
+ | `pose` | (T, 3) float64 | world x (m), y (m), yaw (rad) |
542
+ | `power_kw` | (T,) float64 | engine output torque times transmission shaft speed (kW) |
543
+ | `positive_work_kj_per_interval` | (T,) float64 | positive engine work in the interval (kJ) |
544
+ | `contact_n` | (T,) float64 | largest contact force with placed obstacles (N); the arenas have none, so it is 0 |
545
+ | `parked` | (T,) bool | the vehicle is at the end of the route and asked to stop |
546
+ | `terminal_state`, `terminal_pose`, `terminal_parked` | (17,), (3,), () | the same quantities after the last interval |
547
+ | `state_fields` | (17,) str | the names of the state columns |
548
+ | `dt_s` | () float32 | 0.05 |
549
+
550
+ The 17-number state, in this order (`STATE_FIELDS` in `src/nedm/traverse/fdm_data.py`, the preset
551
+ `tire_normal_force_omega_pt` of `src/nedm/training/constants.py`, at the experiment commit
552
+ [`901d6c9`](https://github.com/uwsbel/NeDM/blob/901d6c9423a16c0fafc3d60056065415d5a725f2/src/nedm/training/constants.py)):
553
+
554
+ | # | Field | Unit |
555
+ |---|---|---|
556
+ | 0-1 | `vel_body_x_mps`, `vel_body_y_mps`: chassis velocity in the body frame (x forward) | m/s |
557
+ | 2-3 | `roll_rad`, `pitch_rad` | rad |
558
+ | 4-6 | `roll_rate_radps`, `ang_vel_body_y_radps` (pitch rate), `yaw_rate_radps` | rad/s |
559
+ | 7-10 | `tire_{fl,fr,rl,rr}_force_wheel_fz_n`: normal force on each wheel | N |
560
+ | 11-14 | `tire_{fl,fr,rl,rr}_spindle_omega_radps`: wheel spin rate | rad/s |
561
+ | 15 | `engine_motor_speed_radps` | rad/s |
562
+ | 16 | `engine_motorshaft_torque_nm` | N m |
563
+
564
+ **`command_reference.npz`.** `interval_start_s` and `desired_speed_mps` (T,): the time of each interval (s) and the
565
+ speed the follower was asked for (m/s). `reference_waypoints` (N, 2, m), `reference_stations` (N, m along the route),
566
+ `reference_speeds` (N, m/s) and `reference_headings` (N, rad): the route. Rigid branch continuations add `branch_frame` and
567
+ `branch_waypoints`, `branch_stations`, `branch_speeds`, `branch_headings`.
568
+
569
+ **`anchor_state.npz`.** `state` (17,) and `pose` (3,) at the start of recording, `goal_xy` (2, m), `goal_radius_m`,
570
+ and `history` (16, 24): 16 steps of 50 ms (0.8 s), each with the 17 state numbers, the 3 previously applied
571
+ controls, the position relative to the current pose in its heading frame (x, y in m) and the sine and cosine of the
572
+ relative heading (`HISTORY_FIELDS` in `src/nedm/traverse/fdm_data.py`). At a standing start the history repeats the
573
+ first state with a braking command.
574
+
575
+ ### `episodes.csv.gz`
576
+
577
+ One row per drive of a raw collection, next to its tar shards at `traversing/raw/<item>/episodes.csv.gz`:
578
+
579
+ | Column | Meaning |
580
+ |---|---|
581
+ | `run_id` | drive folder name |
582
+ | `collection` | the collection folder: the folder holding the drive's `runs/` folder, else the drive's parent folder |
583
+ | `vehicle`, `world` | `hmmwv`, `gator` or `polaris`; `rigid` or `soil` (from `outcome.json`, else the item's defaults) |
584
+ | `arena` | the arena asset path from `case.json`, for example `assets/traverse/arena_f104_50h_v1`; the item `arena_heightmaps` restores that folder (heightmap `arena_000.bmp` and `arena_meta.json`) |
585
+ | `status`, `elapsed_s` | end status and recorded time (s) from `outcome.json` |
586
+ | `n_files`, `bytes` | released files of the drive and their total size |
587
+ | `trajectory_sha256`, `outcome_sha256` | SHA256 of the drive's `trajectory.npz` and `outcome.json` |
588
+ | `shard` | the tar shard holding the drive |
589
+
590
+ These tables have no `load_dataset` configs of their own: the `datasets` library reads every config of a repository
591
+ with one file format, here the paper's Parquet. Load a table with the CSV reader and its Hub path instead:
592
+
593
+ ```python
594
+ from datasets import load_dataset
595
+ eps = load_dataset("csv", split="train", data_files="hf://datasets/harryzhang1018/NeDM@6620faead5225ac9aa5ae8ab19bc2ef2db38a863/"
596
+ "traversing/raw/hmmwv_soil_f104_collection/episodes.csv.gz")
597
+ ```
598
+
599
+ ### Download and restore
600
+
601
+ The helper in the code repository downloads items at the pinned revision, checks every file against the manifest's
602
+ SHA256, and restores each item to its path in a checkout (for example `artifacts/traverse/crm_f104_v1/collect_v1/runs/`
603
+ for the HMMWV soil collection), which is where the study's scripts expect it. It needs `huggingface_hub`:
604
+
605
+ ```bash
606
+ python traversing/scripts/release/download_traversing_data.py --list --all # items, sizes, restore paths
607
+ python traversing/scripts/release/download_traversing_data.py --milestone m2 --bundle models
608
+ python traversing/scripts/release/download_traversing_data.py --items hmmwv_soil_f104_collection --verify-members
609
+ python traversing/scripts/release/verify_release.py --local artifacts/hf_release/download # re-check downloaded files
610
+ ```
611
+
612
+ The default revision is `6620faead5225ac9aa5ae8ab19bc2ef2db38a863`, the Hub commit pinned in
613
+ `traversing/manifests/hf_release_manifest.json`; `--revision` selects another one (with a warning). Items named in an
614
+ item's `requires` are added to the selection. Existing files with other content are kept unless `--overwrite` is
615
+ given. Without the helper, fetch a folder with
616
+ `huggingface_hub.snapshot_download("harryzhang1018/NeDM", repo_type="dataset", revision="6620faead5225ac9aa5ae8ab19bc2ef2db38a863", allow_patterns="traversing/models/m2_shared_history_model/*")`
617
+ and extract tar shards with `tar -xzf part-00000.tar.gz` at the root of a checkout.
618
+
619
+ ### Loading notes
620
+
621
+ - **`.npz` files** contain object arrays in places: load them with `numpy.load(path, allow_pickle=True)`.
622
+ - **Models** are PyTorch checkpoints: a dict holding a state dict (under `state` for the risk networks, `model` for the
623
+ NRD, `model_state_dict` for the PPO checkpoint) plus the architecture settings. Load with
624
+ `torch.load(path, map_location="cpu", weights_only=True)`, allowing the NumPy arrays and paths some of them store
625
+ (`load_checkpoint` in `traversing/scripts/release/verify_release.py` shows how). The JSON next to each ensemble is
626
+ its training record. The network classes are in the experiment code at commit
627
+ [`901d6c9`](https://github.com/uwsbel/NeDM/tree/901d6c9423a16c0fafc3d60056065415d5a725f2) and are not on main yet.
628
+ - **The tracker actor** (`m3_tracker_round2_numpy_actor/actor.npz`) is plain NumPy: observation normalisation
629
+ (`obs_mean`, `obs_var`, `obs_eps`), the layer weights `W0..W3`, `b0..b3` of a 158 -> 512 -> 256 -> 128 -> 3
630
+ network, and the action scaling (`action_center`, `action_scale`, `action_low`, `action_high`). It runs without
631
+ torch.
632
+ - **Units** are in the key names (`_m`, `_mps`, `_rad`, `_radps`, `_n`, `_nm`, `_kw`, `_kj`, `_s`).
633
+
634
+ ### Known limitations
635
+
636
+ - **Simulation only.** Every drive is a Chrono simulation; there is no real-vehicle data.
637
+ - **Whole-arena overhead camera.** Every planner map comes from a fixed overhead camera that sees the whole arena,
638
+ with ideal depth, and the planners use the simulator's exact vehicle pose.
639
+ - **One soil setting and one terrain generator.** All soil drives use the same 0.24 m particle layer, and only the
640
+ wheels touch the soil: the HMMWV's rigid tyre mesh, and plain cylinders for the Gator and Polaris calibrated to the
641
+ HMMWV's sinkage. All arenas come from one hill-and-crater generator.
642
+ - **The Polaris's engine values are not physical.** Chrono's stock Polaris driveline gives the wheels about 16 times
643
+ the engine's power, so in Polaris drives the engine speed and torque (state numbers 15 and 16), `power_kw` and the
644
+ work values do not describe a real engine.
645
+ - **Vehicle-specific models.** Each risk model was trained on one vehicle's drives and is meant for that vehicle; the
646
+ labels describe drives by Chrono's stock PID follower. The predicted failure probabilities rank routes but are not
647
+ calibrated.
648
+ - **Re-drives are not always bit-identical.** Chrono runs on the cluster repeat exactly on one node but not across
649
+ nodes. Re-driving the PID follower on soil reproduced 369 of 423 trajectories exactly and 419 of 423 end states.
650
+
651
+ ### License and citation
652
+
653
+ BSD-3-Clause, the same as Part A and the code. The traversing study has no publication yet: please cite the NeDM paper
654
+ (Part A) and name the dataset revision you used (`6620faead5225ac9aa5ae8ab19bc2ef2db38a863`).
655
+
656
+ ## Part C: contact NRD
657
+
658
+ ### What it is
659
+
660
+ Follow-on work to the paper, not part of it. A neural reduced dynamics model (NRD) for systems whose contacts start
661
+ and stop: a bouncing ball, two pool balls, an SO101 arm that pushes a T-shaped block, and a Unitree G1 humanoid that a
662
+ frozen walking policy (HOMIE) drives. A core network, a collision network and a contact network predict each 20 ms
663
+ step, with one design for all four cases; the first three cases share one training config, and G1 has its own. The
664
+ design, the results and the commands are in
665
+ [`contact_nrd/` of the code repository](https://github.com/uwsbel/NeDM/tree/main/contact_nrd). The training files,
666
+ the SO101 and G1 test files and the models are byte-exact copies of the study's files. The ball and pool test files are
667
+ new conversions of the study's raw test recordings, made with the same converter as the training files. The ball, pool
668
+ and SO101 data come from [Project Chrono](https://projectchrono.org) simulations, the G1 data from MuJoCo 3.15.0.
669
+
670
+ ### Layout
671
+
672
+ | Path | Contents |
673
+ |---|---|
674
+ | `contact_nrd/<case>/train/` | `system.json` and `unified_data.npz`: training (split 0) and validation (split 1) episodes, plus the source campaign's own test episodes (split 2, not used) |
675
+ | `contact_nrd/<case>/test/` | The same two files for test episodes (split 2) from a separate collection with a new seed. No test episode was used for training or checkpoint selection |
676
+ | `contact_nrd/<case>/models/seed61.pt`, `seed62.pt` | The trained models (PyTorch checkpoints) |
677
+ | `contact_nrd/g1_locomotion/{train,test}/manifest.json` | G1 only: the collection record (settings, seeds, package versions, model-file hashes) |
678
+ | `contact_nrd/g1_locomotion/models/seed61_training/`, `seed62_training/` | G1 only: the training record of each model (`run_config.json` with the SHA-256 of the code and the data, `complete.json`, `train_log.jsonl`, `validation.json`) |
679
+ | `contact_nrd/g1_locomotion/results/` | G1 only: the test output of both models (`sealed_test_seed61_seed62.json`, `.out`) |
680
+ | `contact_nrd/release_manifest.json` | Size and SHA-256 of every file; source folders, campaigns, seeds and episode counts |
681
+
682
+ `<case>` is `bouncing_ball` (5,400 / 900 training / validation episodes, 1,800 test), `pool` (19,200 / 2,400,
683
+ 4,800 test), `so101_push_t` (51,200 / 6,400, 1,000 test) or `g1_locomotion` (30,685 / 3,413, 3,608 test). The first
684
+ three cases total 9.8 GB, G1 21.4 GB.
685
+
686
+ ### What the files contain
687
+
688
+ - `system.json`: the bodies (kind, size, fixed planes or table), the contact pairs, the record step, the target
689
+ body and time; for the arm and the T, the channel names and types.
690
+ - `unified_data.npz` (uncompressed NumPy): `contacts` [N, T-1, P] (pair p touches during record interval k),
691
+ `lengths` [N], `splits` [N], and the states. Ball and pool: `states` [N, T, D, 9] = position, velocity, angular
692
+ velocity of each ball. SO101 push-T: `arm` [N, T, 10] (joint angles, joint speeds), `tshape` [N, T, 13]
693
+ (position, quaternion wxyz, velocity, angular velocity) and `action` [N, T, 5] (joint position command). Other
694
+ arrays (`launches`; for the SO101 `contacts_link`, `t_table`, `scenario`) give more detail on each shot or push;
695
+ the models do not use them. Units are SI. Ball and pool records are 1 ms apart, the SO101 records 10 ms. In the
696
+ ball and pool `system.json`, `model_step_s` is 0.01 s; the released models use 0.02 s (from the training config).
697
+ - G1 `unified_data.npz`: `robot` [N, T, 67] (pelvis position, quaternion wxyz, 27 joint angles, pelvis velocity,
698
+ pelvis angular velocity, 27 joint rates), `action` [N, T, 27] (joint position targets), `contacts` [N, T-1, 2]
699
+ (left foot and right foot on the ground), `family` [N] (index into the `families` of `system.json`), `episode_id`,
700
+ `lengths`, `splits`. Other arrays (per record: `command`, `policy_output`, `contact_force`, `contact_steps`,
701
+ `torque`, `limit_steps`, `limit_joints`; per episode: `seed`, `group_id`, `terminal_reason` and the settings of the
702
+ difficult and probe families) give more detail; the models do not use them. Records are 10 ms apart. The G1
703
+ `system.json` also gives the families and the `evaluation` block of checkpoint selection. The G1 data come from
704
+ running the HOMIE walking policy (OpenHomie, commit `33071f79`) in MuJoCo. HOMIE itself is not in this dataset: it is
705
+ fetched from its pinned upstream commit, under its own license.
706
+
707
+ ### Download and use
708
+
709
+ ```bash
710
+ PYTHONPATH=src python -m nedm.contact_nrd.download --case pool # in the code repository; checks every SHA-256
711
+ PYTHONPATH=src python -m nedm.contact_nrd.download --case g1_locomotion --part models results # G1 without the data
712
+ ```
713
+
714
+ The code repository's `contact_nrd/release_manifest.json` pins the Hub revision (the G1 case has its own revision in
715
+ `case_revisions`). The files cannot be loaded with `datasets.load_dataset`; read them with NumPy or with
716
+ `nedm.contact_nrd.data.load_data`.
717
+
718
+ ### Known limitations
719
+
720
+ - **Simulation only.** There is no real-robot or real-table data.
721
+ - **One scene per case.** One ball, wall and floor; one pool table with fixed ball start positions; one arm, T and
722
+ table; one G1 robot with one walking policy on a flat floor. The test episodes are new shots, pushes and walks from
723
+ the same ranges as the training data.
724
+ - **Open-loop scores.** The published errors are model rollouts against recorded episodes, with the recorded arm
725
+ commands (G1: rollouts from recorded 4-state histories with the recorded joint targets).
726
+ - **Test sets seen during design.** The study also scored earlier design versions on these test episodes.
727
+
728
+ ### License and citation
729
+
730
+ BSD-3-Clause, the same as Part A and the code. The contact NRD has no publication yet: please cite the NeDM paper
731
+ (Part A) and name the dataset revision you used (`d68fa3c4d91539bc6a079f4b2f3ff5c27d825101`; the G1 case:
732
+ `cba82611210e401dc0155cb78fcf456a385ecef4`).
733
+
734
+ ## Part D: G1 footstep policy
735
+
736
+ ### What it is
737
+
738
+ Follow-on work to the paper, not part of it. A footstep policy for the Unitree G1 humanoid. Every 20 ms it sets the
739
+ velocity command (forward speed, sideways speed, turn rate) of a frozen walking policy (HOMIE), so that the feet land
740
+ on given footprints, on a flat floor and on planks with gaps. PPO trained it only inside the G1 contact NRD of Part C
741
+ (`contact_nrd/g1_locomotion/models/seed61.pt`, `seed62.pt`); MuJoCo 3.15.0 checked it on new courses. The training,
742
+ the results and the commands are in
743
+ [`g1_footstep_rl/` of the code repository](https://github.com/uwsbel/NeDM/tree/main/g1_footstep_rl). The policies,
744
+ their run files and the RL inputs are byte-exact copies of the study's files.
745
+
746
+ ### Layout
747
+
748
+ | Path | Contents |
749
+ |---|---|
750
+ | `g1_footstep_rl/policy/fs_cmd_s1/`, `fs_cmd_s2/` | Two PPO policies (`policy.pt`) and their run files: configs, curriculum, input hashes, stage ends, validation history, learning curve |
751
+ | `g1_footstep_rl/rl_inputs/start_bank/` | 200,000 start states from the G1 training data (`bank_v1.npz`), its summary and the joint ranges of the training data |
752
+ | `g1_footstep_rl/rl_inputs/courses/` | 200,000 training and 1,280 validation footstep courses, and their report |
753
+ | `g1_footstep_rl/results/dev/` | MuJoCo evaluations on the development courses (5 course types, 64 courses each): both policies, with the same episodes also inside the NRD, and the baseline H-FS (HOMIE with a hand-written footstep controller); the NRD-against-MuJoCo summary; package versions |
754
+ | `g1_footstep_rl/results/hfs_tuning/` | The parameter search of the baseline |
755
+ | `g1_footstep_rl/videos/` | Three side-by-side MuJoCo videos (policy above, baseline below) and their record (command, policy SHA-256, outcomes) |
756
+ | `g1_footstep_rl/release_manifest.json` | Size and SHA-256 of every file; provenance |
757
+
758
+ Total 975 MB.
759
+
760
+ ### What the files contain
761
+
762
+ - `policy.pt`: an RSL-RL 2.2.4 checkpoint (`model_state_dict`: actor and critic MLPs 512-256-128 on 163 inputs, 3
763
+ outputs, and the action std). The run files next to it give the environment and PPO settings.
764
+ - `course_bank_v4_{train,val}.npz` (float32, course frame): `targets` [M, 40, 5] (x, y, yaw, foot side, stop flag),
765
+ `centre` [M, 40, 3] (course line), `n` (footprints in use), `level`, `seed`, plank `intervals` [M, 16, 2] and
766
+ `half_width`, the stop and cliff flags.
767
+ - `bank_v1.npz`: `hist` [N, 4, 67] (the NRD's state history), `teacher_history` [N, 6, 76] (HOMIE's input history),
768
+ `family`, `kind` (stand, walk, turn, ...) and the source episode and step of each start.
769
+ - Each evaluation folder: `rows.json` (one row per course: outcome, completion, falls, drift), `steps.json` (one row
770
+ per footprint: error, along and across), `summary.json` and `SUMMARY.md` (cell rates with 95 % intervals, paired
771
+ McNemar tests against the baseline); the policy folders also `nrd_rows.json`, `nrd_steps.json` (the same courses
772
+ inside the NRD) and `snapshots.npz` (the MuJoCo states that start them).
773
+
774
+ ### Download and use
775
+
776
+ ```bash
777
+ scripts/g1_footstep_rl/reproduce.sh full --steps download --with-results # in the code repository; checks every SHA-256
778
+ ```
779
+
780
+ The code repository's `g1_footstep_rl/release_manifest.json` pins the Hub revision. `reproduce.sh` also trains the
781
+ policies again and runs the MuJoCo evaluation. HOMIE is not in this dataset: the code repository fetches it from its
782
+ pinned upstream commit (OpenHomie, commit `33071f79`), which has its own license.
783
+
784
+ ### Known limitations
785
+
786
+ - **Simulation only.** There is no real-robot data.
787
+ - **One robot and one walking policy.** Flat floor and flat plank tops at the floor height, straight plank courses,
788
+ standing starts.
789
+ - **Development results only.** The results are on development courses, which also guided choices during the study.
790
+ The study's final-test courses were not run.
791
+ - **Machine-dependent episodes.** MuJoCo episodes repeat bitwise only with the same CPU type and package versions
792
+ (`results/dev/environment.json`).
793
+
794
+ ### License and citation
795
+
796
+ BSD-3-Clause, the same as Part A and the code. HOMIE is not hosted here; it is fetched from its pinned upstream commit,
797
+ under its own license. The G1 footstep policy has no publication yet: please cite the NeDM paper (Part A) and name the
798
+ dataset revision you used (`cba82611210e401dc0155cb78fcf456a385ecef4`).
799
+
800
+ ## Part E: SO101 pick and place
801
+
802
+ ### What it is
803
+
804
+ Follow-on work to the paper, not part of it. A camera policy (the "student") for a real SO101 arm picks a 30 mm cube
805
+ and places it on a plate. Every training step ran inside a contact NRD of the arm and the cube (the design of Part C,
806
+ trained on CPU MuJoCo 3.15.0 episodes): a state teacher trained with PPO in the NRD, then the student trained in the
807
+ NRD with ray-traced images of a calibrated copy of the real scene (online DAgger). No real image was a training
808
+ sample. On the real arm the student placed the cube in 36 of 50 stress-test episodes (72 %; 95 % interval 58–83 %).
809
+ The training, the results and the commands are in
810
+ [`so101_pick_place/` of the code repository](https://github.com/uwsbel/NeDM/tree/main/so101_pick_place).
811
+
812
+ ### Layout
813
+
814
+ | Path | Contents |
815
+ |---|---|
816
+ | `so101_pick_place/nrd/c1_s62/`, `nrd/c0_s62/` | The policy NRD (every teacher and student stage ran in it) and its base: `best.pt` loads with `nedm.contact_nrd.model.load_model`; `original/best.pt` is the file as trained (two training-only heads more); the training records |
817
+ | `so101_pick_place/nrd_data/` | The 4 NRD training data parts (93,494 episodes; `unified_data.npz`, `system.json`, `manifest.json`), and the 7 PPO policies behind `policy_v3` |
818
+ | `so101_pick_place/nrd_test/` | The sealed scripted test set (3,050 episodes) |
819
+ | `so101_pick_place/teacher/`, `student/` | Every teacher (T0-T6) and student (S0-S5) checkpoint of the chain with its run record; the teacher's expert data |
820
+ | `so101_pick_place/rl_inputs/` | Task sets, start banks, geometry, the task sets of the sim checks |
821
+ | `so101_pick_place/results/` | The sealed NRD test, the sim-check results and selection rules, the per-episode robot results |
822
+ | `so101_pick_place/robot/` | Raw logs of 19 robot sessions (102 policy episodes), 52 videos of the student's input images, 2 LeRobot teleop recordings |
823
+ | `so101_pick_place/bundle/` | The folder installed on the robot computer, and its tarball |
824
+ | `so101_pick_place/scene_calib/`, `provenance/` | Camera calibration, scene and servo fit (also in the code repository); code snapshots that are in no commit |
825
+ | `so101_pick_place/release_manifest.json` | Size and SHA-256 of every file; provenance (commits, runs, sources) |
826
+
827
+ Total 13.3 GB (NRD data 10.6 GB).
828
+
829
+ ### What the files contain
830
+
831
+ - NRD data (`unified_data.npz`, uncompressed): `arm` [N, 601, 12] (6 joint angles, 6 joint rates), `cube` [N, 601,
832
+ 13] (position, quaternion wxyz, velocity, angular velocity), `action` [N, 601, 6] (joint position targets),
833
+ `contacts` [N, 600, 3] (fixed jaw - cube, moving jaw - cube, cube - table), `lengths`, `splits` (0 train,
834
+ 1 validation, 2 test), `family`, `phase`, contact force, impulse and depth, ids, seeds and outcome fields. Records
835
+ are 10 ms apart, episodes 4 s.
836
+ - Checkpoints: PyTorch files. Teachers: MLP state policies with privileged inputs. Students: two ResNet18 image
837
+ encoders (external camera crop and wrist camera, 224 x 224 RGB), joint angles and rates, a chunk of 10 joint
838
+ targets as output.
839
+ - Robot logs: per session `session.json` (command line, typed outcome per episode) and `first_frames.npz`; per
840
+ episode `episode_live.json` (setup, guard, latency, outcome) and `episode_live.npz` (50 Hz joints and commands,
841
+ each policy query with its action chunk and the two input images at 112 px).
842
+
843
+ ### Download and use
844
+
845
+ ```bash
846
+ scripts/so101_pick_place/reproduce.sh full --steps download # in the code repository; checks every SHA-256
847
+ ```
848
+
849
+ The code repository's `so101_pick_place/release_manifest.json` pins the Hub revision; `--with-nrd-data` and
850
+ `--with-robot` add the large folders. The MuJoCo Menagerie SO101 model is not in this dataset: the code repository
851
+ fetches it at a pinned revision.
852
+
853
+ ### Known limitations
854
+
855
+ - **One robot, one lab, one cube and plate.** The outcome is typed by the operator; the stress protocol was not fixed
856
+ in advance, and the student was chosen with robot results.
857
+ - **The NRD test set has only scripted families** and is not fully blind (run once before on an older NRD design).
858
+ - **Lab content.** The robot logs hold lab background images, the robot computer's user path and the USB adapter
859
+ serial. The videos show the student's input images as logged on the robot (112 px; the student sees 224 px);
860
+ there is no full-resolution video.
861
+
862
+ ### License and citation
863
+
864
+ BSD-3-Clause, the same as Part A and the code. The MuJoCo Menagerie model is not hosted here. The SO101 pick and place
865
+ has no publication yet: please cite the NeDM paper (Part A) and name the dataset revision you used (the
866
+ `hf_revision` of `so101_pick_place/release_manifest.json` in the code repository).
so101_pick_place/code/requirements-so101-pick-place.txt ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Extra Python packages of the SO101 pick-and-place release (so101_pick_place/README.md). Not part of the paper's
2
+ # environment: requirements.txt and environment*.yml are unchanged, and this study does not use them.
3
+ #
4
+ # 1. Workstation: training, sim checks, bundle build, fake-robot replay (one GPU; scripts/so101_pick_place/reproduce.sh)
5
+ # install the torch / torchvision build for your GPU first (https://pytorch.org), then
6
+ # pip install -r requirements-so101-pick-place.txt
7
+ # Do not add requirements.txt: it pins torch 2.8.0 / torchvision 0.23.0, which this study never ran on. Tested:
8
+ # torch 2.12.0+cu130, torchvision 0.27.1+cu130, Python 3.12.15 (RTX 5090; local runs, smoke runs, the sealed
9
+ # NRD test), torch 2.10.0+rocm7.1, torchvision 0.25.0+rocm (AMD MI350X / MI300X; every training job).
10
+ # AMD GPUs: do NOT install warp-lang from PyPI (that wheel is CUDA only). The renderer ran on AMD's ROCm port of
11
+ # Warp 1.13.0, built from source (scripts/render/hpcfund/build_warp_rocm.sbatch on the branch
12
+ # so101-pick-place-study), with newton installed with --no-deps.
13
+ mujoco==3.15.0 # CPU MuJoCo: the NRD data collector, the scene, the evaluations and sim checks
14
+ scipy==1.18.1 # MuJoCo worlds (rotations), the collector
15
+ warp-lang==1.13.0 # ray-traced camera images of the student (with newton; pinned as a pair)
16
+ newton==1.2.0
17
+ trimesh==5.1.1 # mesh files of the renderer
18
+ huggingface_hub==1.33.0 # download.py (the Hub files)
19
+ pyarrow==26.0.0 # LeRobot recordings (replay), robot logs
20
+ pillow==12.3.0 # images
21
+ opencv-python-headless==4.13.0.92 # the replay of the LeRobot recordings (fake step) and the robot videos
22
+ imageio==2.38.1 # videos (optional)
23
+ imageio-ffmpeg==0.6.0
24
+ # numpy came with torch: 2.5.4 (RTX 5090), 2.4.3 / 2.5.4 (AMD). The robot videos (robot/render_videos.py) also need
25
+ # an ffmpeg with libx264 on the PATH.
26
+ #
27
+ # 2. Robot computer only (Jetson AGX Orin, conda env "lerobot"; README "Deploy"). The steps of section 1 need none of
28
+ # these except opencv; the bundle carries the kin points, so the robot computer needs no mujoco, warp or newton:
29
+ # pip install lerobot==0.6.1 opencv-python pyarrow (with the torch / torchvision of the Jetson)
30
+ # The study's notes record LeRobot 0.6.2 on the Orin: the version string of LeRobot's GitHub main branch after v0.6.1,
31
+ # not a PyPI release (PyPI's latest is 0.6.1, checked 2026-10-27), so the Orin had a source install of LeRobot
32
+ # whose commit was not recorded. PyPI lerobot 0.6.1 ran the replay and the fake robot on the workstation; it was
33
+ # not run on the real arm. A source install of LeRobot's main branch also reports 0.6.2, but its commit will differ.
so101_pick_place/code/scripts/so101_pick_place/check/check_analyze.py ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Release sim check, v12 (CHECK_SPEC.md section 3): per-episode and per-start metrics of check_eval.py runs.
2
+
3
+ python -B check_analyze.py TAG=runs/x.npz[:kind] ... --out out/analysis_<name>.json
4
+ kind: H (hold starts, tasks/h68.npz; rows % 68 = start, rows // 68 = draw) or J (jit224; the cube side of each row
5
+ from the task metadata, Addendum B6: the file changes side in blocks of 8, 112 rows cube left L->R, 112 cube right
6
+ R->L). The J task metrics (grasp / lift / place / near place / carry stop) are those of sim_eps.py (this folder;
7
+ the plane = the run's own plane). Ported from the study's ~/so101_r2s_claude/v12/check/lib/check_analyze.py: file
8
+ paths from this repository and its download folder; --h68 names the H68 metadata (was <check folder>/tasks/h68.json).
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import argparse
13
+ import json
14
+ import sys
15
+ from pathlib import Path
16
+
17
+ import numpy as np
18
+
19
+ HERE = Path(__file__).resolve().parent
20
+ DATA = HERE.parents[2] / "artifacts" / "so101_pick_place"
21
+ DT = 0.02
22
+ LOOSE, LOOSE6 = 10.0, 6.0
23
+ OPEN_CMD = 20.0
24
+ FAR_MM = 40.0
25
+ LIFT_MM = 25.0
26
+ WIN_S = 6.0
27
+ _K = {}
28
+
29
+
30
+ def kin():
31
+ if "k" not in _K:
32
+ import torch
33
+ from nedm.so101_policy.kin import SO101Kin
34
+ k = SO101Kin()
35
+ _K["k"] = lambda q: tuple(x.numpy() for x in k.fk(torch.as_tensor(q)))
36
+ return _K["k"]
37
+
38
+
39
+ def hold_start(jaw_deg, n=15):
40
+ ok = (jaw_deg >= 6) & (jaw_deg <= 13)
41
+ run = np.convolve(ok.astype(int), np.ones(n, int), "valid") >= n
42
+ h = np.flatnonzero(run)
43
+ return int(h[0]) if len(h) else None
44
+
45
+
46
+ def planned_jaw(chunk, k, n_dec, lo=0.0, hi=1.5):
47
+ dstep = np.arange(n_dec) * 5 - 1
48
+ m = (dstep >= k + lo / DT) & (dstep < k + hi / DT)
49
+ if not m.any():
50
+ return float("nan")
51
+ return float(np.degrees(chunk[:n_dec][m, :5, 5].mean(1)).mean())
52
+
53
+
54
+ def ep_metrics(q, cube, ex, chunk, n, goal_xy):
55
+ q, cube = q[:n].astype(np.float64), cube[:n].astype(np.float64)
56
+ cmd = np.degrees(ex[:, :, 5].reshape(-1)[:n].astype(np.float64))
57
+ jaw = np.degrees(q[:, 5])
58
+ P, R = kin()(q)
59
+ gz = P[:, 2] * 1e3
60
+ k = hold_start(jaw)
61
+ if k is None:
62
+ return dict(hold=False, grasp_release=False, release_robot=False)
63
+ up = np.flatnonzero(gz[k:] > gz[k] + LIFT_MM)
64
+ kl = k + int(up[0]) if len(up) else n
65
+ kw = min(kl, k + int(round(WIN_S / DT)), n)
66
+ dgoal = np.linalg.norm(cube[:, :2] - np.asarray(goal_xy)[None], axis=1) * 1e3
67
+ hit = np.flatnonzero((cmd[k:kw] > OPEN_CMD) & (dgoal[k:kw] > FAR_MM))
68
+ op_r = np.flatnonzero(cmd[k:kl] > OPEN_CMD)
69
+ nd = int(np.ceil(n / 5))
70
+ out = dict(hold=True, k=int(k), t_hold=round(k * DT, 2), lift=bool(len(up)),
71
+ t_lift=round(float(kl - k) * DT, 2) if len(up) else None,
72
+ plan=planned_jaw(chunk, k, nd), plan_0_1=planned_jaw(chunk, k, nd, 0.0, 1.0),
73
+ grasp_release=bool(len(hit)), t_grel=round(float(hit[0]) * DT, 2) if len(hit) else None,
74
+ release_robot=bool(len(op_r)), t_rel_robot=round(float(op_r[0]) * DT, 2) if len(op_r) else None,
75
+ cmd_max_win=float(cmd[k:kw].max()), jaw_max_win=float(jaw[k:kw].max()),
76
+ goal_mm_hold=float(dgoal[k]))
77
+ if len(hit):
78
+ t = k + int(hit[0])
79
+ j = min(t + 25, n - 1)
80
+ out["dropped"] = bool(np.linalg.norm(P[j] - cube[j, :3]) * 1e3 > 25.0)
81
+ s0, s1 = k + 5, min(k + 55, n)
82
+ if s1 > s0:
83
+ loc = np.einsum("nji,nj->ni", R[s0:s1], cube[s0:s1, :3] - P[s0:s1]) * 1e3 # R^T (c - p), mm
84
+ out["seat_mm"] = np.round(loc.mean(0), 2).tolist()
85
+ out["gp_above_cube_mm"] = round(float((P[s0:s1, 2] - cube[s0:s1, 2]).mean() * 1e3), 2)
86
+ out["closed"] = bool(np.median(np.linalg.norm(P[s0:s1] - cube[s0:s1, :3], axis=1)) * 1e3 < 25.0)
87
+ return out
88
+
89
+
90
+ def run_episodes(f):
91
+ z = np.load(f, allow_pickle=True)
92
+ sq, sc, ex, ch, L = z["state_q"], z["state_cube"], z["rec_exec"], z["rec_chunk"], z["steps"]
93
+ goal = z["goal_xy"]
94
+ rows = []
95
+ for i in range(sq.shape[0]):
96
+ n = int(min(L[i], sq.shape[1]))
97
+ r = ep_metrics(sq[i], sc[i], ex[i], ch[i], n, goal[i])
98
+ r.update(ep=i, end=int(z["end"][i]), steps=n, lenient=bool(z["lenient"][i]), seed=int(z["seeds"][i]))
99
+ rows.append(r)
100
+ info = json.loads(str(z["check"])) if "check" in z else {}
101
+ return rows, info
102
+
103
+
104
+ def per_start(rows, N):
105
+ out = []
106
+ for s in range(N):
107
+ rs = [r for r in rows if r["ep"] % N == s]
108
+ pl = [r["plan"] for r in rs if r["hold"] and np.isfinite(r["plan"])]
109
+ out.append(dict(row=s, draws=len(rs), holds=sum(r["hold"] for r in rs),
110
+ plan=float(np.median(pl)) if pl else None,
111
+ grasp_release=sum(r["grasp_release"] for r in rs),
112
+ release_robot=sum(r["release_robot"] for r in rs),
113
+ seat_mm=(np.round(np.median([r["seat_mm"] for r in rs if "seat_mm" in r], 0), 2).tolist()
114
+ if any("seat_mm" in r for r in rs) else None),
115
+ gp_above_cube_mm=(float(np.median([r["gp_above_cube_mm"] for r in rs if "gp_above_cube_mm" in r]))
116
+ if any("gp_above_cube_mm" in r for r in rs) else None)))
117
+ return out
118
+
119
+
120
+ def counts(starts, rows, sel=None):
121
+ st = [s for s in starts if sel is None or s["row"] in sel]
122
+ rs = [r for r in rows if sel is None or r["row"] in sel]
123
+ pl = np.array([s["plan"] for s in st if s["plan"] is not None])
124
+ gr_rows = sorted(int(s["row"]) for s in st if s["grasp_release"] > 0) # Addendum B3: distinct starts
125
+ return dict(starts=len(st), starts_hold=int(len(pl)), loose=int((pl > LOOSE).sum()), loose6=int((pl > LOOSE6).sum()),
126
+ starts_grasp_release=len(gr_rows), grasp_release_starts=gr_rows,
127
+ plan_mean=round(float(pl.mean()), 3) if len(pl) else None,
128
+ plan_p50=round(float(np.median(pl)), 3) if len(pl) else None,
129
+ episodes=len(rs), ep_hold=sum(r["hold"] for r in rs),
130
+ grasp_release=sum(r["grasp_release"] for r in rs), release_robot=sum(r["release_robot"] for r in rs),
131
+ ep_loose=sum(bool(r["hold"] and r["plan"] > LOOSE) for r in rs))
132
+
133
+
134
+ J224_TASKS = str(DATA / "rl_inputs/check_tasks/jit224.npz")
135
+ J224_META = str(DATA / "rl_inputs/check_tasks/all280.json") # = sim_eps.META
136
+
137
+
138
+ def j224_side_rows():
139
+ """Addendum B6: the rows of jit224 with the cube left (direction L->R) and right (R->L), from the task metadata
140
+ (row b -> the file's seed of row b -> its metadata entry). A re-seeded repeat keeps the file's row order."""
141
+ meta = json.loads(Path(J224_META).read_text())
142
+ by = {meta["seed0"] + m["row"]: m for m in meta["tasks"]}
143
+ seeds = np.load(J224_TASKS)["seeds"].astype(int)
144
+ d = [by[int(x)]["direction"] for x in seeds]
145
+ left = {b for b, x in enumerate(d) if x == "L->R"}
146
+ right = {b for b, x in enumerate(d) if x == "R->L"}
147
+ if len(left) + len(right) != len(seeds):
148
+ raise SystemExit("jit224: a row with no L->R / R->L direction")
149
+ return left, right
150
+
151
+
152
+ def j_task(f, plane, info):
153
+ """sim_eps.py task metrics per direction (rows 0-111 L->R, 112-223 R->L); seeds mapped back by row."""
154
+ from nedm.so101_policy import task as _T # noqa: F401 (this checkout's task module first)
155
+ sys.path.insert(0, str(HERE))
156
+ import sim_eps as SE
157
+ meta = json.loads(SE.META.read_text())
158
+ z = np.load(f, allow_pickle=True)
159
+ seeds = z["seeds"].astype(int)
160
+ rows_meta = [dict(m, seed=meta["seed0"] + m["row"]) for m in meta["tasks"]]
161
+ by = {m["seed"]: m for m in rows_meta}
162
+ t224 = np.load(J224_TASKS)["seeds"].astype(int)
163
+ if not set(seeds) <= set(by): # a re-seeded repeat: map row b -> the file's seed of row b
164
+ if len(seeds) != len(t224):
165
+ raise SystemExit(f"{f}: {len(seeds)} rows, not the 224 of jit224")
166
+ rows_meta = [dict(by[int(t224[b])], seed=int(seeds[b])) for b in range(len(seeds))]
167
+ eps = SE.episodes(f, plane, rows_meta)
168
+ out = {}
169
+ for d, kk in (("L->R", "lr"), ("R->L", "rl")):
170
+ rs = [x for x in eps if x["direction"] == d]
171
+ out[kk] = dict(n=len(rs), grasp=sum(x["grasp"] for x in rs), lift=sum(x["lift"] for x in rs),
172
+ place=sum(x["place"] for x in rs), near_place=sum(x["near_place"] for x in rs),
173
+ carry_stop=sum(x["carry_stop"] for x in rs), stall=sum(x["stall"] for x in rs),
174
+ far_stop=sum(any(s["to_goal_mm"] > 30.0 for s in x["stops"]) for x in rs))
175
+ out["all"] = {k: out["lr"][k] + out["rl"][k] for k in out["lr"]}
176
+ out["per_episode"] = [dict(ep=x["ep"], grasp=x["grasp"], place=x["place"], carry_stop=x["carry_stop"],
177
+ near_place=x["near_place"], end=x["end"]) for x in eps]
178
+ return out
179
+
180
+
181
+ def main():
182
+ p = argparse.ArgumentParser()
183
+ p.add_argument("runs", nargs="+", help="TAG=file.npz:H|J")
184
+ p.add_argument("--out", required=True)
185
+ p.add_argument("--h68", default=str(DATA / "rl_inputs/check_tasks/h68.json"), help="H68 start metadata")
186
+ a = p.parse_args()
187
+ out = json.loads(Path(a.out).read_text()) if Path(a.out).exists() else {}
188
+ h68 = json.loads(Path(a.h68).read_text())["holds"]
189
+ sets = {"H30": set(range(30)), "H38": set(range(30, len(h68)))}
190
+ for spec in a.runs:
191
+ tag, rest = spec.split("=", 1)
192
+ f, kind = rest.rsplit(":", 1)
193
+ rows, info = run_episodes(f)
194
+ r = dict(file=f, kind=kind, info=info)
195
+ if kind == "H":
196
+ N = len(h68)
197
+ for x in rows:
198
+ x["row"], x["draw"] = x["ep"] % N, x["ep"] // N
199
+ st = per_start(rows, N)
200
+ r["starts"] = st
201
+ r["counts"] = {"H68": counts(st, rows), **{k: counts(st, rows, v) for k, v in sets.items()}}
202
+ for side in ("L", "R"):
203
+ sel = {m["row"] for m in h68 if m["side"] == side}
204
+ r["counts"][f"H68_{side}"] = counts(st, rows, sel)
205
+ else:
206
+ N = len(rows)
207
+ for x in rows:
208
+ x["row"], x["draw"] = x["ep"], 0
209
+ st = per_start(rows, N)
210
+ if N != 224:
211
+ raise SystemExit(f"{f}: {N} rows, not the 224 of jit224")
212
+ jl, jr = j224_side_rows() # Addendum B6 (was rows 0-111 / 112-223: wrong)
213
+ r["counts"] = {"J224": counts(st, rows), "J_L": counts(st, rows, jl), "J_R": counts(st, rows, jr)}
214
+ plane = info.get("plane")
215
+ r["task"] = j_task(f, tuple(plane) if plane else None, info)
216
+ r["episodes"] = rows
217
+ out[tag] = r
218
+ c = r["counts"]
219
+ main_key = "H68" if kind == "H" else "J224"
220
+ cc = c[main_key]
221
+ extra = (f" | task L->R g {r['task']['lr']['grasp']} p {r['task']['lr']['place']} stop {r['task']['lr']['carry_stop']}"
222
+ f" R->L g {r['task']['rl']['grasp']} p {r['task']['rl']['place']} stop {r['task']['rl']['carry_stop']}"
223
+ if kind == "J" else "")
224
+ print(f"{tag:26s} {main_key}: holds {cc['starts_hold']}/{cc['starts']} starts, plan mean {cc['plan_mean']} p50 "
225
+ f"{cc['plan_p50']}, loose {cc['loose']} (>6: {cc['loose6']}), grasp releases {cc['grasp_release']}/"
226
+ f"{cc['episodes']} (robot rule {cc['release_robot']}){extra}", flush=True)
227
+ Path(a.out).write_text(json.dumps(out, default=float))
228
+
229
+
230
+ if __name__ == "__main__":
231
+ main()
so101_pick_place/code/scripts/so101_pick_place/check/check_eval.py ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Release sim check of a camera student (v12 check, frozen runner check_eval.py sha256 f70011ab, ported): one
2
+ closed-loop CPU MuJoCo evaluation through scripts/so101_policy/vision_viral.py eval, with the recording of the planned
3
+ chunk per decision, the goal plate 3.9 mm thick in the renders and the drop rule at the plate top (plane runs), the
4
+ parts override of the arm (RL = configs/so101_pick_place/parts_override_v2.json, the real-look gripper parts; GR = the
5
+ parts of the scene real_scene_v2.json; own = the student's pinned scene), tasks re-seeded (--seed-base: seed = base +
6
+ row + N j for draw j), the measured table plane (or --plane), the flat robot floor and NEDM_SO101_DYN from the
7
+ environment (run_gates.sh sets the fitted servo model configs/so101_pick_place/dyn_fit_d2q.json).
8
+
9
+ NEDM_SO101_DYN="$(cat configs/so101_pick_place/dyn_fit_d2q.json)" PYTHONPATH=src python -B \
10
+ scripts/so101_pick_place/check/check_eval.py eval --student tb10 --arm own \
11
+ --tasks artifacts/so101_pick_place/rl_inputs/check_tasks/jit224.npz --horizon 2000 --tag g2_a --out OUT.npz
12
+
13
+ Ported from the study's frozen runner (~/so101_r2s_claude/v12/check/lib/check_eval.py, sha256 f70011ab...): the
14
+ paths come from this repository (code, configs/so101_pick_place, artifacts/so101_pick_place) instead of the study's
15
+ folders; the "build68" command (it built rows 30-67 of h68.npz from robot logs with study-only scripts) is left out:
16
+ h68.npz is released (rl_inputs/check_tasks/). The eval arguments, the patches of vision_viral.py and the recorded
17
+ arrays are the frozen runner's (checked on one G2 smoke run: same arrays).
18
+ """
19
+ from __future__ import annotations
20
+
21
+ import argparse
22
+ import hashlib
23
+ import importlib.util
24
+ import json
25
+ import os
26
+ import subprocess
27
+ import time
28
+ from pathlib import Path
29
+
30
+ import numpy as np
31
+
32
+ CODE = Path(__file__).resolve().parents[3] # the repository root
33
+ WT = Path(os.environ.get("CHECK_WT", str(CODE))) # code under test: this checkout (scripts/, src/)
34
+ DATA = CODE / "artifacts" / "so101_pick_place" # the Hub folder after reproduce.sh --steps download
35
+ CONF = CODE / "configs" / "so101_pick_place"
36
+ WB = Path(os.environ.get("CHECK_WB", str(CONF)))
37
+ CALIB = Path(os.environ.get("CHECK_CALIB", str(CONF / "calib_v1.json")))
38
+ JT = Path(os.environ.get("CHECK_JT", str(DATA / "teacher/t4_jt_h110/model_00110.pt"))) # loaded, not used for acting
39
+ PLANE = (-0.00468, -0.03641, 0.01836)
40
+ PLATE = 0.0039031332928005
41
+ STUDENTS = {"D": DATA / "student/s4_v8_roll_s801/it_02000.pt", "tb10": DATA / "student/s5_v12_tb10_s1210/it_01000.pt"}
42
+ SCENE_DIRS = [CONF, WB] + [Path(p) for p in os.environ.get("CHECK_SCENE_DIRS", "").split(":") if p]
43
+ BASE = {"v2": Path(os.environ.get("CHECK_BASE_V2", str(CONF / "real_scene_v2.json")))}
44
+ BASE_SHA = {"v2": "4bce0b8dd6f22b5499b556275bca0bf248d1e96b1cd3babf169b34a8cb539d82"}
45
+ RL_PARTS = {"v2": WB / "parts_override_v2.json"}
46
+ RL_SHA = {"v2": "3840ca99745839ff693dca975f9853720176ab61b3b7d751a42995e0e5366217"}
47
+ REC = dict(on=False, delta=[], q=[], chunk=[], exec=[])
48
+
49
+
50
+ def log(s):
51
+ print(f"[{time.strftime('%H:%M:%S')}] check_eval: {s}", flush=True)
52
+
53
+
54
+ def sha(p):
55
+ return hashlib.sha256(Path(p).read_bytes()).hexdigest()
56
+
57
+
58
+ # ---- eval ----------------------------------------------------------------------------------------------------------
59
+ def find_scene(ck):
60
+ import torch
61
+ c = torch.load(ck, map_location="cpu", weights_only=False)["cfg"]
62
+ get = (lambda k: c.get(k, "")) if isinstance(c, dict) else (lambda k: getattr(c, k, ""))
63
+ want = get("scene_sha256")
64
+ own = Path(str(get("scene") or "")).expanduser()
65
+ if str(own) and own.is_file() and sha(own) == want: # the pinned path itself (AMD runs)
66
+ return own
67
+ for dd in SCENE_DIRS:
68
+ if not dd.is_dir():
69
+ continue
70
+ for p in sorted(dd.glob("*.json")):
71
+ try:
72
+ if sha(p) == want:
73
+ return p
74
+ except OSError:
75
+ continue
76
+ raise SystemExit(f"no scene file with sha256 {want[:12]} for {ck} in {[str(d) for d in SCENE_DIRS]}")
77
+
78
+
79
+ def family(scene):
80
+ names = [p.get("name", "") for p in json.loads(Path(scene).read_text())["geometry"].get("parts", [])]
81
+ if any(n.startswith("base_clamp") for n in names):
82
+ raise SystemExit(f"{scene}: a scene of the study's v4 family (not part of this release)")
83
+ return "v2"
84
+
85
+
86
+ def arm_parts(arm, fam):
87
+ if arm == "RL":
88
+ f = RL_PARTS[fam]
89
+ if sha(f) != RL_SHA[fam]:
90
+ raise SystemExit(f"{f}: sha256 {sha(f)[:12]} != the frozen {RL_SHA[fam][:12]}")
91
+ return json.loads(f.read_text()), str(f)
92
+ if arm == "GR":
93
+ f = BASE[fam]
94
+ if sha(f) != BASE_SHA[fam]:
95
+ raise SystemExit(f"{f}: sha256 {sha(f)[:12]} != the frozen {BASE_SHA[fam][:12]}")
96
+ return json.loads(f.read_text())["geometry"]["parts"], str(f)
97
+ raise SystemExit(f"arm {arm}")
98
+
99
+
100
+ def look_of(scene, fam, arm):
101
+ """The look a run renders (Addendum B2): 'grey' (the family's base scene parts), 'real' (the real-look parts of
102
+ arm RL) or 'other'. Arm 'own' = the parts of the student's pinned scene file, compared with both lists."""
103
+ if arm in ("RL", "GR"):
104
+ return "real" if arm == "RL" else "grey"
105
+ own = json.loads(Path(scene).read_text())["geometry"].get("parts", [])
106
+ if own == arm_parts("GR", fam)[0]:
107
+ return "grey"
108
+ if own == arm_parts("RL", fam)[0]:
109
+ return "real"
110
+ return "other"
111
+
112
+
113
+ def tile(t, n, base):
114
+ """The task set n times; seeds = base + row + N j (base 0: the file's own seeds, n must be 1)."""
115
+ N = len(t["seeds"])
116
+ if not base and n != 1:
117
+ raise SystemExit("--draws > 1 needs --seed-base")
118
+ out = {k: (np.concatenate([v] * n) if (np.ndim(v) and len(v) == N) else v) for k, v in t.items()}
119
+ if base:
120
+ out["seeds"] = np.concatenate([np.arange(N, dtype=np.int64) + base + j * N for j in range(n)])
121
+ return out
122
+
123
+
124
+ def cmd_eval(a):
125
+ import torch
126
+ torch.set_num_threads(a.threads)
127
+ from nedm.so101_policy.vision import viral as VI
128
+ if not str(VI.__file__).startswith(str(WT)):
129
+ raise SystemExit(f"nedm from {VI.__file__}, not {WT}")
130
+ plane = None if a.plane == "sim" else (PLANE if a.plane == "measured" else tuple(float(v) for v in a.plane.split(",")))
131
+ if a.plane_dz:
132
+ if plane is None:
133
+ raise SystemExit("--plane-dz needs a plane")
134
+ plane = (plane[0] + a.plane_dz, plane[1], plane[2])
135
+ orig_den = VI.denormalise
136
+
137
+ def denormalise(st, p):
138
+ out = orig_den(st, p)
139
+ if REC["on"]:
140
+ REC["delta"].append(out.detach().float())
141
+ return out
142
+ VI.denormalise = denormalise
143
+ orig_call = VI.Actor.__call__
144
+
145
+ def call(self, ws, goal_pose, k=None):
146
+ REC["delta"], REC["on"] = [], True
147
+ try:
148
+ ex = orig_call(self, ws, goal_pose, k)
149
+ finally:
150
+ REC["on"] = False
151
+ delta = torch.cat(REC["delta"])
152
+ q = ws.q.to(delta.device, torch.float32).nan_to_num()
153
+ if self.q_offset is not None:
154
+ q = q + torch.as_tensor(self.q_offset, dtype=q.dtype, device=q.device)
155
+ if delta.shape[0] != q.shape[0]:
156
+ raise RuntimeError(f"chunk record: {delta.shape[0]} deltas for {q.shape[0]} worlds")
157
+ REC["q"].append(q.cpu())
158
+ REC["chunk"].append((q[:, None, :] + delta).cpu())
159
+ REC["exec"].append(ex.float().cpu())
160
+ return ex
161
+ VI.Actor.__call__ = call
162
+ ck = Path(STUDENTS.get(a.student, a.student)).expanduser().resolve()
163
+ scene = find_scene(ck)
164
+ fam = family(scene)
165
+ parts, parts_src = arm_parts(a.arm, fam) if a.arm != "own" else (None, "own scene")
166
+ look = look_of(scene, fam, a.arm) # Addendum B2: recorded in the run's "check" info
167
+ info = {}
168
+ orig_make_views = VI.make_views
169
+
170
+ def make_views(cfg, num_worlds, **kw):
171
+ geo = dict(kw.get("geometry_over") or {})
172
+ if plane is not None:
173
+ if "table_plane" not in geo:
174
+ raise SystemExit("check_eval: the plate patch needs the table plane")
175
+ geo["plate_thickness"] = PLATE
176
+ if parts is not None:
177
+ geo["parts"] = parts
178
+ kw["geometry_over"] = geo or None
179
+ views = orig_make_views(cfg, num_worlds, **kw)
180
+ rs = views.real.real
181
+ got = [p.get("name") if isinstance(p, dict) else getattr(p, "name", None) for p in rs.parts]
182
+ if parts is not None and len(got) != len(parts):
183
+ raise SystemExit(f"check_eval: the parts override did not reach the renderer ({len(got)} vs {len(parts)})")
184
+ info.update(parts=got, table_plane=list(rs.table_plane) if rs.table_plane is not None else None,
185
+ plate_mm=float(rs.plate_thickness) * 1e3)
186
+ log(f"render: arm {a.arm} ({fam}, {parts_src}): {len(got)} parts, table plane {info['table_plane']}, plate "
187
+ f"{info['plate_mm']:.2f} mm")
188
+ return views
189
+ VI.make_views = make_views
190
+ spec = importlib.util.spec_from_file_location("vision_viral", str(WT / "scripts/so101_policy/vision_viral.py"))
191
+ VV = importlib.util.module_from_spec(spec)
192
+ spec.loader.exec_module(VV)
193
+ if plane is not None:
194
+ orig_get = VV.EnvCache.get
195
+
196
+ def get(self, world, B):
197
+ new = (world, B) not in self.c
198
+ env = orig_get(self, world, B)
199
+ if new:
200
+ if env.task.cfg is not env.tcfg:
201
+ raise SystemExit("check_eval: the task config is not the env's")
202
+ env.tcfg.release_z = float(env.tcfg.release_z) + PLATE
203
+ log(f"rules: release_z -> {env.tcfg.release_z * 1e3:.1f} mm above the physics table (plate top)")
204
+ return env
205
+ VV.EnvCache.get = get
206
+ orig_eval = VV.evaluate
207
+
208
+ def evaluate(*p, **kw):
209
+ r = orig_eval(*p, **kw)
210
+ r["rec_q"] = torch.stack(REC["q"], 1).numpy().astype(np.float32)
211
+ r["rec_chunk"] = torch.stack(REC["chunk"], 1).numpy().astype(np.float32)
212
+ r["rec_exec"] = torch.stack(REC["exec"], 1).numpy().astype(np.float32)
213
+ head = subprocess.run(["git", "-C", str(WT), "rev-parse", "HEAD"], capture_output=True, text=True).stdout.strip()
214
+ if not head and (WT / "SYNC_HEAD.txt").exists():
215
+ head = (WT / "SYNC_HEAD.txt").read_text().strip()
216
+ r["check"] = np.array(json.dumps(dict(
217
+ tag=a.tag, student=a.student, ckpt=str(ck), ckpt_sha256=sha(ck), scene=str(scene), scene_sha256=sha(scene),
218
+ family=fam, arm=a.arm, look=look, parts_src=parts_src, parts=info.get("parts"), tasks=str(a.tasks),
219
+ tasks_sha256=sha(a.tasks), draws=a.draws, seed_base=a.seed_base, n_base=n_base, plane=plane,
220
+ floor=a.floor, horizon=a.horizon, hold_cap_s=a.hold_cap_s, roll_hi_deg=a.roll_hi_deg,
221
+ dyn=os.environ.get("NEDM_SO101_DYN", "")[:40] and json.loads(os.environ["NEDM_SO101_DYN"]).get("note"),
222
+ wt=str(WT), wt_head=head, check_eval_sha256=sha(__file__))))
223
+ return r
224
+ VV.evaluate = evaluate
225
+ t = dict(np.load(a.tasks, allow_pickle=True))
226
+ n_base = len(t["seeds"])
227
+ t = tile(t, a.draws, a.seed_base)
228
+ out = Path(a.out)
229
+ out.parent.mkdir(parents=True, exist_ok=True)
230
+ tf = out.parent / f"_tasks_{a.tag}.npz"
231
+ np.savez(tf, **t)
232
+ nw = len(t["seeds"])
233
+ args = ["eval", "--student", str(ck), "--scene-path", str(scene), "--calib-path", str(CALIB),
234
+ "--render-worlds", str(nw), "--jt", str(JT), "--tasks", str(tf), "--world", "mujoco",
235
+ "--workers", str(a.workers), "--record-states", "--horizon", str(a.horizon), "--hold-cap-s", str(a.hold_cap_s),
236
+ "--qd-robot", "3", "--floor", a.floor, "--seed", "0", "--out", str(out)]
237
+ if plane is not None:
238
+ args.insert(-2, f"--table-plane={plane[0]},{plane[1]},{plane[2]}")
239
+ if a.roll_hi_deg is not None:
240
+ args += ["--roll-hi-deg", str(a.roll_hi_deg)]
241
+ args += [x for x in os.environ.get("CHECK_EVAL_EXTRA", "").split() if x] # AMD: --nrd-ckpt, --mj-python
242
+ log(f"eval {a.tag}: student {ck}, scene {scene} ({fam}), arm {a.arm} (look {look}), {nw} worlds ({a.draws} draws, seed base "
243
+ f"{a.seed_base}), plane {plane}, dyn {'on' if os.environ.get('NEDM_SO101_DYN') else 'OFF'}")
244
+ try:
245
+ VV.main(args)
246
+ finally:
247
+ tf.unlink(missing_ok=True)
248
+
249
+
250
+ def main():
251
+ p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
252
+ sub = p.add_subparsers(dest="cmd", required=True)
253
+ q = sub.add_parser("eval")
254
+ q.add_argument("--student", required=True, help="a STUDENTS name or a checkpoint path")
255
+ q.add_argument("--tag", required=True)
256
+ q.add_argument("--arm", choices=("RL", "GR", "own"), required=True)
257
+ q.add_argument("--tasks", required=True)
258
+ q.add_argument("--draws", type=int, default=1)
259
+ q.add_argument("--seed-base", type=int, default=0, help="seed = base + row + N j (0: the file's seeds, 1 draw)")
260
+ q.add_argument("--plane", default="measured", help="measured | sim | c0,c1,c2")
261
+ q.add_argument("--plane-dz", type=float, default=0.0, help="m added to the plane's height term")
262
+ q.add_argument("--floor", default="zero")
263
+ q.add_argument("--horizon", type=int, default=400)
264
+ q.add_argument("--hold-cap-s", type=float, default=40.0)
265
+ q.add_argument("--roll-hi-deg", type=float, default=None)
266
+ q.add_argument("--workers", type=int, default=6)
267
+ q.add_argument("--threads", type=int, default=6)
268
+ q.add_argument("--out", required=True, help="output .npz")
269
+ q.set_defaults(fn=cmd_eval)
270
+ a = p.parse_args()
271
+ a.fn(a)
272
+
273
+
274
+ if __name__ == "__main__":
275
+ main()
so101_pick_place/code/scripts/so101_pick_place/check/gates_summary.py ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Gate summary for one checkpoint against D on the same platform (SELECTION_v12.md section 2, Addenda A and B).
2
+
3
+ python -B gates_summary.py --platform local --name <name> [--ref D] --out <json> --root DIR [--ref-root DIR]
4
+ Runs: <root>/runs/gates/<platform>/<name>/<run>.npz (run_gates.sh names). D's reference: <ref-root>/runs/gates/
5
+ <platform>/<ref>/ (default: the same root) with the "ref" runs (G2 repeats g2_b / g2_c, H68 block b).
6
+ Ported from the study's ~/so101_r2s_claude/v12/check/lib/gates_summary.py: --root is required (no default check
7
+ folder) and --validation names the check's validation result (was <check folder>/out/validation.json).
8
+
9
+ Addendum B:
10
+ - B2: G1, G2, G3 run in the student's own pinned look (check_eval.py arm "own"). The look each run recorded is checked
11
+ against the arm of the name (visR / visRtbpl: the real-look parts; every other arm and D: the grey parts). D's
12
+ reference runs are arm GR (= D's own look; own == GR bit-identical on D, 2026-10-27). A mismatch is an error (the
13
+ checkpoint is then undecided). visR / visRtbpl also run g2_a_GR (grey-look G2): reported only.
14
+ - B1: G2 tolerance A1 = max(2.5 SD sqrt(4/3), 4); G3 = max(2.5 SD sqrt(2), 4) (one D run per plane).
15
+ - B3: the release veto from g4_h68_RL_a (block 613,000) and g4_h68_RL_b (block 613,300): grasp releases at >= 2
16
+ distinct starts in each block. ctrl's veto is computed and reported (rank_selection.py exempts it).
17
+ - B6: every G2 / G3 result also gives the robot place rule (near_place: the jaw opens with the cube within 30 mm of
18
+ the plate centre, or a sim place) next to the sim lenient place, per direction (lr = cube left L->R, rl = cube
19
+ right R->L, from the task metadata).
20
+ - G4 (a)-(d) are reported only (B3 replaces their use; A3: the check is not usable as a gate).
21
+ """
22
+ from __future__ import annotations
23
+
24
+ import argparse
25
+ import json
26
+ import sys
27
+ from pathlib import Path
28
+
29
+ import numpy as np
30
+
31
+ HERE = Path(__file__).resolve().parent.parent
32
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
33
+ import check_analyze as CA # noqa: E402
34
+ import sel_rules as SR # noqa: E402
35
+
36
+ _CACHE = {}
37
+ G1_RUNS = ("g1_dev100", "g1_homedev100")
38
+ G23_RUNS = ("g2_a", "g3_m3", "g3_p3")
39
+ METRICS = ("grasp", "place", "carry_stop")
40
+ DIRS = ("lr", "rl")
41
+
42
+
43
+ def run(root, plat, name, r, kind):
44
+ f = Path(root) / f"runs/gates/{plat}/{name}/{r}.npz"
45
+ key = str(f)
46
+ if key in _CACHE:
47
+ return _CACHE[key]
48
+ if not f.exists():
49
+ _CACHE[key] = None
50
+ return None
51
+ rows, info = CA.run_episodes(str(f))
52
+ out = dict(file=str(f), info=info)
53
+ if kind == "G1":
54
+ out["n"], out["lenient"] = len(rows), sum(x["lenient"] for x in rows)
55
+ elif kind == "J":
56
+ for x in rows:
57
+ x["row"], x["draw"] = x["ep"], 0
58
+ st = CA.per_start(rows, len(rows))
59
+ out["counts"] = CA.counts(st, rows)
60
+ pl = info.get("plane")
61
+ t = CA.j_task(str(f), tuple(pl) if pl else None, info)
62
+ out["task"] = {k: v for k, v in t.items() if k != "per_episode"}
63
+ out["per_episode"] = t["per_episode"]
64
+ else:
65
+ N = 68
66
+ for x in rows:
67
+ x["row"], x["draw"] = x["ep"] % N, x["ep"] // N
68
+ st = CA.per_start(rows, N)
69
+ out["counts"] = CA.counts(st, rows)
70
+ out["plans"] = [s["plan"] for s in st]
71
+ _CACHE[key] = out
72
+ return out
73
+
74
+
75
+ def contrast(rl, gr):
76
+ a = np.array([np.nan if v is None else v for v in rl["plans"]])
77
+ b = np.array([np.nan if v is None else v for v in gr["plans"]])
78
+ ok = np.isfinite(a) & np.isfinite(b)
79
+ return float((a[ok] - b[ok]).mean()), int(ok.sum())
80
+
81
+
82
+ def collect(root, plat, name, is_ref, grey_g2):
83
+ """-> (runs dict, required run names, report-only run names)."""
84
+ req = list(G1_RUNS) + list(G23_RUNS) + ["g4_h68_RL_a", "g4_h68_RL_b"] + (["g2_b", "g2_c"] if is_ref else [])
85
+ rep = ["g4_h68_GR_a", "g4_j224_RL"] + (["g4_h68_GR_b"] if is_ref else []) + (["g2_a_GR"] if grey_g2 else [])
86
+ kind = {r: ("G1" if r.startswith("g1_") else "H" if "h68" in r else "J") for r in req + rep}
87
+ return {r: run(root, plat, name, r, kind[r]) for r in req + rep}, req, rep
88
+
89
+
90
+ def run_look(info):
91
+ """The look a run rendered: the recorded 'look' (check_eval.py since Addendum B), else from the arm (GR / RL)."""
92
+ return info.get("look") or {"GR": "grey", "RL": "real"}.get(info.get("arm"))
93
+
94
+
95
+ def look_errors(R, arm, is_ref):
96
+ """B2 checks: G1-G3 runs in the student's own look (candidates: arm 'own'); g2_a_GR in the grey look."""
97
+ exp = SR.own_look(arm) if arm else ("grey" if is_ref else None)
98
+ errs = []
99
+ for r in G1_RUNS + G23_RUNS + (("g2_b", "g2_c") if is_ref else ()):
100
+ x = R.get(r)
101
+ if not x:
102
+ continue
103
+ lk, am = run_look(x["info"]), x["info"].get("arm")
104
+ if exp and lk != exp:
105
+ errs.append(f"{r}: look {lk} (arm {am}), not the own look {exp} of arm {arm or 'D'} (B2)")
106
+ if not is_ref and am != "own":
107
+ errs.append(f"{r}: arm {am}, not 'own' (B2: G1-G3 in the student's own pinned look)")
108
+ if R.get("g2_a_GR") and run_look(R["g2_a_GR"]["info"]) != "grey":
109
+ errs.append(f"g2_a_GR: look {run_look(R['g2_a_GR']['info'])}, not grey")
110
+ for r in ("g4_h68_RL_a", "g4_h68_RL_b", "g4_j224_RL"):
111
+ if R.get(r) and run_look(R[r]["info"]) != "real":
112
+ errs.append(f"{r}: look {run_look(R[r]['info'])}, not the real look (arm RL)")
113
+ for r in ("g4_h68_RL_a", "g4_h68_RL_b"):
114
+ sb = {"g4_h68_RL_a": 613000, "g4_h68_RL_b": 613300}[r]
115
+ if R.get(r) and (R[r]["info"].get("seed_base"), R[r]["info"].get("draws")) != (sb, 4):
116
+ errs.append(f"{r}: seed base {R[r]['info'].get('seed_base')} / draws {R[r]['info'].get('draws')}, "
117
+ f"not {sb} / 4 (B3)")
118
+ return errs
119
+
120
+
121
+ def by_direction(task):
122
+ """B6: per direction the sim lenient place next to the robot place rule (near_place)."""
123
+ return {d: dict(n=task[d]["n"], grasp=task[d]["grasp"], place_sim=task[d]["place"],
124
+ place_robot_rule=task[d]["near_place"], carry_stop=task[d]["carry_stop"]) for d in DIRS}
125
+
126
+
127
+ def by_direction_mean(tasks):
128
+ return {d: {k: round(float(np.mean([by_direction(t)[d][k] for t in tasks])), 2)
129
+ for k in ("n", "grasp", "place_sim", "place_robot_rule", "carry_stop")} for d in DIRS}
130
+
131
+
132
+ def judge(xr, ref_vals, tol, ref_dirs):
133
+ out = {}
134
+ for m in METRICS:
135
+ c = xr["task"]["all"][m]
136
+ ok = (c <= ref_vals[m] + tol[m]) if m == "carry_stop" else (c >= ref_vals[m] - tol[m])
137
+ out[m] = dict(cand=c, D=round(ref_vals[m], 2), tol=round(tol[m], 3), pass_=bool(ok))
138
+ out["pass"] = all(out[m]["pass_"] for m in METRICS)
139
+ out["place_robot_rule_all"] = dict(cand=xr["task"]["all"]["near_place"])
140
+ out["by_direction"] = by_direction(xr["task"])
141
+ out["D_by_direction"] = ref_dirs
142
+ return out
143
+
144
+
145
+ def summarize(plat, name, ref="D", root=HERE, ref_root=HERE, validation=None):
146
+ is_ref = name == ref
147
+ arm = SR.arm_of(name)
148
+ run_name, it = SR.parse_ckpt(name)
149
+ D, dreq, _ = collect(ref_root, plat, ref, True, False)
150
+ X, xreq, xrep = (D, dreq, []) if is_ref and Path(root) == Path(ref_root) else \
151
+ collect(root, plat, name, is_ref, arm in SR.REAL_LOOK_ARMS)
152
+ miss = [f"{ref}:{k}" for k in dreq if D[k] is None] + ([] if is_ref else [f"{name}:{k}" for k in xreq if X[k] is None])
153
+ miss_rep = [f"{name}:{k}" for k in xrep if X[k] is None]
154
+ res = dict(platform=plat, name=name, ref=ref, arm=arm, run=run_name, it=it,
155
+ seed=SR.parse_run(run_name)[1] if run_name else None,
156
+ own_look=SR.own_look(arm) if arm else ("grey" if is_ref else None),
157
+ missing=miss, missing_report_only=miss_rep, errors=[])
158
+ if arm is None and not is_ref:
159
+ res["errors"].append(f"{name}: not a v12 candidate name (v12_<arm>_s<seed>_it<1000|1500>)")
160
+ res["errors"] += look_errors(X, arm, is_ref) + ([] if is_ref else [f"D reference: {e}" for e in look_errors(D, None, True)])
161
+ shas = sorted({v["info"].get("ckpt_sha256") for v in X.values() if v and v["info"].get("ckpt_sha256")})
162
+ ckpts = sorted({v["info"].get("ckpt") for v in X.values() if v and v["info"].get("ckpt")})
163
+ if len(shas) > 1:
164
+ res["errors"].append(f"the runs of {name} used {len(shas)} different checkpoints {[s[:12] for s in shas]}")
165
+ res["ckpt"], res["ckpt_sha256"] = (ckpts[0] if len(ckpts) == 1 else ckpts), (shas[0] if len(shas) == 1 else shas)
166
+ val = Path(validation) if validation else None
167
+ res["check_usable_as_gate"] = json.loads(val.read_text()).get("verdict", {}).get("usable_as_gate") \
168
+ if val and val.exists() else None
169
+ G = {}
170
+ # G1
171
+ if all(X[r] and D[r] for r in G1_RUNS):
172
+ def pc(R):
173
+ return 100.0 * sum(R[r]["lenient"] for r in G1_RUNS) / sum(R[r]["n"] for r in G1_RUNS)
174
+ G["G1"] = dict(cand=round(pc(X), 2), D=round(pc(D), 2), line=round(pc(D) - 3.0, 2),
175
+ cand_sets=[X[r]["lenient"] for r in G1_RUNS], D_sets=[D[r]["lenient"] for r in G1_RUNS])
176
+ G["G1"]["pass"] = G["G1"]["cand"] >= G["G1"]["line"] - 1e-9
177
+ # G2 / G3 (tolerances from D's three G2 runs on this platform; A1 and B1)
178
+ if all(D[r] for r in ("g2_a", "g2_b", "g2_c")):
179
+ tol2, tol3, dmean, tol_range, sd1 = {}, {}, {}, {}, {}
180
+ for m in METRICS:
181
+ v = [D[r]["task"]["all"][m] for r in ("g2_a", "g2_b", "g2_c")]
182
+ tol_range[m] = max(1.5 * (max(v) - min(v)), 4.0) # the first rule (22:12), replaced by A1
183
+ M = np.array([[e[m] for e in D[r]["per_episode"]] for r in ("g2_a", "g2_b", "g2_c")], float)
184
+ sd1[m] = float(np.sqrt(M.var(0, ddof=1).sum())) # SD of one run's total (per-episode variances)
185
+ tol2[m], tol3[m] = SR.tol_g2(sd1[m]), SR.tol_g3(sd1[m])
186
+ dmean[m] = float(np.mean(v))
187
+ res["tolerance"] = dict(G2=dict(rule="A1: max(2.5 x SD x sqrt(1 + 1/3), 4) (one run vs the mean of D's 3)",
188
+ tol=tol2),
189
+ G3=dict(rule="B1: max(2.5 x SD x sqrt(2), 4) (one run vs ONE D run per plane)", tol=tol3),
190
+ sd_one_run=sd1, tol_first_rule_range=tol_range,
191
+ D_runs={m: [D[r]["task"]["all"][m] for r in ("g2_a", "g2_b", "g2_c")] for m in METRICS},
192
+ D_mean=dmean)
193
+ d2dirs = by_direction_mean([D[r]["task"] for r in ("g2_a", "g2_b", "g2_c")])
194
+ if X["g2_a"]:
195
+ G["G2"] = judge(X["g2_a"], dmean, tol2, d2dirs)
196
+ G["G2"]["look"] = run_look(X["g2_a"]["info"])
197
+ if X.get("g2_a_GR"): # B2: grey-look G2 of visR / visRtbpl, report only
198
+ G["G2_grey_report"] = judge(X["g2_a_GR"], dmean, tol2, d2dirs)
199
+ G["G2_grey_report"]["note"] = "report only (B2); D's reference = D in its own look (grey)"
200
+ g3 = {}
201
+ for r in ("g3_m3", "g3_p3"):
202
+ if X[r] and D[r]:
203
+ g3[r] = judge(X[r], {m: float(D[r]["task"]["all"][m]) for m in METRICS}, tol3, by_direction(D[r]["task"]))
204
+ if len(g3) == 2:
205
+ G["G3"] = dict(planes=g3, **{"pass": all(v["pass"] for v in g3.values())})
206
+ # B3 release veto (H68, real look, blocks 613,000 / 613,300; distinct starts per block)
207
+ def blocks(R):
208
+ blk = {}
209
+ for b, r in (("613000", "g4_h68_RL_a"), ("613300", "g4_h68_RL_b")):
210
+ if R.get(r):
211
+ c = R[r]["counts"]
212
+ blk[b] = dict(grasp_releases=c["grasp_release"], episodes=c["episodes"], starts=c["starts_grasp_release"],
213
+ start_rows=c["grasp_release_starts"], loose_starts=c["loose"])
214
+ return blk
215
+ blk, dblk = blocks(X), blocks(D)
216
+ sa, sb = (blk[b]["starts"] if b in blk else None for b in ("613000", "613300"))
217
+ res["veto"] = dict(rule=f"B3: grasp releases at >= {SR.VETO_MIN_STARTS} distinct starts in block 613,000 AND in "
218
+ "block 613,300", blocks=blk, vetoed=SR.vetoed(sa, sb),
219
+ applies=SR.veto_applies(arm) if arm else None, D_blocks=dblk)
220
+ # G4 (a)-(d): reported only
221
+ need = ("g4_h68_RL_a", "g4_h68_GR_a", "g4_h68_RL_b", "g4_h68_GR_b", "g4_j224_RL")
222
+ if all(D[r] for r in need) and all(X[r] for r in ("g4_h68_RL_a", "g4_h68_GR_a", "g4_j224_RL")):
223
+ dl = max(D["g4_h68_RL_a"]["counts"]["loose"], D["g4_h68_RL_b"]["counts"]["loose"])
224
+ dg = max(D["g4_h68_RL_a"]["counts"]["grasp_release"], D["g4_h68_RL_b"]["counts"]["grasp_release"])
225
+ dj = D["g4_j224_RL"]["counts"]["grasp_release"]
226
+ dc, _ = contrast(D["g4_h68_RL_a"], D["g4_h68_GR_a"])
227
+ xc, nc = contrast(X["g4_h68_RL_a"], X["g4_h68_GR_a"])
228
+ g4 = dict(a_loose=dict(cand=X["g4_h68_RL_a"]["counts"]["loose"], D=dl),
229
+ b_grasp_release=dict(cand=X["g4_h68_RL_a"]["counts"]["grasp_release"], D=dg),
230
+ c_j224_grasp_release=dict(cand=X["g4_j224_RL"]["counts"]["grasp_release"], D=dj, line=dj + 2),
231
+ d_contrast=dict(cand=round(xc, 3), D=round(dc, 3), n=nc),
232
+ plan_mean_RL=dict(cand=X["g4_h68_RL_a"]["counts"]["plan_mean"], D=D["g4_h68_RL_a"]["counts"]["plan_mean"]),
233
+ j224_RL_task=dict(place_sim_all=X["g4_j224_RL"]["task"]["all"]["place"],
234
+ by_direction=by_direction(X["g4_j224_RL"]["task"])))
235
+ g4["a_loose"]["pass_"] = g4["a_loose"]["cand"] <= dl
236
+ g4["b_grasp_release"]["pass_"] = g4["b_grasp_release"]["cand"] <= dg
237
+ g4["c_j224_grasp_release"]["pass_"] = g4["c_j224_grasp_release"]["cand"] <= dj + 2
238
+ g4["d_contrast"]["pass_"] = xc < dc
239
+ g4["pass"] = all(v["pass_"] for v in g4.values() if isinstance(v, dict) and "pass_" in v)
240
+ g4["gates"] = False
241
+ g4["note"] = "reported only (B3 replaces the use of G4 (a)-(d); A3: not usable as a gate)"
242
+ G["G4_report"] = g4
243
+ res["gates"] = G
244
+ decided = not miss and not res["errors"]
245
+ res["pass_G123"] = all(G.get(k, {}).get("pass", False) for k in ("G1", "G2", "G3")) if decided else None
246
+ res["vetoed"] = res["veto"]["vetoed"] if decided else None
247
+ res["eligible"] = SR.ckpt_test(res, arm) if arm else None # B4 (1) test (ctrl: veto exempt)
248
+ res["g2_places_own"] = X["g2_a"]["task"]["all"]["place"] if X.get("g2_a") else None # B4 (2)
249
+ res["gates_used"] = ["G1", "G2", "G3", "veto (B3; not ctrl)"]
250
+ return res, D, X
251
+
252
+
253
+ def main():
254
+ p = argparse.ArgumentParser()
255
+ p.add_argument("--platform", required=True)
256
+ p.add_argument("--name", required=True)
257
+ p.add_argument("--ref", default="D")
258
+ p.add_argument("--root", required=True, help="folder with runs/gates/<platform>/<name>/")
259
+ p.add_argument("--ref-root", default="", help="folder with D's reference runs (default: --root)")
260
+ p.add_argument("--validation", default="", help="the check's validation result (verdict.usable_as_gate)")
261
+ p.add_argument("--out", required=True)
262
+ a = p.parse_args()
263
+ res, D, X = summarize(a.platform, a.name, a.ref, a.root, a.ref_root or a.root, a.validation or None)
264
+ if res["missing"]:
265
+ print("missing runs:", res["missing"])
266
+ if res["errors"]:
267
+ print("errors:", res["errors"])
268
+ Path(a.out).parent.mkdir(parents=True, exist_ok=True)
269
+ Path(a.out).write_text(json.dumps(res, indent=1, default=float))
270
+ G = res["gates"]
271
+ print(json.dumps({k: (v.get("pass") if isinstance(v, dict) else v) for k, v in G.items()}),
272
+ "veto", res["veto"]["vetoed"], {b: v["starts"] for b, v in res["veto"]["blocks"].items()},
273
+ "pass_G123", res["pass_G123"], "eligible", res["eligible"], "g2_places", res["g2_places_own"])
274
+
275
+
276
+ if __name__ == "__main__":
277
+ main()
so101_pick_place/code/scripts/so101_pick_place/check/run_gates.sh ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # The sim checks of a camera student (the v12 selection gates, results/sim_checks/SELECTION_v12.md on the Hub): G1
3
+ # nominal success on the sim table, G2 the robot-like check, G3 the table plane -3 / +3 mm, the B3 release veto and
4
+ # the G4 numbers (reported only). Every run is one check_eval.py evaluation (CPU MuJoCo + GPU renders).
5
+ #
6
+ # run_gates.sh run <name> <student.pt> <root> [ref] the evaluations one after the other -> <root>/runs/gates/local/<name>/
7
+ # run_gates.sh summary <name> <root> [ref_name] -> <root>/out/gates/local/<name>.json (gates_summary.py, against
8
+ # D's runs in <root>/runs/gates/local/<ref_name>, default D)
9
+ # "ref" adds D's extra reference runs (G2 repeats b / c, the H68 grey repeat): run D once with "ref" before the
10
+ # summary of another student (name D, checkpoint student/s4_v8_roll_s801/it_02000.pt). Student names for the summary:
11
+ # v12_<arm>_s<seed>_it<1000|1500> (the released student: v12_tb10_s1210_it1000).
12
+ #
13
+ # Per checkpoint (9 evaluations; ref: + 3):
14
+ # g1_dev100, g1_homedev100 sim table, nominal, no servo model, roll cap 98, 1,500 steps, hold cap 20 s, own look
15
+ # g2_a J224, measured plane, flat floor, fit_d2q, 40 s, own look (file seeds)
16
+ # g2_b, g2_c (ref) the same, seeds 613,600 / 613,900
17
+ # g3_m3, g3_p3 g2_a with the plane height -3 / +3 mm
18
+ # g4_h68_RL_a, g4_h68_RL_b H68 x 4 draws, 8 s, real look (arm RL), seeds 613,000 / 613,300 (B3 veto: both blocks)
19
+ # g4_h68_GR_a H68 grey look, seeds 613,000 (G4 (d) contrast, reported)
20
+ # g4_h68_GR_b (ref) seeds 613,300
21
+ # g4_j224_RL J224 in arm RL (G4 (c), reported)
22
+ #
23
+ # Environment: PY (Python with torch, mujoco, warp-lang, newton; default python3), WORKERS (CPU MuJoCo workers,
24
+ # default 6), RUNNER (a command prefix for every evaluation, e.g. a memory cap), ONLY (comma list of run names: run
25
+ # only these), HORIZON / TASK_ROWS (smoke only: shorter episodes / the first rows of the task file; the gate rules
26
+ # need the full sets).
27
+ # Ported from the study's runner ~/so101_r2s_claude/v12/check/run_gates.sh + lib/run_one.sh (local mode; the AMD
28
+ # mode, the GPU lock and the memory cap of the study machine are left out). The evaluation list is the same.
29
+ set -uo pipefail
30
+ CODE="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
31
+ CK="$CODE/scripts/so101_pick_place/check"
32
+ A="$CODE/artifacts/so101_pick_place"
33
+ J=$A/rl_inputs/check_tasks/jit224.npz
34
+ H=$A/rl_inputs/check_tasks/h68.npz
35
+ DEV=$A/rl_inputs/tasks/dev100.npz
36
+ HDEV=$A/rl_inputs/tasks/home_dev100.npz
37
+ DYN_FILE=$CODE/configs/so101_pick_place/dyn_fit_d2q.json
38
+ PY=${PY:-python3}
39
+ MODE=${1:?mode: run | summary}
40
+
41
+ list() { # <ref>: one line per evaluation: <dyn> <run> <check_eval args>
42
+ local REF=$1
43
+ echo "fit_d2q g2_a --arm own --tasks $J --horizon 2000"
44
+ echo "fit_d2q g4_j224_RL --arm RL --tasks $J --horizon 2000"
45
+ echo "fit_d2q g3_m3 --arm own --tasks $J --horizon 2000 --plane-dz -0.003"
46
+ echo "fit_d2q g3_p3 --arm own --tasks $J --horizon 2000 --plane-dz 0.003"
47
+ [ "$REF" = ref ] && echo "fit_d2q g2_b --arm own --tasks $J --horizon 2000 --seed-base 613600"
48
+ [ "$REF" = ref ] && echo "fit_d2q g2_c --arm own --tasks $J --horizon 2000 --seed-base 613900"
49
+ echo "none g1_dev100 --arm own --tasks $DEV --plane sim --horizon 1500 --hold-cap-s 20 --roll-hi-deg 98"
50
+ echo "none g1_homedev100 --arm own --tasks $HDEV --plane sim --horizon 1500 --hold-cap-s 20 --roll-hi-deg 98"
51
+ echo "fit_d2q g4_h68_RL_a --arm RL --tasks $H --draws 4 --seed-base 613000 --horizon 400"
52
+ echo "fit_d2q g4_h68_RL_b --arm RL --tasks $H --draws 4 --seed-base 613300 --horizon 400"
53
+ echo "fit_d2q g4_h68_GR_a --arm GR --tasks $H --draws 4 --seed-base 613000 --horizon 400"
54
+ [ "$REF" = ref ] && echo "fit_d2q g4_h68_GR_b --arm GR --tasks $H --draws 4 --seed-base 613300 --horizon 400"
55
+ return 0
56
+ }
57
+
58
+ export PYTHONPATH="$CODE/src${PYTHONPATH:+:$PYTHONPATH}" PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
59
+ export OMP_NUM_THREADS=${OMP_NUM_THREADS:-6} MKL_NUM_THREADS=${MKL_NUM_THREADS:-6}
60
+ cd "$CODE"
61
+ case $MODE in
62
+ run)
63
+ NAME=${2:?name}; CKPT=$(readlink -f "${3:?student checkpoint}"); ROOT=${4:?output root}; REF=${5:-}
64
+ [ -f "$CKPT" ] || { echo "run_gates: no checkpoint $CKPT"; exit 2; }
65
+ O=$ROOT/runs/gates/local/$NAME; mkdir -p "$O" "$ROOT/logs"
66
+ T0=$(date +%s)
67
+ echo "[$(date +%T)] run_gates $NAME $CKPT $REF" | tee -a "$O/gates.log"
68
+ FAIL=0
69
+ while read -r dyn run args; do
70
+ if [ -n "${ONLY:-}" ] && [[ ",$ONLY," != *",$run,"* ]]; then continue; fi
71
+ [ -f "$O/$run.npz" ] && { echo "skip $run (exists)" >> "$O/gates.log"; continue; }
72
+ if [ -n "${TASK_ROWS:-}" ]; then # smoke: the first TASK_ROWS rows of the task file
73
+ set -- $args; tf=""; rest=()
74
+ while [ $# -gt 0 ]; do if [ "$1" = --tasks ]; then tf=$2; shift 2; else rest+=("$1"); shift; fi; done
75
+ sub=$O/_rows_${run}.npz
76
+ "$PY" -c "import numpy as np, sys; t = dict(np.load(sys.argv[1], allow_pickle=True)); n = len(t['seeds']); k = int(sys.argv[3]); np.savez(sys.argv[2], **{a: (v[:k] if np.ndim(v) and len(v) == n else v) for a, v in t.items()})" "$tf" "$sub" "$TASK_ROWS"
77
+ args="${rest[*]} --tasks $sub"
78
+ fi
79
+ [ -n "${HORIZON:-}" ] && args="$args --horizon $HORIZON"
80
+ if [ "$dyn" = none ]; then export NEDM_SO101_DYN=""; else export NEDM_SO101_DYN="$(cat "$DYN_FILE")"; fi
81
+ t=$(date +%s)
82
+ ${RUNNER:-} "$PY" -B "$CK/check_eval.py" eval --tag "gates_${NAME}_$run" --workers "${WORKERS:-6}" --student "$CKPT" \
83
+ --out "$O/$run.npz" $args > "$ROOT/logs/gates_${NAME}_$run.log" 2>&1 < /dev/null
84
+ rc=$?
85
+ rm -f "$O/_rows_${run}.npz"
86
+ echo "[$(date +%T)] $run rc $rc wall $(( $(date +%s) - t )) s" | tee -a "$O/gates.log"
87
+ [ "$rc" = 0 ] || FAIL=$((FAIL + 1))
88
+ done < <(list "$REF")
89
+ echo "[$(date +%T)] run_gates $NAME done, wall $(( $(date +%s) - T0 )) s, $FAIL failed" | tee -a "$O/gates.log"
90
+ [ "$FAIL" = 0 ] || { echo "run_gates: $FAIL evaluations failed (logs: $ROOT/logs/gates_${NAME}_*.log)" >&2; exit 1; };;
91
+ summary)
92
+ NAME=${2:?name}; ROOT=${3:?root}; REFN=${4:-D}
93
+ mkdir -p "$ROOT/out/gates/local"
94
+ ${RUNNER:-} "$PY" -B "$CK/gates_summary.py" --platform local --name "$NAME" --ref "$REFN" --root "$ROOT" \
95
+ --out "$ROOT/out/gates/local/$NAME.json";;
96
+ *) sed -n 2,26p "$0"; exit 2;;
97
+ esac
so101_pick_place/code/scripts/so101_pick_place/check/sel_rules.py ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Addendum B of SELECTION_v12.md (results/sim_checks/ on the Hub) as pure functions (no file I/O), used by
2
+ gates_summary.py.
3
+
4
+ - names: v12_<arm>_s<seed> (a run) and v12_<arm>_s<seed>_it<1000|1500> (a checkpoint); "visR" is a prefix of
5
+ "visRtbpl", so the arm is matched as a whole token between "v12_" and "_s<digits>".
6
+ - B1 tolerances: G2 = max(2.5 SD sqrt(1 + 1/3), 4) (A1: one run vs the mean of D's 3), G3 = max(2.5 SD sqrt(2), 4)
7
+ (one run vs ONE D run).
8
+ - B2 own look: visR and visRtbpl = the real-look parts, every other arm (and D) = the grey parts.
9
+ - B3 veto: grasp releases at >= 2 distinct starts in block 613,000 AND at >= 2 distinct starts in block 613,300; it
10
+ applies to every arm except ctrl.
11
+ - B4 (1) checkpoint: it 1500 if it passes G1, G2, G3 and is not vetoed, else it 1000 with the same test, else out;
12
+ (2) seed: more G2 places (own look, sim lenient rule); a difference below 20 places is a tie -> the lower seed.
13
+ - B5 slots: 1 visual (visR, visRtbpl, visH), 2 table (tbpl, tb10, tb15, tb05), 3 table + visual (visRtbpl, visH, then
14
+ the next unused table arm), 4 control (ctrl, visH, then the next unused table arm); empty if no candidate.
15
+ """
16
+ from __future__ import annotations
17
+
18
+ import math
19
+ import re
20
+
21
+ ARMS = ("ctrl", "tb05", "tb10", "tb15", "tbpl", "visR", "visH", "visRtbpl")
22
+ _ARM_RX = "|".join(sorted(ARMS, key=len, reverse=True)) # longest first (visRtbpl before visR)
23
+ RUN_RX = re.compile(rf"^v12_({_ARM_RX})_s(\d+)$")
24
+ CKPT_RX = re.compile(rf"^(v12_(?:{_ARM_RX})_s\d+)_it(1000|1500)$")
25
+ ITS = ("it1500", "it1000") # B4 (1) order
26
+ # SELECTION_v12.md section 1 (12 runs, 24 checkpoints; the "26" in section 1 is a miscount)
27
+ EXPECTED_RUNS = ("v12_ctrl_s1201", "v12_ctrl_s1202", "v12_tb05_s1205", "v12_tb10_s1210", "v12_tb15_s1215",
28
+ "v12_tbpl_s1221", "v12_tbpl_s1222", "v12_visR_s1231", "v12_visR_s1232", "v12_visH_s1235",
29
+ "v12_visRtbpl_s1241", "v12_visRtbpl_s1242")
30
+ REAL_LOOK_ARMS = ("visR", "visRtbpl")
31
+ TIE_PLACES = 20
32
+ VETO_MIN_STARTS = 2
33
+ SLOT1 = ("visR", "visRtbpl", "visH")
34
+ TABLE_ORDER = ("tbpl", "tb10", "tb15", "tb05")
35
+ SLOT3 = ("visRtbpl", "visH") + TABLE_ORDER
36
+ SLOT4 = ("ctrl", "visH") + TABLE_ORDER
37
+ SLOTS = ((1, "visual", SLOT1), (2, "table", TABLE_ORDER), (3, "table + visual", SLOT3), (4, "control", SLOT4))
38
+
39
+
40
+ def parse_run(run):
41
+ """'v12_visRtbpl_s1241' -> ('visRtbpl', 1241); anything else -> (None, None)."""
42
+ m = RUN_RX.match(run or "")
43
+ return (m.group(1), int(m.group(2))) if m else (None, None)
44
+
45
+
46
+ def parse_ckpt(name):
47
+ """'v12_visR_s1231_it1500' -> ('v12_visR_s1231', 'it1500'); anything else -> (None, None)."""
48
+ m = CKPT_RX.match(name or "")
49
+ return (m.group(1), f"it{m.group(2)}") if m else (None, None)
50
+
51
+
52
+ def arm_of(name):
53
+ """The arm of a run or checkpoint name (None if the name is not a v12 candidate)."""
54
+ run, _ = parse_ckpt(name)
55
+ return parse_run(run or name)[0]
56
+
57
+
58
+ def own_look(arm):
59
+ """B2: the look of a student's pinned scene: 'real' for visR / visRtbpl, else 'grey' (D and the other arms)."""
60
+ return "real" if arm in REAL_LOOK_ARMS else "grey"
61
+
62
+
63
+ def tol_g2(sd):
64
+ """A1 (kept by B1): one candidate run vs the mean of D's three runs."""
65
+ return max(2.5 * sd * math.sqrt(1.0 + 1.0 / 3.0), 4.0)
66
+
67
+
68
+ def tol_g3(sd):
69
+ """B1: one candidate run vs ONE D run at each plane."""
70
+ return max(2.5 * sd * math.sqrt(2.0), 4.0)
71
+
72
+
73
+ def vetoed(starts_a, starts_b):
74
+ """B3: grasp releases at >= 2 distinct starts in block 613,000 AND in block 613,300 (None if a block is missing)."""
75
+ if starts_a is None or starts_b is None:
76
+ return None
77
+ return starts_a >= VETO_MIN_STARTS and starts_b >= VETO_MIN_STARTS
78
+
79
+
80
+ def veto_applies(arm):
81
+ """B3: every arm except ctrl (the training-length control)."""
82
+ return arm != "ctrl"
83
+
84
+
85
+ def ckpt_test(summary, arm):
86
+ """B4 (1) test of one checkpoint: True (passes G1, G2, G3 and, unless ctrl, is not vetoed), False, or None
87
+ (undecided: a summary or a required run is missing, or an error)."""
88
+ if not summary or summary.get("errors"):
89
+ return None
90
+ g = summary.get("pass_G123")
91
+ if g is None:
92
+ return None
93
+ if not g:
94
+ return False
95
+ if not veto_applies(arm):
96
+ return True
97
+ v = summary.get("veto", {}).get("vetoed")
98
+ if v is None:
99
+ return None
100
+ return not v
101
+
102
+
103
+ def pick_checkpoint(its, arm):
104
+ """B4 (1): its = {'it1500': summary, 'it1000': summary}. Returns dict(pick, status, why); status 'pass', 'out' or
105
+ 'undecided' (an undecided it 1500 is not skipped: the run is undecided until it is complete)."""
106
+ why = []
107
+ for it in ITS:
108
+ ok = ckpt_test(its.get(it), arm)
109
+ if ok is None:
110
+ why.append(f"{it} undecided")
111
+ return dict(pick=None, status="undecided", why="; ".join(why))
112
+ if ok:
113
+ why.append(f"{it} passes" + ("" if veto_applies(arm) else " G1-G3 (ctrl: veto exempt)"))
114
+ return dict(pick=it, status="pass", why="; ".join(why))
115
+ why.append(f"{it} fails ({fail_reason(its[it], arm)})")
116
+ return dict(pick=None, status="out", why="; ".join(why) + " -> the run is out")
117
+
118
+
119
+ def fail_reason(summary, arm):
120
+ out = [g for g in ("G1", "G2", "G3") if not summary.get("gates", {}).get(g, {}).get("pass", False)]
121
+ if veto_applies(arm) and summary.get("veto", {}).get("vetoed"):
122
+ out.append("vetoed")
123
+ return ", ".join(out) or "?"
124
+
125
+
126
+ def pick_seed(cands):
127
+ """B4 (2): cands = [dict(run, seed, places)] (passing runs of one arm). The run with more G2 places; a difference
128
+ below TIE_PLACES is a tie and a tie goes to the lower seed. Returns (chosen dict, why)."""
129
+ if not cands:
130
+ return None, "no passing run"
131
+ if len(cands) == 1:
132
+ return cands[0], "the only passing run"
133
+ best = max(c["places"] for c in cands)
134
+ tied = [c for c in cands if best - c["places"] < TIE_PLACES]
135
+ ch = min(tied, key=lambda c: c["seed"])
136
+ pl = ", ".join(f"s{c['seed']} {c['places']}" for c in sorted(cands, key=lambda c: c["seed"]))
137
+ if len(tied) > 1:
138
+ return ch, f"G2 places {pl}: difference below {TIE_PLACES} = tie -> the lower seed s{ch['seed']}"
139
+ return ch, f"G2 places {pl}: s{ch['seed']} has {TIE_PLACES} or more places more"
140
+
141
+
142
+ def fill_slots(passing):
143
+ """B5: passing = the set of arms with a chosen run. Returns [dict(slot, family, arm or None, rule)]."""
144
+ used, out = {}, []
145
+ for k, fam, order in SLOTS:
146
+ notes, arm = [], None
147
+ for a in order:
148
+ if a not in passing:
149
+ notes.append(f"{a}: no passing run")
150
+ elif a in used:
151
+ notes.append(f"{a}: used in slot {used[a]}")
152
+ else:
153
+ arm = a
154
+ break
155
+ if arm is not None:
156
+ used[arm] = k
157
+ rule = f"B5 slot {k} order {' > '.join(order)}: " + "; ".join(notes + [f"-> {arm}"])
158
+ else:
159
+ rule = f"B5 slot {k} order {' > '.join(order)}: " + "; ".join(notes) + " -> empty"
160
+ out.append(dict(slot=k, family=fam, arm=arm, rule=rule))
161
+ return out
so101_pick_place/code/scripts/so101_pick_place/check/sim_eps.py ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Per-episode outcomes of the sim reproduction runs (eval_rec.py npz files) with the robot's carry-stop rule.
2
+
3
+ Per episode (sim world b; heights above the PHYSICS table: the calib plane in "real" runs, z = 0 in "nominal" runs):
4
+ grasp the cube held (jaw 3-15 deg and the cube centre within 25 mm of the grasp point) for >= 1 s, or lifted
5
+ lift the cube bottom >= 20 mm above the table at any step (analyze_grasp.py LIFT rule)
6
+ place sim lenient success (task rule)
7
+ near_place robot-like place: lenient, or lifted and then the jaw opened (> 0.19 rad) with the cube centre <= 30 mm
8
+ (xy) from the goal centre (a drop from a hover above the plate counts; the sim's drop rules
9
+ release_high / unsupported end such episodes before the cube lands)
10
+ goal_hover_s time held with the grasp point within 30 mm (xy) of the goal centre
11
+ carry stop the robot rule (robot_eps.py): >= 2 s of consecutive decisions with the cube held and the planned motion
12
+ (max over the 5 arm joints of |last chunk step - q at the decision|) < 0.5 deg
13
+ stall >= 2 s of consecutive decisions with the cube held and the grasp point moving < 5 mm in the next 2 s
14
+ (any plan; includes a plan that pushes into the floor or the table)
15
+ end the sim end code (task.ENDS)
16
+ usage: sim_eps.py OUT.json TAG=run.npz[:plane] ... (plane = 'real' for the calib plane, else nominal)
17
+
18
+ Ported from the study's ~/so101_r2s_claude/v11/fullcheck/lib/sim_eps.py: code, kin points and task metadata come from
19
+ this repository and its download folder (the study read hw_lib.py of commit ddb08332d; its tcp() is the same code).
20
+ """
21
+ from __future__ import annotations
22
+
23
+ import json
24
+ import sys
25
+ from pathlib import Path
26
+
27
+ import numpy as np
28
+
29
+ WT = Path(__file__).resolve().parents[3] # the repository root
30
+ sys.path.insert(0, str(WT / "src"))
31
+ sys.path.insert(0, str(WT / "scripts/so101_policy/real2sim/hw"))
32
+ import hw_lib as H # noqa: E402
33
+ from nedm.so101_policy import task as T # noqa: E402
34
+
35
+ KIN = str(WT / "artifacts/so101_pick_place/rl_inputs/geometry/kin_points_v1.npz")
36
+ PLANE = (-0.00468, -0.03641, 0.01836)
37
+ META = WT / "artifacts/so101_pick_place/rl_inputs/check_tasks/all280.json" # task metadata of jit224 (direction per seed)
38
+ DT = 0.02
39
+ MOVE_DEG, STOP_S, STALL_MM = 0.5, 2.0, 5.0
40
+ HELD_JAW = (3.0, 15.0)
41
+ HELD_D = 0.025
42
+ LIFT, DOWN, OPEN, DROP_R = 0.02, 0.005, 0.19, 0.030
43
+ _L = None
44
+
45
+
46
+ def layer():
47
+ global _L
48
+ if _L is None:
49
+ _L = H.ActionLayer(KIN)
50
+ return _L
51
+
52
+
53
+ def runs(mask, min_n):
54
+ out, i, n = [], 0, len(mask)
55
+ while i < n:
56
+ if mask[i]:
57
+ j = i
58
+ while j < n and mask[j]:
59
+ j += 1
60
+ if j - i >= min_n:
61
+ out.append((i, j))
62
+ i = j
63
+ else:
64
+ i += 1
65
+ return out
66
+
67
+
68
+ def episodes(npz, plane, meta_rows):
69
+ z = np.load(npz, allow_pickle=True)
70
+ q = z["state_q"].astype(np.float64)
71
+ cube = z["state_cube"].astype(np.float64)
72
+ steps = z["steps"].astype(int)
73
+ length = z["length"].astype(int)
74
+ goal = z["goal_xy"].astype(np.float64)
75
+ le = z["lenient"].astype(bool)
76
+ end = z["end"].astype(int)
77
+ rq, rc = z["rec_q"].astype(np.float64), z["rec_chunk"].astype(np.float64)
78
+ n, Tm = q.shape[:2]
79
+ seeds = z["seeds"]
80
+ by_seed = {m["seed"]: m for m in meta_rows}
81
+ tcp = layer().tcp(q.reshape(-1, 6)).reshape(n, Tm, 3)
82
+ per = 5 * DT
83
+ nstop = int(round(STOP_S / per))
84
+ out = []
85
+ for b in range(n):
86
+ k = max(1, min(int(steps[b]), Tm))
87
+ c = cube[b, :k, :3]
88
+ fl = np.zeros(k) if plane is None else plane[0] + plane[1] * c[:, 0] + plane[2] * c[:, 1]
89
+ h = c[:, 2] - T.CUBE_HALF - fl
90
+ jaw = np.degrees(q[b, :k, 5])
91
+ dist = np.linalg.norm(tcp[b, :k] - c, axis=1)
92
+ held = (jaw >= HELD_JAW[0]) & (jaw <= HELD_JAW[1]) & (dist < HELD_D)
93
+ up = np.flatnonzero(h >= LIFT)
94
+ k_lift = int(up[0]) if len(up) else None
95
+ held_runs = runs(held, int(1.0 / DT))
96
+ grasp = bool(held_runs) or k_lift is not None
97
+ rel = None
98
+ if k_lift is not None:
99
+ gone = np.flatnonzero((np.arange(k) > k_lift) & ((np.radians(jaw) > OPEN) | (h < DOWN)))
100
+ if len(gone):
101
+ g = int(gone[0])
102
+ rel = dict(t=round((g + 1) * DT, 2), dxy_mm=round(float(np.linalg.norm(c[g, :2] - goal[b])) * 1e3, 1),
103
+ h_mm=round(float(h[g]) * 1e3, 1))
104
+ relj = None
105
+ if k_lift is not None:
106
+ op = np.flatnonzero((np.arange(k) > k_lift) & (np.radians(jaw) > OPEN))
107
+ if len(op):
108
+ g = int(op[0])
109
+ relj = dict(t=round((g + 1) * DT, 2), dxy_mm=round(float(np.linalg.norm(c[g, :2] - goal[b])) * 1e3, 1),
110
+ h_mm=round(float(h[g]) * 1e3, 1))
111
+ near_goal = np.linalg.norm(tcp[b, :k, :2] - goal[b], axis=1) < DROP_R
112
+ goal_hover_s = round(float((held & near_goal).sum() * DT), 2)
113
+ # decisions: d starts at step 5 d (state index 5 d - 1; d = 0: the start state ~ index 0)
114
+ D = min(int(length[b]), rq.shape[1])
115
+ si = np.clip(5 * np.arange(D) - 1, 0, k - 1)
116
+ mot = np.degrees(np.abs(rc[b, :D, -1, :5] - rq[b, :D, :5])).max(1)
117
+ hd = held[si]
118
+ stops = []
119
+ for i0, i1 in runs(hd & (mot < MOVE_DEG), nstop):
120
+ ss = si[i0:i1]
121
+ stops.append(dict(t0=round(float(si[i0] * DT), 2), dur_s=round((i1 - i0) * per, 2),
122
+ motion_p50_deg=round(float(np.median(mot[i0:i1])), 2),
123
+ tcp_z_mm=round(float(np.median(tcp[b, ss, 2])) * 1e3, 1),
124
+ cube_h_mm=round(float(np.median(h[ss])) * 1e3, 1),
125
+ to_goal_mm=round(float(np.median(np.linalg.norm(tcp[b, ss, :2] - goal[b], axis=1))) * 1e3, 1)))
126
+ # stall: held and the grasp point moves < 5 mm over the next 2 s (100 steps)
127
+ fut = np.clip(si + int(STOP_S / DT), 0, k - 1)
128
+ moved = np.linalg.norm(tcp[b, fut] - tcp[b, si], axis=1) * 1e3
129
+ ok_f = (si + int(STOP_S / DT)) <= k - 1
130
+ stalls = []
131
+ for i0, i1 in runs(hd & ok_f & (moved < STALL_MM), 1):
132
+ ss = si[i0:i1]
133
+ stalls.append(dict(t0=round(float(si[i0] * DT), 2), dur_s=round((i1 - i0) * per + STOP_S, 2),
134
+ motion_p50_deg=round(float(np.median(mot[i0:i1])), 2),
135
+ tcp_z_mm=round(float(np.median(tcp[b, ss, 2])) * 1e3, 1),
136
+ cube_h_mm=round(float(np.median(h[ss])) * 1e3, 1),
137
+ to_goal_mm=round(float(np.median(np.linalg.norm(tcp[b, ss, :2] - goal[b], axis=1))) * 1e3, 1)))
138
+ m = by_seed[int(seeds[b])]
139
+ out.append(dict(ep=b, seed=int(seeds[b]), set=m["set"], layout=m["layout"], jitter=m["jitter"],
140
+ direction=m["direction"], robot_episode=m["episode"], robot_student=m["student"],
141
+ grasp=grasp, lift=k_lift is not None, place=bool(le[b]),
142
+ near_place=bool(le[b] or (relj is not None and relj["dxy_mm"] <= DROP_R * 1e3)), release=rel,
143
+ release_jaw=relj, goal_hover_s=goal_hover_s,
144
+ carry_stop=bool(stops), stops=stops, stall=bool(stalls), stalls=stalls,
145
+ end=T.ENDS[int(end[b])], t_end=round(k * DT, 2), held_s=round(float(held.sum() * DT), 1),
146
+ jaw_min_deg=round(float(jaw.min()), 1)))
147
+ return out
148
+
149
+
150
+ def summary(rows):
151
+ def cnt(rs):
152
+ return dict(n=len(rs), grasp=sum(r["grasp"] for r in rs), lift=sum(r["lift"] for r in rs),
153
+ place=sum(r["place"] for r in rs), near_place=sum(r["near_place"] for r in rs),
154
+ carry_stop=sum(r["carry_stop"] for r in rs), stall=sum(r["stall"] for r in rs))
155
+ s = {}
156
+ for st in sorted({r["set"] for r in rows}):
157
+ rs = [r for r in rows if r["set"] == st]
158
+ s[st] = {d: cnt([r for r in rs if r["direction"] == d]) for d in ("R->L", "L->R")}
159
+ ends = {}
160
+ for r in rs:
161
+ ends[r["end"]] = ends.get(r["end"], 0) + 1
162
+ s[st]["ends"] = ends
163
+ return s
164
+
165
+
166
+ def main():
167
+ meta = json.loads(META.read_text())
168
+ rows_meta = [dict(m, seed=meta["seed0"] + m["row"]) for m in meta["tasks"]]
169
+ res = {}
170
+ for spec in sys.argv[2:]:
171
+ tag, f = spec.split("=", 1)
172
+ pl = None
173
+ if f.endswith(":real"):
174
+ f, pl = f[:-5], PLANE
175
+ elif f.endswith(":realnoy"):
176
+ f, pl = f[:-8], (PLANE[0], PLANE[1], 0.0)
177
+ rows = episodes(f, pl, rows_meta)
178
+ s = summary(rows)
179
+ res[tag] = dict(file=f, plane=pl, summary=s, episodes=rows)
180
+ for st, v in s.items():
181
+ line = " | ".join(f"{d}: n {v[d]['n']} g {v[d]['grasp']} l {v[d]['lift']} p {v[d]['place']} "
182
+ f"np {v[d]['near_place']} stop {v[d]['carry_stop']} stall {v[d]['stall']}"
183
+ for d in ("R->L", "L->R"))
184
+ print(f"{tag:28s} {st:9s} {line} | ends {v['ends']}")
185
+ Path(sys.argv[1]).write_text(json.dumps(res, indent=1))
186
+
187
+
188
+ if __name__ == "__main__":
189
+ main()
so101_pick_place/code/scripts/so101_pick_place/download.py ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Download the Hub files of the SO101 pick-and-place release and check the size and SHA-256 of every file.
2
+
3
+ python scripts/so101_pick_place/download.py [--groups nrd,teacher,...] [--dest DIR] [--source DIR] [--check-only]
4
+
5
+ The file list, the sizes and the SHA-256 values come from so101_pick_place/release_manifest.json (repository copy).
6
+ Files land in DEST/so101_pick_place/<path> (default DEST = artifacts of this checkout: the code reads its defaults
7
+ there, nedm.so101_policy.paths). A file that is already in place with the right size and SHA-256 is not fetched again.
8
+
9
+ Where the files come from:
10
+ - the Hub (harryzhang1018/NeDM, dataset), at the manifest's pinned "hf_revision" (huggingface_hub.snapshot_download);
11
+ - or a local folder with the layout of the Hub folder so101_pick_place/ (--source DIR, or the environment variable
12
+ SO101_PP_HF_SOURCE): e.g. a release staging folder or an earlier download. Files are hard-linked when the folder is
13
+ on the same file system, else copied. Every file is checked in the same way.
14
+ Without a pinned revision ("PENDING") and without --source, the script only checks the files that are in place.
15
+
16
+ Groups (folders of so101_pick_place/ on the Hub; sizes from the manifest are printed):
17
+ nrd nrd/ the policy NRD c1_s62 and the base NRD c0_s62 (main-compatible best.pt,
18
+ the original files in original/, the training records)
19
+ nrd_test nrd_test/ the sealed scripted NRD test set (3,050 episodes)
20
+ nrd_data nrd_data/ the 4 NRD training data parts (93,494 episodes) + the 7 PPO policies
21
+ teacher teacher/ without t1_expert_data/ teacher checkpoints T0, T2-T6 and their run records
22
+ expert_data teacher/t1_expert_data/ the 24,576 NRD expert episodes behind the BC teacher T2
23
+ student student/ student checkpoints S0-S5 and their run records
24
+ rl_inputs rl_inputs/ task sets, start banks, geometry, the task sets of the sim checks
25
+ results results/ sim-check and robot result files, the NRD test results
26
+ bundle bundle/ the folder installed on the robot computer, and its tarball
27
+ recordings robot/lerobot_recordings/ 2 LeRobot teleop recordings (replay input, camera calibration input)
28
+ robot robot/ robot logs, videos and the recordings
29
+ scene_calib scene_calib/ calibration and scene files (the same bytes as configs/so101_pick_place/)
30
+ provenance provenance/ code snapshots that are in no commit
31
+ card README.md the dataset card of the folder
32
+ all every file
33
+ """
34
+ from __future__ import annotations
35
+
36
+ import argparse
37
+ import hashlib
38
+ import json
39
+ import os
40
+ import re
41
+ import shutil
42
+ import sys
43
+ from pathlib import Path
44
+
45
+ CODE = Path(__file__).resolve().parents[2]
46
+ MANIFEST = CODE / "so101_pick_place" / "release_manifest.json"
47
+ GROUPS = {"nrd": ("nrd/",), "nrd_test": ("nrd_test/",), "nrd_data": ("nrd_data/",), "teacher": ("teacher/",),
48
+ "expert_data": ("teacher/t1_expert_data/",), "student": ("student/",), "rl_inputs": ("rl_inputs/",),
49
+ "results": ("results/",), "bundle": ("bundle/",), "recordings": ("robot/lerobot_recordings/",),
50
+ "robot": ("robot/",), "scene_calib": ("scene_calib/",), "provenance": ("provenance/",),
51
+ "card": ("README.md",), "all": ("",)}
52
+ EXCLUDE = {"teacher": ("teacher/t1_expert_data/",)}
53
+
54
+
55
+ def sha256(path):
56
+ h = hashlib.sha256()
57
+ with open(path, "rb") as f:
58
+ for block in iter(lambda: f.read(1 << 20), b""):
59
+ h.update(block)
60
+ return h.hexdigest()
61
+
62
+
63
+ def select(files, prefix, groups):
64
+ out = {}
65
+ for g in groups:
66
+ if g not in GROUPS:
67
+ sys.exit(f"unknown group {g!r} (groups: {', '.join(GROUPS)})")
68
+ for n, m in files.items():
69
+ rel = n[len(prefix):]
70
+ if rel.startswith(GROUPS[g]) and not rel.startswith(EXCLUDE.get(g, ("\0",))):
71
+ out[n] = m
72
+ return out
73
+
74
+
75
+ def place(src, dst):
76
+ dst.parent.mkdir(parents=True, exist_ok=True)
77
+ if dst.exists() or dst.is_symlink():
78
+ dst.unlink()
79
+ try:
80
+ os.link(src, dst)
81
+ except OSError:
82
+ shutil.copyfile(src, dst)
83
+
84
+
85
+ def main(argv=None):
86
+ p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
87
+ p.add_argument("--groups", default="nrd,teacher,student,rl_inputs,results,bundle,recordings",
88
+ help="comma list (default: what reproduce.sh full needs; see above)")
89
+ p.add_argument("--dest", default=str(CODE / "artifacts"), help="files land in DEST/so101_pick_place/")
90
+ p.add_argument("--source", default=os.environ.get("SO101_PP_HF_SOURCE", ""),
91
+ help="local folder with the layout of the Hub folder so101_pick_place/ (instead of the Hub)")
92
+ p.add_argument("--manifest", default=str(MANIFEST))
93
+ p.add_argument("--check-only", action="store_true", help="only check the files in place")
94
+ p.add_argument("--quiet", action="store_true", help="print only the summary and the bad files")
95
+ a = p.parse_args(argv)
96
+ manifest = json.loads(Path(a.manifest).read_text())
97
+ prefix, dest = manifest["prefix"], Path(a.dest)
98
+ files = select(manifest["files"], prefix, [g for g in a.groups.split(",") if g])
99
+ for n in files:
100
+ if not n.startswith(prefix) or n.startswith("/") or "\\" in n or ".." in n.split("/"):
101
+ sys.exit(f"unsafe path in the manifest: {n}")
102
+ total = sum(m["bytes"] for m in files.values())
103
+ print(f"{len(files)} files, {total / 1e9:.3f} GB (groups {a.groups}) -> {dest / prefix}", flush=True)
104
+ good = lambda n: ((dest / n).is_file() and (dest / n).stat().st_size == files[n]["bytes"]
105
+ and sha256(dest / n) == files[n]["sha256"])
106
+ ok = {n: good(n) for n in sorted(files)}
107
+ missing = [n for n in ok if not ok[n]]
108
+ rev = manifest.get("hf_revision", "")
109
+ pinned = re.fullmatch(r"[0-9a-f]{40}", rev) is not None
110
+ if missing and not a.check_only:
111
+ if a.source:
112
+ src = Path(a.source)
113
+ print(f"{len(missing)} file(s) from the local folder {src} (hard link or copy)", flush=True)
114
+ for n in missing:
115
+ f = src / n[len(prefix):]
116
+ if f.is_file():
117
+ place(f, dest / n)
118
+ elif pinned:
119
+ try:
120
+ from huggingface_hub import snapshot_download
121
+ except ImportError:
122
+ sys.exit(f"{len(missing)} file(s) must be downloaded, and the download needs huggingface_hub "
123
+ "(pip install huggingface_hub); or give --source DIR")
124
+ print(f"download {len(missing)} file(s) from {manifest['repo_id']} at revision {rev}", flush=True)
125
+ snapshot_download(repo_id=manifest["repo_id"], repo_type="dataset", revision=rev, allow_patterns=missing,
126
+ local_dir=str(dest))
127
+ else:
128
+ print(f"hf_revision is {rev!r} (no pinned Hub revision) and no --source: only the check of the files "
129
+ f"in {dest / prefix}", flush=True)
130
+ ok.update({n: good(n) for n in missing})
131
+ for n in ok:
132
+ if not (a.quiet and ok[n]):
133
+ print(f"{'ok ' if ok[n] else 'BAD'} {dest / n}", flush=True)
134
+ bad = [n for n in ok if not ok[n]]
135
+ print(f"{len(ok) - len(bad)} of {len(ok)} files OK (size and SHA-256)", flush=True)
136
+ if bad:
137
+ sys.exit(f"{len(bad)} file(s) missing or with another size or SHA-256")
138
+
139
+
140
+ if __name__ == "__main__":
141
+ main()
so101_pick_place/code/scripts/so101_pick_place/nrd/equiv.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Rollouts and task metrics of one checkpoint with one code tree, for the original-vs-released check.
2
+
3
+ Per data folder (all its episodes): (1) a 100-step rollout from the first recorded state, (2) a 100-step rollout
4
+ from the recorded 4-state history at model step 100 (the grasp / carry part of the episode), both with the recorded
5
+ commands and with the contact switches; (3) data.evaluate(by_family=True), the task metrics of training and test.
6
+ Every tensor goes to OUT.pt, the evaluate reports to OUT.json. The code tree's own load_model, load_data and
7
+ step_average_rates are used.
8
+
9
+ python -I equiv.py CODE_SRC_DIR CKPT DEVICE OUT_PREFIX NAME=DATA_DIR [NAME=DATA_DIR ...]
10
+
11
+ Release check of the SO101 pick-and-place study (so101_pick_place/README.md, "The NRD"; reproduce.sh steps
12
+ nrd_val, nrd_strip).
13
+ """
14
+ import json
15
+ import sys
16
+ import time
17
+
18
+
19
+ def main():
20
+ src, ckpt, device, out = sys.argv[1:5]
21
+ sys.path.insert(0, src)
22
+ import torch
23
+ torch.set_num_threads(8)
24
+ from nedm.contact_nrd import data as D, model as M
25
+ model, packet = M.load_model(ckpt, device)
26
+ kinds = set(model.config["integrate"]["kinds"])
27
+ tensors, reports, info = {}, {}, dict(code=M.__file__, ckpt=ckpt, device=device, torch=torch.__version__)
28
+ for item in sys.argv[5:]:
29
+ name, root = item.split("=", 1)
30
+ t0 = time.time()
31
+ data = D.load_data(root, device, model_step_s=model.dt)
32
+ data = D.step_average_rates(data, kinds)
33
+ s = data["stride"]
34
+ st, act = data["states"][:, ::s], data["actions"][:, ::s]
35
+ with torch.no_grad():
36
+ traj, gates = model.rollout(st[:, 0], act[:, :100], return_gates=True)
37
+ k0 = 100
38
+ hist = st[:, k0 - model.k + 1:k0 + 1]
39
+ ok = torch.ones(hist.shape[:2], dtype=torch.bool, device=hist.device)
40
+ traj2, gates2 = model.rollout_from(hist, ok, act[:, k0:k0 + 100], return_gates=True)
41
+ rep = D.evaluate(model, data, torch.arange(len(data["lengths"]), device=device), by_family=True)
42
+ tensors[name] = dict(first_state=traj.cpu(), first_state_gates=gates.cpu(), mid=traj2.cpu(), mid_gates=gates2.cpu())
43
+ reports[name] = rep
44
+ info[name] = dict(episodes=int(len(data["lengths"])), seconds=round(time.time() - t0, 1),
45
+ selection_score=rep.get("selection_score"))
46
+ print(name, json.dumps(info[name]), flush=True)
47
+ torch.save(tensors, out + ".pt")
48
+ with open(out + ".json", "w") as f:
49
+ json.dump(dict(info=info, reports=reports), f, default=float)
50
+
51
+
52
+ if __name__ == "__main__":
53
+ main()
so101_pick_place/code/scripts/so101_pick_place/nrd/equiv_compare.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Compare equiv.py outputs of the original file in the training code and the released file in main's code.
2
+
3
+ python -I equiv_compare.py OUT.json A_PREFIX B_PREFIX [A_PREFIX B_PREFIX ...]
4
+
5
+ Per pair: every rollout tensor bit for bit (raw float64 bytes), the max abs difference, and the evaluate reports
6
+ as canonical JSON (sorted keys) for exact equality.
7
+
8
+ Release check of the SO101 pick-and-place study (so101_pick_place/README.md, "The NRD"; reproduce.sh steps
9
+ nrd_val, nrd_strip).
10
+ """
11
+ import json
12
+ import sys
13
+
14
+ import torch
15
+
16
+
17
+ def main():
18
+ out, pairs = sys.argv[1], sys.argv[2:]
19
+ rows = []
20
+ for a, b in zip(pairs[::2], pairs[1::2]):
21
+ ta, tb = torch.load(a + ".pt", weights_only=True), torch.load(b + ".pt", weights_only=True)
22
+ ja, jb = json.load(open(a + ".json")), json.load(open(b + ".json"))
23
+ for name in ta:
24
+ row = dict(a=a, b=b, data=name, episodes=ja["info"][name]["episodes"])
25
+ for k in ta[name]:
26
+ x, y = ta[name][k], tb[name][k]
27
+ row[k] = dict(shape=list(x.shape), bitwise_equal=bool(
28
+ x.dtype == y.dtype and x.shape == y.shape
29
+ and torch.equal(x.contiguous().view(-1).view(torch.uint8), y.contiguous().view(-1).view(torch.uint8))),
30
+ max_abs_diff=float((x.double() - y.double()).abs().nan_to_num(0).max()))
31
+ ca = json.dumps(ja["reports"][name], sort_keys=True)
32
+ cb = json.dumps(jb["reports"][name], sort_keys=True)
33
+ row["evaluate_json_equal"] = ca == cb
34
+ row["selection_score"] = [ja["reports"][name]["selection_score"], jb["reports"][name]["selection_score"]]
35
+ rows.append(row)
36
+ print(name, a.split("/")[-1], "vs", b.split("/")[-1], {k: row[k]["bitwise_equal"] for k in ta[name]},
37
+ "evaluate equal", row["evaluate_json_equal"], flush=True)
38
+ ok = all(r["evaluate_json_equal"] and all(v["bitwise_equal"] for k, v in r.items() if isinstance(v, dict))
39
+ for r in rows)
40
+ with open(out, "w") as f:
41
+ json.dump(dict(all_equal=ok, rows=rows), f, indent=1)
42
+ print("ALL EQUAL" if ok else "DIFFERENCES FOUND")
43
+
44
+
45
+ if __name__ == "__main__":
46
+ main()
so101_pick_place/code/scripts/so101_pick_place/nrd/strip_ckpt.py ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Make a contact NRD checkpoint that origin/main's nedm.contact_nrd.model.load_model accepts, from a checkpoint of
2
+ the SO101 study's training code (commit f6f05c21c). The study trained with a training-only geometry loss: the
3
+ model_config key ``aux_geometry`` and two heads ``geo_collision`` / ``geo_contact`` (Linear 128 -> 12 each) that the
4
+ step never uses. This script removes exactly these: the key from the top-level ``model_config`` and the 4 tensors
5
+ ``geo_collision.{weight,bias}``, ``geo_contact.{weight,bias}`` from ``model_state_dict``. Every other entry (also
6
+ the training record ``runtime``, ``validation``, ``sigma``, ``stage``, ``update``) is kept unchanged and in the same
7
+ order. Then it reloads the new file and checks every kept entry against the original bit for bit (tensors: dtype,
8
+ shape and raw bytes; other values: exact equality).
9
+
10
+ python -I strip_ckpt.py SRC.pt DST.pt REPORT.json [EXPECTED.pt]
11
+
12
+ EXPECTED.pt (e.g. the released main-compatible best.pt): the new file is compared with it, by bytes and, if the bytes
13
+ differ, entry by entry as above. The bytes depend on the torch version (zip layout) and on the output file name (the
14
+ zip folder name inside the file): the release files were written by torch 2.12.0 under the name best.pt.
15
+
16
+ Release check of the SO101 pick-and-place study (so101_pick_place/README.md, "The NRD"); used by
17
+ scripts/so101_pick_place/reproduce.sh, step nrd_strip.
18
+ """
19
+ import hashlib
20
+ import json
21
+ import math
22
+ import os
23
+ import sys
24
+ from collections import OrderedDict
25
+
26
+ import torch
27
+
28
+ GEO = ("geo_collision.", "geo_contact.")
29
+
30
+
31
+ def sha256(path):
32
+ h = hashlib.sha256()
33
+ with open(path, "rb") as f:
34
+ for b in iter(lambda: f.read(1 << 20), b""):
35
+ h.update(b)
36
+ return h.hexdigest()
37
+
38
+
39
+ def load(path):
40
+ torch.serialization.add_safe_globals([torch.torch_version.TorchVersion])
41
+ return torch.load(path, map_location="cpu", weights_only=True)
42
+
43
+
44
+ def same(a, b, where, bad):
45
+ """Exact equality; tensors by dtype, shape and raw bytes; floats NaN-aware; dict key order too."""
46
+ if torch.is_tensor(a) or torch.is_tensor(b):
47
+ ok = (torch.is_tensor(a) and torch.is_tensor(b) and a.dtype == b.dtype and a.shape == b.shape
48
+ and torch.equal(a.contiguous().view(-1).view(torch.uint8), b.contiguous().view(-1).view(torch.uint8)))
49
+ if not ok:
50
+ bad.append(where)
51
+ return
52
+ if type(a) is not type(b):
53
+ bad.append(f"{where} (type {type(a).__name__} vs {type(b).__name__})")
54
+ return
55
+ if isinstance(a, dict):
56
+ if list(a.keys()) != list(b.keys()):
57
+ bad.append(f"{where} (keys/order)")
58
+ return
59
+ for k in a:
60
+ same(a[k], b[k], f"{where}/{k}", bad)
61
+ ma, mb = getattr(a, "_metadata", None), getattr(b, "_metadata", None)
62
+ if ma is not None or mb is not None:
63
+ same(dict(ma or {}), dict(mb or {}), f"{where}/_metadata", bad)
64
+ return
65
+ if isinstance(a, (list, tuple)):
66
+ if len(a) != len(b):
67
+ bad.append(f"{where} (length)")
68
+ return
69
+ for i, (x, y) in enumerate(zip(a, b)):
70
+ same(x, y, f"{where}[{i}]", bad)
71
+ return
72
+ if isinstance(a, float) and math.isnan(a) and math.isnan(b):
73
+ return
74
+ if a != b:
75
+ bad.append(where)
76
+
77
+
78
+ def main():
79
+ src, dst, report = sys.argv[1:4]
80
+ p = load(src)
81
+ sd = p["model_state_dict"]
82
+ removed = [k for k in sd if k.startswith(GEO)]
83
+ assert sorted(removed) == sorted(["geo_collision.weight", "geo_collision.bias", "geo_contact.weight",
84
+ "geo_contact.bias"]), removed
85
+ assert p["model_config"].get("aux_geometry") is True, p["model_config"]
86
+ new_sd = OrderedDict((k, v) for k, v in sd.items() if not k.startswith(GEO))
87
+ meta = getattr(sd, "_metadata", None)
88
+ if meta is not None: # per-module version records of state_dict(); drop the two removed modules' entries
89
+ new_sd._metadata = OrderedDict((k, v) for k, v in meta.items() if k not in ("geo_collision", "geo_contact"))
90
+ new = {}
91
+ for k, v in p.items():
92
+ if k == "model_config":
93
+ new[k] = {kk: vv for kk, vv in v.items() if kk != "aux_geometry"}
94
+ elif k == "model_state_dict":
95
+ new[k] = new_sd
96
+ else:
97
+ new[k] = v
98
+ torch.save(new, dst)
99
+
100
+ # check: reload both files from disk and compare everything that was kept
101
+ a, b = load(src), load(dst)
102
+ bad = []
103
+ if list(a.keys()) != list(b.keys()):
104
+ bad.append("top-level keys/order")
105
+ for k in a:
106
+ if k == "model_config":
107
+ same({kk: vv for kk, vv in a[k].items() if kk != "aux_geometry"}, b[k], k, bad)
108
+ if "aux_geometry" in b[k]:
109
+ bad.append("model_config still has aux_geometry")
110
+ elif k == "model_state_dict":
111
+ kept = OrderedDict((kk, vv) for kk, vv in a[k].items() if not kk.startswith(GEO))
112
+ ma = getattr(a[k], "_metadata", None)
113
+ if ma is not None:
114
+ kept._metadata = OrderedDict((kk, vv) for kk, vv in ma.items()
115
+ if kk not in ("geo_collision", "geo_contact"))
116
+ same(kept, b[k], k, bad)
117
+ if any(kk.startswith(GEO) for kk in b[k]):
118
+ bad.append("geo tensors still present")
119
+ else:
120
+ same(a[k], b[k], k, bad)
121
+ out = dict(source=src, source_bytes=int(os.path.getsize(src)), source_sha256=sha256(src),
122
+ released=dst, released_bytes=int(os.path.getsize(dst)), released_sha256=sha256(dst),
123
+ removed_model_config_keys=["aux_geometry"], removed_tensors=removed,
124
+ removed_parameters=int(sum(sd[k].numel() for k in removed)),
125
+ kept_tensors=len(b["model_state_dict"]), kept_parameters=int(sum(t.numel() for t in b["model_state_dict"].values())),
126
+ state_dict_metadata=meta is not None,
127
+ unchanged_entries=[k for k in a if k not in ("model_config", "model_state_dict")],
128
+ note="runtime (the training record) is unchanged: it still lists aux_geometry in runtime.model_config "
129
+ "and runtime.config, and runtime.parameters counts the removed heads",
130
+ mismatches=bad, all_kept_entries_equal=not bad, torch=torch.__version__)
131
+ if len(sys.argv) > 4: # compare with an expected file (the released main-compatible one)
132
+ exp = sys.argv[4]
133
+ out.update(expected=exp, expected_sha256=sha256(exp), bytes_equal_to_expected=sha256(exp) == out["released_sha256"])
134
+ if not out["bytes_equal_to_expected"]:
135
+ bad_exp = []
136
+ same(load(exp), b, "expected", bad_exp)
137
+ out["entries_equal_to_expected"] = not bad_exp
138
+ out["mismatches_to_expected"] = bad_exp
139
+ bad += [f"expected: {m}" for m in bad_exp]
140
+ with open(report, "w") as f:
141
+ json.dump(out, f, indent=1)
142
+ print(json.dumps({k: v for k, v in out.items() if k not in ("unchanged_entries",)}, indent=1))
143
+ if bad:
144
+ sys.exit(1)
145
+
146
+
147
+ if __name__ == "__main__":
148
+ main()
so101_pick_place/code/scripts/so101_pick_place/nrd/subsets.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Copy N episodes of one split (default splits == 1, the validation episodes; evenly spaced over the rows of that
2
+ split) of each NRD data part into a small data folder (unified_data.npz with every per-episode array sliced,
3
+ system.json copied). N = 0: every episode of the split. --split family: the first N train and the first N validation
4
+ episodes of every family (smoke training runs need both splits in every family).
5
+
6
+ python -I subsets.py OUT N [--split 1|2|family] name=PART_DIR [name=PART_DIR ...]
7
+
8
+ Release checks of the SO101 pick-and-place study (so101_pick_place/README.md, "The NRD"; reproduce.sh steps nrd_val,
9
+ nrd_strip and the smoke of nrd_train). The release used: N = 64 of each of the 4 parts (original-vs-main check) and
10
+ N = 0 of production_plus (2,853 validation episodes, the validation columns of the README).
11
+ """
12
+ import hashlib
13
+ import json
14
+ import shutil
15
+ import sys
16
+ from pathlib import Path
17
+
18
+ import numpy as np
19
+
20
+
21
+ def sha256(path):
22
+ h = hashlib.sha256()
23
+ with open(path, "rb") as f:
24
+ for b in iter(lambda: f.read(1 << 24), b""):
25
+ h.update(b)
26
+ return h.hexdigest()
27
+
28
+
29
+ def main():
30
+ out_root, n = Path(sys.argv[1]), int(sys.argv[2])
31
+ args, split = sys.argv[3:], "1"
32
+ if args[:1] == ["--split"]:
33
+ split, args = args[1], args[2:]
34
+ record = {}
35
+ for item in args:
36
+ name, src = item.split("=", 1)
37
+ src = Path(src)
38
+ out = out_root / name
39
+ out.mkdir(parents=True, exist_ok=True)
40
+ with np.load(src / "unified_data.npz") as p:
41
+ files = list(p.files)
42
+ splits = p["splits"]
43
+ total = len(splits)
44
+ if split == "family":
45
+ fam_all = p["family"]
46
+ val = np.sort(np.concatenate([np.flatnonzero((fam_all == f) & (splits == sp))[:n]
47
+ for f in np.unique(fam_all) for sp in (0, 1)]))
48
+ pick = val
49
+ else:
50
+ val = np.flatnonzero(splits == int(split))
51
+ pick = val if n == 0 or n >= len(val) else val[np.linspace(0, len(val) - 1, n).round().astype(np.int64)]
52
+ assert len(np.unique(pick)) == len(pick), "not enough episodes"
53
+ arrays = {}
54
+ for k in files: # one array at a time (the large parts are several GB)
55
+ a = p[k]
56
+ if a.ndim == 0 or a.shape[0] != total:
57
+ raise ValueError(f"{src}: array {k} {a.shape} is not per episode")
58
+ arrays[k] = np.ascontiguousarray(a[pick])
59
+ del a
60
+ np.savez(out / "unified_data.npz", **arrays)
61
+ shutil.copy2(src / "system.json", out / "system.json")
62
+ fam = arrays.get("family")
63
+ families = [f["name"] for f in json.loads((src / "system.json").read_text()).get("families", [])]
64
+ record[name] = dict(source=str(src), source_npz_sha256=sha256(src / "unified_data.npz"),
65
+ source_episodes=int(total), split=split, source_split_episodes=int(len(val)),
66
+ rows=pick.tolist(), subset_npz_sha256=sha256(out / "unified_data.npz"),
67
+ families={families[int(f)]: int(c) for f, c in zip(*np.unique(fam, return_counts=True))}
68
+ if fam is not None else None)
69
+ print(name, total, "episodes,", len(val), f"in split {split}, picked", len(pick), record[name]["families"], flush=True)
70
+ (out_root / "subsets.json").write_text(json.dumps(record, indent=1))
71
+
72
+
73
+ if __name__ == "__main__":
74
+ main()
so101_pick_place/code/scripts/so101_pick_place/nrd/summarize.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Table of the task metrics (data.evaluate reports) of the SO101 NRDs: validation reports of the training runs and
2
+ reports of origin/main's `python -m nedm.contact_nrd.test` (validation re-score and sealed test).
3
+
4
+ python -I summarize.py OUT_PREFIX LABEL=FILE[:MODEL][@GROUP] ...
5
+
6
+ FILE: a training validation.json (MODEL empty) or a test.py --output JSON (MODEL = the --model name).
7
+ GROUP: selected (default), all, or a family name. Writes OUT_PREFIX.json and OUT_PREFIX.md.
8
+
9
+ Release check of the SO101 pick-and-place study (so101_pick_place/README.md, "The NRD"; reproduce.sh steps
10
+ nrd_val, nrd_strip).
11
+ """
12
+ import json
13
+ import math
14
+ import sys
15
+
16
+ ROWS = [ # label, path in the report, scale, format
17
+ ("episodes", ("episodes",), 1, "{:.0f}"),
18
+ ("1 s windows: cube position p50 (mm)", ("windows", "1.0", "cube", "pos_m", "median"), 1e3, "{:.2f}"),
19
+ ("1 s windows: cube position p95 (mm)", ("windows", "1.0", "cube", "pos_m", "p95"), 1e3, "{:.2f}"),
20
+ ("1 s windows: cube angle p50 (deg)", ("windows", "1.0", "cube", "angle_rad", "median"), 180 / math.pi, "{:.2f}"),
21
+ ("1 s windows: cube angle p95 (deg)", ("windows", "1.0", "cube", "angle_rad", "p95"), 180 / math.pi, "{:.2f}"),
22
+ ("1 s windows: arm joint RMS p95 (mrad)", ("windows", "1.0", "arm", "joint_rms_rad", "p95"), 1e3, "{:.2f}"),
23
+ ("1 s windows (count)", ("windows", "1.0", "windows"), 1, "{:.0f}"),
24
+ ("4 s from the first state: cube position p50 (mm)", ("free", "target", "cube", "pos_m", "median"), 1e3, "{:.2f}"),
25
+ ("4 s from the first state: cube position p95 (mm)", ("free", "target", "cube", "pos_m", "p95"), 1e3, "{:.2f}"),
26
+ ("4 s from the first state: cube angle p95 (deg)", ("free", "target", "cube", "angle_rad", "p95"), 180 / math.pi, "{:.2f}"),
27
+ ("4 s path RMS of the cube p95 (mm)", ("free", "path_rmse_m", "p95"), 1e3, "{:.2f}"),
28
+ ("contact events: wrong per recorded event", ("free", "contacts", "all", "event_error_rate"), 1, "{:.3f}"),
29
+ ("contact switch accuracy", ("free", "contacts", "all", "gate_accuracy"), 1, "{:.4f}"),
30
+ ("lifted: disagreement (%)", ("free", "flags", "lifted", "disagreement"), 100, "{:.2f}"),
31
+ ("dropped: disagreement (%)", ("free", "flags", "dropped", "disagreement"), 100, "{:.2f}"),
32
+ ("finite rollouts", ("finite_fraction",), 1, "{:.4f}"),
33
+ ("selection score (lower is better)", ("selection_score",), 1, "{:.3f}"),
34
+ ]
35
+
36
+
37
+ def dig(x, path):
38
+ for p in path:
39
+ if not isinstance(x, dict) or p not in x:
40
+ return None
41
+ x = x[p]
42
+ return x
43
+
44
+
45
+ def group_of(report, group):
46
+ if group == "all":
47
+ return report
48
+ if group == "selected":
49
+ return report.get("selected")
50
+ return (report.get("families") or {}).get(group)
51
+
52
+
53
+ def main():
54
+ out = sys.argv[1]
55
+ cols, cache = [], {}
56
+ for item in sys.argv[2:]:
57
+ label, spec = item.split("=", 1)
58
+ spec, group = (spec.split("@", 1) + ["selected"])[:2]
59
+ path, model = (spec.split(":", 1) + [""])[:2]
60
+ if path not in cache:
61
+ cache[path] = json.load(open(path))
62
+ rep = cache[path]["models"][model] if model else cache[path]
63
+ g = group_of(rep, group)
64
+ cols.append((label, path, model, group, g))
65
+ table = {}
66
+ for name, path, scale, fmt in ROWS:
67
+ table[name] = {}
68
+ for label, _, _, _, g in cols:
69
+ v = dig(g, path) if g is not None else None
70
+ table[name][label] = None if v is None else v * scale
71
+ families = {}
72
+ for label, path, model, group, _ in cols:
73
+ rep = cache[path]["models"][model] if model else cache[path]
74
+ for fam, block in (rep.get("families") or {}).items():
75
+ v = dig(block, ("windows", "1.0", "cube", "pos_m", "p95"))
76
+ families.setdefault(fam, {})[label] = None if v is None else 1e3 * v
77
+ lines = ["| Metric | " + " | ".join(c[0] for c in cols) + " |", "|---|" + "---|" * len(cols)]
78
+ for name, path, scale, fmt in ROWS:
79
+ lines.append(f"| {name} | " + " | ".join("-" if table[name][c[0]] is None else fmt.format(table[name][c[0]])
80
+ for c in cols) + " |")
81
+ lines += ["", "1 s windows, cube position p95 (mm) per family (whole report of each column):", "",
82
+ "| Family | " + " | ".join(c[0] for c in cols) + " |", "|---|" + "---|" * len(cols)]
83
+ for fam, vals in families.items():
84
+ lines.append(f"| {fam} | " + " | ".join("-" if vals.get(c[0]) is None else f"{vals[c[0]]:.2f}" for c in cols) + " |")
85
+ open(out + ".md", "w").write("\n".join(lines) + "\n")
86
+ json.dump(dict(columns=[dict(label=c[0], file=c[1], model=c[2], group=c[3]) for c in cols], metrics=table,
87
+ family_cube_pos_1s_p95_mm=families), open(out + ".json", "w"), indent=1)
88
+ print("\n".join(lines))
89
+
90
+
91
+ if __name__ == "__main__":
92
+ main()
so101_pick_place/code/scripts/so101_pick_place/reproduce.sh ADDED
@@ -0,0 +1,872 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # =====================================================================================================================
3
+ # scripts/so101_pick_place/reproduce.sh: the SO101 pick-and-place chain NRD -> state teacher (PPO in the NRD) ->
4
+ # camera student (online DAgger in the NRD with ray-traced images) -> sim checks -> robot bundle
5
+ # (so101_pick_place/README.md).
6
+ #
7
+ # A real SO101 arm picks a 30 mm cube and places it on a plate. Every training step of every policy ran inside the
8
+ # NRD below; no real image was a training sample. This script repeats the steps from the released files; the robot
9
+ # test itself is a manual step on the robot computer (README "Deploy").
10
+ #
11
+ # NRD (every teacher and student step below runs in it)
12
+ # Hub harryzhang1018/NeDM (dataset), so101_pick_place/nrd/c1_s62/best.pt at the revision pinned in
13
+ # so101_pick_place/release_manifest.json; sha256 2d1a24926d463c5432a8dcb6897c05fe1082f04095c773ec914dd53986d66abc
14
+ # (10,893,663 bytes). Main's nedm.contact_nrd.model.load_model loads it with no code change: it is the
15
+ # study's file (original/best.pt, sha256 f45ee8be...) with the two training-only geometry heads removed;
16
+ # its rollouts are bit-identical to the original's in the training code (README "The NRD").
17
+ # Base so101_pick_place/nrd/c0_s62/ (the start weights of c1_s62; the same layout).
18
+ # Data so101_pick_place/nrd_data/{production_plus,noisy_v1,expert_v2,policy_v3}/ (10.6 GB, --with-nrd-data);
19
+ # sealed test so101_pick_place/nrd_test/ (3,050 scripted episodes, 0.34 GB).
20
+ #
21
+ # Steps (each step reads the released parents unless --parents own and this script's own run exists in OUT/runs)
22
+ # setup contact_nrd/so101_grasp/fetch_sources.py: the MuJoCo Menagerie SO101 model at the pinned revision
23
+ # (vendor/, 27 MB; needs git and github.com); exact
24
+ # download scripts/so101_pick_place/download.py: the Hub files (size + sha256 of every file); --hf-source DIR
25
+ # (or SO101_PP_HF_SOURCE) takes them from a local folder with the Hub layout instead of the Hub
26
+ # geometry kin.save_points and TaskGeometry.from_mujoco rebuild rl_inputs/geometry/ (exact)
27
+ # nrd main's load_model on both NRDs; a 100-step rollout of 4 test episodes; the sha256 of the files
28
+ # nrd_collect the collector (nedm.contact_nrd.collect.so101_grasp) regenerates the first episode of every family
29
+ # of nrd_test/ and compares the arrays (exact); chain: the 4 scripted campaigns in full, their episode
30
+ # counts compared with the released manifests
31
+ # nrd_train base NRD and fine-tune with the training code of commit f6f05c21c (branch so101-pick-place-study;
32
+ # a git worktree under OUT; main's train.py lacks its options); needs --with-nrd-data. Smoke: --smoke
33
+ # runs of the training code on 4 train + 4 validation episodes of every family of each data part
34
+ # nrd_strip scripts/so101_pick_place/nrd/strip_ckpt.py: the main-compatible file of an NRD of the training code
35
+ # (geometry heads removed). Released originals: the result is compared with the released best.pt. Own
36
+ # nrd_train runs: OUT/nrd_main/<run>/best.pt; with --parents own the policy stages then run in the own
37
+ # c1. With commit f6f05c21c present: the original in the training code vs the new file in main's code
38
+ # (equiv.py: 100-step rollouts, contact switches, task metrics; validation episodes of the 4 data parts
39
+ # with --with-nrd-data, else test episodes)
40
+ # nrd_test main's python -m nedm.contact_nrd.test on nrd_test/ (smoke: 2 episodes per family), next to the
41
+ # released results/nrd/sealed_test.json (the README numbers); also the own NRDs of nrd_strip
42
+ # nrd_val (--with-nrd-data) main's python -m nedm.contact_nrd.test on the validation episodes (split 1) of
43
+ # production_plus, then the validation / sealed-test table of the README (scripts/so101_pick_place/nrd/)
44
+ # t0 .. t6 the teacher stages (README "Training chain"): t0 decoder PPO from scratch (train_ppo.py), t1 expert
45
+ # data, t2 behaviour cloning, t3 / t4 joint-target PPO, t5 / t6 the robot-round fine-tunes
46
+ # s0 .. s5 the student stages: s0 offline rounds from ImageNet ResNet18, s1 .. s5 online DAgger
47
+ # simcheck scripts/so101_pick_place/check/run_gates.sh on the released (or own) tb10 and on D; gates_summary
48
+ # bundle scripts/so101_policy/real2sim/hw/make_orin_bundle.sh -> OUT/bundle/so101_hw_v13_tb10, compared with the
49
+ # released bundle (MANIFEST.txt)
50
+ # fake the bundle on this machine with a fake robot (no device opened): robot_test.sh check, eval 1 6 and
51
+ # replay of 3 recordings; the replay is repeated with the released bundle and the action chunks are
52
+ # compared
53
+ # robot (--with-robot) the robot result tables from the released logs (build_results.py), next to the
54
+ # released results.json
55
+ # summary the numbers of this run next to the released ones
56
+ #
57
+ # Modes
58
+ # smoke every step of full with tiny sizes (about 5 min on one RTX 5090 once the files are local): a setup check
59
+ # full setup, download, geometry, nrd, nrd_collect, nrd_strip, nrd_test, t6, s5, simcheck, bundle, fake, summary
60
+ # (default): the last teacher and student stages from the released parents (T5, S4), the sim checks, the
61
+ # bundle. About 2 GPU-h (t6 0.8, s5 0.5 + its in-run evaluations, simcheck 21 evaluations) + CPU
62
+ # chain every stage from scratch: nrd_collect (full), nrd_train, nrd_strip, nrd_val, t0 .. t6, s0 .. s5, simcheck,
63
+ # bundle, fake. About 22 GPU-h on one MI350X / MI300X per job (README table); a cluster is advised. Needs
64
+ # --with-nrd-data (and the expert data come from t1; --with-expert-data downloads the released ones). The
65
+ # policy stages run in the own NRD c1 of nrd_train / nrd_strip (else in the released one)
66
+ #
67
+ # Options
68
+ # --steps LIST comma list of steps (default: those of the mode). Without download no file is fetched or checked
69
+ # --out DIR outputs (default artifacts/so101_pick_place_repro; smoke: a new smoke_<time> folder in it)
70
+ # --hf-source DIR take the Hub files from DIR (a folder with the layout of the Hub folder so101_pick_place/)
71
+ # --parents own|released start each stage from this script's parent run (own) or from the released parent
72
+ # (default released; chain: own)
73
+ # --device DEV torch device (default cuda)
74
+ # --workers N CPU MuJoCo worker processes of the evaluations (default 8)
75
+ # --with-nrd-data also download the 4 NRD data parts (10.6 GB; nrd_val / nrd_train and t1 need them; t0 uses
76
+ # the 28 MB start bank rl_inputs/banks/bank_pp_s0.npz)
77
+ # --with-expert-data also download the released expert data of t1 (0.83 GB; t2 with --parents released)
78
+ # --with-robot also download the robot logs and videos (1.15 GB; robot step)
79
+ # Environment
80
+ # PY Python with torch, torchvision, numpy, scipy, mujoco 3.15.0, warp-lang 1.13.0, newton 1.2.0,
81
+ # huggingface_hub (default python3); requirements-so101-pick-place.txt. The renderer needs an
82
+ # NVIDIA GPU with CUDA (or the ROCm build of Warp on AMD GPUs)
83
+ # SO101_PP_HF_SOURCE default of --hf-source
84
+ # Files: all data go to artifacts/so101_pick_place of this checkout (nedm.so101_policy.paths: the code reads its
85
+ # defaults there; link artifacts/ to another disk if needed). Run records: OUT/runs/<stage>/.
86
+ # =====================================================================================================================
87
+ set -euo pipefail
88
+
89
+ CODE="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
90
+ PY="${PY:-python3}"
91
+ MODE=full
92
+ STEPS=""
93
+ OUT=""
94
+ SOURCE="${SO101_PP_HF_SOURCE:-}"
95
+ PARENTS=""
96
+ DEVICE=cuda
97
+ WORKERS=8
98
+ WITH_NRD_DATA=0
99
+ WITH_EXPERT=0
100
+ WITH_ROBOT=0
101
+
102
+ die() { echo "reproduce.sh: $*" >&2; exit 1; }
103
+ log() { echo "[reproduce $(date +%H:%M:%S)] $*"; }
104
+
105
+ while [ $# -gt 0 ]; do
106
+ case "$1" in
107
+ full|smoke|chain) MODE="$1" ;;
108
+ --steps) STEPS="$2"; shift ;;
109
+ --out) OUT="$2"; shift ;;
110
+ --hf-source) SOURCE="$2"; shift ;;
111
+ --parents) PARENTS="$2"; shift ;;
112
+ --device) DEVICE="$2"; shift ;;
113
+ --workers) WORKERS="$2"; shift ;;
114
+ --with-nrd-data) WITH_NRD_DATA=1 ;;
115
+ --with-expert-data) WITH_EXPERT=1 ;;
116
+ --with-robot) WITH_ROBOT=1 ;;
117
+ -h|--help) sed -n '3,/^# =====/p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
118
+ *) die "unknown argument $1 (see --help)" ;;
119
+ esac
120
+ shift
121
+ done
122
+
123
+ ALL_STEPS="setup download geometry nrd nrd_collect nrd_train nrd_strip nrd_test nrd_val t0 t1 t2 t3 t4 t5 t6 s0 s1 s2 s3 s4 s5 simcheck bundle fake robot summary"
124
+ case "$MODE" in
125
+ full) : "${STEPS:=setup,download,geometry,nrd,nrd_test,nrd_strip,nrd_collect,t6,s5,simcheck,bundle,fake,summary}" "${PARENTS:=released}" ;;
126
+ smoke) : "${STEPS:=setup,download,geometry,nrd,nrd_test,nrd_strip,nrd_collect,t6,s5,simcheck,bundle,fake,summary}" "${PARENTS:=released}" ;;
127
+ chain) : "${STEPS:=setup,download,nrd_collect,nrd_train,nrd_strip,nrd_val,t0,t1,t2,t3,t4,t5,t6,s0,s1,s2,s3,s4,s5,simcheck,bundle,fake,summary}" "${PARENTS:=own}" ;;
128
+ esac
129
+ case "$PARENTS" in own|released) ;; *) die "--parents must be own or released" ;; esac
130
+ [ "$WITH_ROBOT" = 1 ] && [[ ",$STEPS," != *",robot,"* ]] && STEPS="$STEPS,robot"
131
+ [[ ",$STEPS," == *",robot,"* ]] && WITH_ROBOT=1 # the robot step needs the robot logs in the download
132
+ for s in ${STEPS//,/ }; do [[ " $ALL_STEPS " == *" $s "* ]] || die "unknown step $s ($ALL_STEPS)"; done
133
+ has_step() { case ",$STEPS," in *",$1,"*) return 0 ;; *) return 1 ;; esac; }
134
+
135
+ OUT="${OUT:-$CODE/artifacts/so101_pick_place_repro}"
136
+ [ "$MODE" = smoke ] && OUT="$OUT/smoke_$(date +%m%d_%H%M%S)"
137
+ A="$CODE/artifacts/so101_pick_place" # the Hub folder so101_pick_place/ after the download
138
+ mkdir -p "$OUT" "$A"
139
+ OUT="$(cd "$OUT" && pwd)"
140
+ RUNS="$OUT/runs"
141
+ TINY=0; [ "$MODE" = smoke ] && TINY=1
142
+ export PYTHONPATH="$CODE/src${PYTHONPATH:+:$PYTHONPATH}" PYTHONUNBUFFERED=1
143
+ cd "$CODE"
144
+ mkdir -p "$RUNS" "$OUT/configs" "$OUT/tasks"
145
+ log "mode $MODE, steps $STEPS, parents $PARENTS, out $OUT, data $A${SOURCE:+, Hub files from $SOURCE}"
146
+
147
+ # ---------------------------------------------------------------------------------------------------- inputs
148
+ NRD=$A/nrd/c1_s62/best.pt
149
+ T=$A/rl_inputs/tasks
150
+ B=$A/rl_inputs/banks
151
+ SCENE=$CODE/configs/so101_pick_place/real_scene_v2.json # sha256 4bce0b8d... (pinned in every student)
152
+ CALIB=$CODE/configs/so101_pick_place/calib_v1.json # sha256 3b7a2124... (pinned in every student)
153
+ # the scene file names the study's home path of the calibration: every student run passes both (as the runs did)
154
+ SETS=(jaw_lead=0 "scene=\"$SCENE\"" "calib=\"$CALIB\"")
155
+ REL_T=(t0:teacher/t0_nC1_s62_b/model_00171.pt t2:teacher/t2_bc_all/bc.pt t3:teacher/t3_jt_b140/model_00140.pt
156
+ t4:teacher/t4_jt_h110/model_00110.pt t5:teacher/t5_tppo_roll_v8_s21/model_00200.pt
157
+ t6:teacher/t6_tppo_v12_fr10_s122/model_00200.pt s0:student/s0_v2_start_s2/r2/last.pt
158
+ s1:student/s1_v2_online_s18/it_03000.pt s2:student/s2_v2_online2_s28/it_03000.pt
159
+ s3:student/s3_v4_relabel_s63/it_02000.pt s4:student/s4_v8_roll_s801/it_02000.pt
160
+ s5:student/s5_v12_tb10_s1210/it_01000.pt)
161
+ OWN_T=(t0:t0_nC1_s62_b/ckpt/model_00171.pt t2:t2_bc_all/bc.pt t3:t3_jt_b140/ckpt/model_00140.pt
162
+ t4:t4_jt_h110/ckpt/model_00110.pt t5:t5_tppo_roll_v8_s21/ckpt/model_00200.pt
163
+ t6:t6_tppo_v12_fr10_s122/ckpt/model_00200.pt s0:s0_v2_start_s2/r2/last.pt s1:s1_v2_online_s18/ckpt/it_03000.pt
164
+ s2:s2_v2_online2_s28/ckpt/it_03000.pt s3:s3_v4_relabel_s63/ckpt/it_02000.pt s4:s4_v8_roll_s801/ckpt/it_02000.pt
165
+ s5:s5_v12_tb10_s1210/ckpt/it_01000.pt)
166
+ lookup() { local k=$1; shift; for e in "$@"; do [ "${e%%:*}" = "$k" ] && { echo "${e#*:}"; return 0; }; done; return 1; }
167
+ ckpt() { # ckpt <stage>: the parent checkpoint (own run if --parents own and it exists, else released)
168
+ local own; own="$RUNS/$(lookup "$1" "${OWN_T[@]}")"
169
+ if [ "$PARENTS" = own ] && [ "$TINY" = 0 ]; then
170
+ [ -f "$own" ] || die "no own checkpoint $own (run step $1, or --parents released)"
171
+ echo "$own"
172
+ elif [ "$PARENTS" = own ] && [ -f "$own" ]; then echo "$own"
173
+ else echo "$A/$(lookup "$1" "${REL_T[@]}")"; fi
174
+ }
175
+ tiny_or() { [ "$TINY" = 1 ] && echo "$1" || echo "$2"; }
176
+
177
+ # ---------------------------------------------------------------------------------------------------- checks
178
+ if has_step t0 || has_step t1 || has_step t2 || has_step t3 || has_step t4 || has_step t5 || has_step t6 || \
179
+ has_step s0 || has_step s1 || has_step s2 || has_step s3 || has_step s4 || has_step s5 || has_step simcheck; then
180
+ "$PY" -c "import torch, torchvision, numpy, scipy, mujoco" 2>/dev/null \
181
+ || die "$PY needs torch, torchvision, numpy, scipy and mujoco 3.15.0 (requirements-so101-pick-place.txt; set PY)"
182
+ if [ "$DEVICE" != cpu ]; then
183
+ "$PY" -c "import torch, sys; sys.exit(0 if torch.cuda.is_available() else 1)" || die "no GPU for --device $DEVICE"
184
+ fi
185
+ fi
186
+ if has_step s0 || has_step s1 || has_step s2 || has_step s3 || has_step s4 || has_step s5 || has_step simcheck; then
187
+ "$PY" -c "import warp, newton" 2>/dev/null || die "$PY needs warp-lang 1.13.0 and newton 1.2.0 for the renderer"
188
+ fi
189
+
190
+ # ---------------------------------------------------------------------------------------------------- setup
191
+ if has_step setup; then
192
+ log "setup: MuJoCo Menagerie SO101 at the pinned revision (contact_nrd/so101_grasp/vendor/)"
193
+ "$PY" -I contact_nrd/so101_grasp/fetch_sources.py
194
+ fi
195
+
196
+ # ---------------------------------------------------------------------------------------------------- download
197
+ DL_GROUPS=nrd,nrd_test,teacher,student,rl_inputs,results,bundle,recordings
198
+ [ "$WITH_NRD_DATA" = 1 ] && DL_GROUPS="$DL_GROUPS,nrd_data"
199
+ [ "$WITH_EXPERT" = 1 ] && DL_GROUPS="$DL_GROUPS,expert_data"
200
+ [ "$WITH_ROBOT" = 1 ] && DL_GROUPS="$DL_GROUPS,robot"
201
+ if has_step download; then
202
+ log "download + sha256 check ($DL_GROUPS)"
203
+ "$PY" -I scripts/so101_pick_place/download.py --groups "$DL_GROUPS" --dest "$CODE/artifacts" --quiet \
204
+ ${SOURCE:+--source "$SOURCE"}
205
+ fi
206
+
207
+ # smoke task files: the first rows of the released sets (dev100 rows 0-3 = tasks --kind C --n 4 --dev, bit for bit)
208
+ TS="$T"
209
+ if [ "$TINY" = 1 ] && [ ! -f "$T/dev100.npz" ]; then
210
+ for s in t1 t2 t3 t4 t5 t6 s0 s1 s2 s3 s4 s5; do
211
+ has_step $s && die "no task files in $T (step $s): run the download step first"
212
+ done
213
+ elif [ "$TINY" = 1 ]; then
214
+ "$PY" - "$T" "$OUT/tasks" <<'EOF'
215
+ import sys
216
+ from pathlib import Path
217
+ import numpy as np
218
+ src, out = Path(sys.argv[1]), Path(sys.argv[2])
219
+ for name, n in (("dev100", 4), ("home45_dev100", 4), ("home_dev100", 4), ("train_mix45_16k", 256)):
220
+ if not (src / f"{name}.npz").is_file():
221
+ continue
222
+ t = dict(np.load(src / f"{name}.npz", allow_pickle=True))
223
+ N = len(t["seeds"])
224
+ np.savez(out / f"{name}.npz", **{k: (v[:n] if np.ndim(v) and len(v) == N else v) for k, v in t.items()})
225
+ EOF
226
+ TS="$OUT/tasks"
227
+ fi
228
+
229
+ # ---------------------------------------------------------------------------------------------------- geometry
230
+ if has_step geometry; then
231
+ log "geometry: rebuild the kin points and the task geometry from MuJoCo, compare with rl_inputs/geometry/"
232
+ mkdir -p "$OUT/geometry"
233
+ "$PY" - "$A/rl_inputs/geometry" "$OUT/geometry" <<'EOF'
234
+ import hashlib, sys
235
+ from pathlib import Path
236
+ import numpy as np
237
+ from nedm.so101_policy import kin, task
238
+ rel, out = Path(sys.argv[1]), Path(sys.argv[2])
239
+ kin.save_points(out / "kin_points_v1.npz")
240
+ task.TaskGeometry.from_mujoco().save(out / "task_geom_v2.npz")
241
+ sha = lambda p: hashlib.sha256(p.read_bytes()).hexdigest()
242
+ for f in ("kin_points_v1.npz", "task_geom_v2.npz"):
243
+ a, b = np.load(out / f), np.load(rel / f)
244
+ same = sorted(a.files) == sorted(b.files) and all(np.array_equal(a[k], b[k]) for k in a.files)
245
+ print(f"{f}: arrays {'EQUAL' if same else 'DIFFER'} to the released file; sha256 "
246
+ f"{'equal' if sha(out / f) == sha(rel / f) else 'differs (zip records)'}")
247
+ if not same:
248
+ sys.exit(f"{f}: the rebuilt arrays differ from rl_inputs/geometry/{f}")
249
+ EOF
250
+ fi
251
+
252
+ # ---------------------------------------------------------------------------------------------------- nrd
253
+ if has_step nrd; then
254
+ log "nrd: main's nedm.contact_nrd.model.load_model on c1_s62 and c0_s62, 100-step rollouts of 4 test episodes"
255
+ "$PY" - "$A" "$DEVICE" <<'EOF'
256
+ import hashlib, json, sys
257
+ from pathlib import Path
258
+ import torch
259
+ from nedm.contact_nrd import data as D
260
+ from nedm.contact_nrd.model import load_model
261
+ A, dev = Path(sys.argv[1]), sys.argv[2]
262
+ man = json.loads((Path("so101_pick_place/release_manifest.json")).read_text())["files"]
263
+ data = None
264
+ for run in ("c1_s62", "c0_s62"):
265
+ f = A / f"nrd/{run}/best.pt"
266
+ sha = hashlib.sha256(f.read_bytes()).hexdigest()
267
+ model, packet = load_model(str(f), dev)
268
+ n = sum(p.numel() for p in model.parameters())
269
+ if data is None:
270
+ root = A / "nrd_test"
271
+ data = D.step_average_rates(D.load_data(str(root), dev, model_step_s=model.dt), set(model.config["integrate"]["kinds"]))
272
+ s = data["stride"]
273
+ st, act = data["states"][:4, ::s], data["actions"][:4, ::s]
274
+ with torch.no_grad():
275
+ traj = model.rollout(st[:, 0], act[:, :100])
276
+ ic = [b["name"] for b in model.system["bodies"] if b["moving"]].index("cube")
277
+ err = (traj[:, 100, ic, :3] - st[:, 100, ic, :3]).norm(dim=-1) * 1e3
278
+ print(f"{run}: sha256 {sha[:16]} ({'= manifest' if sha == man['so101_pick_place/nrd/' + run + '/best.pt']['sha256'] else 'NOT the manifest'}), "
279
+ f"{n:,} parameters, update {packet.get('update')}, rollout {tuple(traj.shape)} finite {bool(torch.isfinite(traj).all())}, "
280
+ f"cube position error at 2 s (mm): {[round(float(e), 2) for e in err]}")
281
+ EOF
282
+ fi
283
+
284
+ # ---------------------------------------------------------------------------------------------------- nrd_collect
285
+ if has_step nrd_collect; then
286
+ log "nrd_collect: regenerate the first episode of every family of nrd_test/ with the collector (exact check)"
287
+ "$PY" -P - "$A/nrd_test" <<'EOF'
288
+ import json, sys, time
289
+ import numpy as np
290
+ from nedm.contact_nrd.collect import so101_grasp as g
291
+ data = sys.argv[1]
292
+ cfg = g.load_config(); s = g.Scene(cfg)
293
+ master = cfg["campaigns"]["test"]["master_seed"]
294
+ with np.load(f"{data}/unified_data.npz") as f:
295
+ fam_all, fidx, lengths, seeds = f["family"], f["family_index"], f["lengths"], f["seed"]
296
+ rows = sorted(int(np.flatnonzero(fam_all == k)[0]) for k in np.unique(fam_all))
297
+ a = {key: f[key][rows] for key in ("arm", "cube", "action", "contacts")}
298
+ same = []
299
+ for j, row in enumerate(rows):
300
+ ep = g.make_episode(s, int(fam_all[row]), int(fidx[row]), master)
301
+ n = int(lengths[row])
302
+ ok = (len(ep["action"]) == n and int(ep["seed"]) == int(seeds[row])
303
+ and np.array_equal(ep["states"]["arm"][:n].astype(np.float32), a["arm"][j, :n])
304
+ and np.array_equal(ep["states"]["cube"][:n].astype(np.float32), a["cube"][j, :n])
305
+ and np.array_equal(ep["action"][:n].astype(np.float32), a["action"][j, :n])
306
+ and np.array_equal(ep["contacts"], a["contacts"][j, :n - 1]))
307
+ same.append(ok)
308
+ print(f" {cfg['families'][int(fam_all[row])]['name']:14s} row {row}: {'identical' if ok else 'DIFFERENT'}", flush=True)
309
+ print(f"{sum(same)} of {len(same)} test episodes regenerated bit for bit (campaign test, master seed {master})")
310
+ if not all(same):
311
+ sys.exit("the collector does not regenerate the released test episodes on this machine (MuJoCo version?)")
312
+ EOF
313
+ if [ "$MODE" = chain ]; then
314
+ for c in production extra noisy_v1 test; do
315
+ log "nrd_collect: campaign $c (CPU MuJoCo; about 15 min on 24 workers each)"
316
+ FAM=() # the released extra part: 4 of the campaign's 13 families (production_plus/extra_manifest.json)
317
+ [ "$c" = extra ] && FAM=(--families one_sided near_miss weak_closure push)
318
+ [ -f "$OUT/nrd_data/$c/system.json" ] || "$PY" -P -m nedm.contact_nrd.collect.so101_grasp collect \
319
+ --campaign "$c" --workers "$WORKERS" --out "$OUT/nrd_data/$c" "${FAM[@]}"
320
+ "$PY" -P -m nedm.contact_nrd.collect.validate "$OUT/nrd_data/$c" --output "$OUT/nrd_data/$c/validate.json"
321
+ done
322
+ "$PY" - "$OUT/nrd_data" "$A" <<'EOF'
323
+ import json, sys
324
+ from pathlib import Path
325
+ out, A = Path(sys.argv[1]), Path(sys.argv[2])
326
+ REL = {"production": "nrd_data/production_plus/production_manifest.json", "extra": "nrd_data/production_plus/extra_manifest.json",
327
+ "noisy_v1": "nrd_data/noisy_v1/manifest.json", "test": "nrd_test/manifest.json"}
328
+ bad = []
329
+ for c, rel in REL.items():
330
+ mine = json.loads((out / c / "manifest.json").read_text())["episode_counts"]
331
+ ref = json.loads((A / rel).read_text())["episode_counts"]
332
+ print(f"nrd_collect {c}: {sum(mine.values())} episodes in {len(mine)} families (released {sum(ref.values())} in "
333
+ f"{len(ref)}): {'same counts' if mine == ref else 'DIFFERENT counts'}")
334
+ bad += [c] if mine != ref else []
335
+ if bad:
336
+ sys.exit(f"nrd_collect: episode counts differ from the release in {bad}")
337
+ EOF
338
+ log "nrd_collect: expert_v2 and policy_v3 are not re-collected (their collector is in no commit / needs the 7 "
339
+ log " policies; README): the released parts are used by nrd_train"
340
+ fi
341
+ fi
342
+
343
+ # ---------------------------------------------------------------------------------------------------- nrd_train
344
+ # The training options of these two NRDs are not in main's train.py: train with the study code (README).
345
+ ST="$OUT/study_f6f05c21c"
346
+ study_tree() { # study_tree [optional]: a git worktree of commit f6f05c21c (the NRD training code) at $ST
347
+ [ -d "$ST/src/nedm/contact_nrd" ] && return 0
348
+ if ! git -C "$CODE" cat-file -e f6f05c21c^{commit} 2>/dev/null; then
349
+ git -C "$CODE" fetch origin so101-pick-place-study 2>/dev/null || true
350
+ fi
351
+ if ! git -C "$CODE" cat-file -e f6f05c21c^{commit} 2>/dev/null; then
352
+ [ "${1:-}" = optional ] && return 1
353
+ die "commit f6f05c21c not found: git fetch origin so101-pick-place-study"
354
+ fi
355
+ # no LFS files: the training code needs none of the .pt files that f6f05c21c tracks under artifacts/
356
+ GIT_LFS_SKIP_SMUDGE=1 git -C "$CODE" worktree add --quiet --detach "$ST" f6f05c21c || {
357
+ [ "${1:-}" = optional ] && return 1; die "git worktree add of commit f6f05c21c failed"; }
358
+ # f6f05c21c tracks files under artifacts/: link only the data folder of this release into it
359
+ mkdir -p "$ST/artifacts"
360
+ ln -sfn "$CODE/artifacts/so101_pick_place" "$ST/artifacts/so101_pick_place"
361
+ cp -r "$CODE/contact_nrd/so101_grasp/vendor" "$ST/contact_nrd/so101_grasp/" 2>/dev/null || true
362
+ }
363
+ need_nrd_data() { # need_nrd_data <step>: the 4 NRD data parts of the Hub (--with-nrd-data)
364
+ local d
365
+ for d in production_plus noisy_v1 expert_v2 policy_v3; do
366
+ [ -f "$A/nrd_data/$d/unified_data.npz" ] \
367
+ || die "step $1 needs the NRD data ($A/nrd_data/$d missing): add --with-nrd-data to the download"
368
+ done
369
+ }
370
+ if has_step nrd_train; then
371
+ need_nrd_data nrd_train
372
+ study_tree
373
+ SMOKE_FLAG=()
374
+ ND="$A/nrd_data"
375
+ if [ "$TINY" = 1 ]; then # --smoke runs of the training code on 4 train + 4 validation episodes per family
376
+ SMOKE_FLAG=(--smoke)
377
+ ND="$OUT/nrd_data_smoke"
378
+ [ -f "$ND/subsets.json" ] || "$PY" -I scripts/so101_pick_place/nrd/subsets.py "$ND" 4 --split family \
379
+ production_plus="$A/nrd_data/production_plus" noisy_v1="$A/nrd_data/noisy_v1" \
380
+ expert_v2="$A/nrd_data/expert_v2" policy_v3="$A/nrd_data/policy_v3" > "$OUT/nrd_data_smoke.log"
381
+ fi
382
+ PP="$ND/production_plus"
383
+ if [ "$TINY" = 0 ] && [ -f "$OUT/nrd_data/production/system.json" ] && [ -f "$OUT/nrd_data/extra/system.json" ]; then
384
+ PP="$OUT/nrd_data/production_plus" # the own scripted campaigns of nrd_collect (chain)
385
+ [ -f "$PP/system.json" ] || (cd "$ST" && PYTHONPATH="$ST/src" "$PY" -P scripts/contact_nrd/merge_data.py "$PP" \
386
+ "$OUT/nrd_data/production" "$OUT/nrd_data/extra")
387
+ fi
388
+ log "nrd_train: base NRD c0_s62 from scratch on $PP (about 8.5 GPU-h; the study ran it with the uncommitted code of provenance/code_v16_base_nrd.tar.gz: recipe only)"
389
+ # seed 62 = the run's seed (base_c0.json says 61; the run's command line set 62, as here)
390
+ [ -f "$RUNS/nrd_c0_s62/complete.json" ] || (cd "$ST" && PYTHONPATH="$ST/src" "$PY" -P -m nedm.contact_nrd.train \
391
+ --data "$PP" --seed 62 --config "$CODE/configs/so101_pick_place/nrd/base_c0.json" --output "$RUNS/nrd_c0_s62" \
392
+ --device "$DEVICE" "${SMOKE_FLAG[@]}")
393
+ M="$OUT/nrd_data/merged_r3_pp_noisy_expert_policy_x2.5"
394
+ [ "$TINY" = 1 ] && M="$ND/merged"
395
+ log "nrd_train: merge production_plus + noisy_v1 + expert_v2 + policy_v3 (train rows of policy_v3 x 2.5) -> $M (13.6 GB at full size)"
396
+ [ -f "$M/system.json" ] || (cd "$ST" && PYTHONPATH="$ST/src" "$PY" -P scripts/so101_policy/collect_round.py merge \
397
+ --base "$PP" --extra "$ND/noisy_v1" "$ND/expert_v2" "$ND/policy_v3" \
398
+ --repeat "$ND/policy_v3=2.5" --out "$M")
399
+ # array-level check of the merge: the split counts vs the fine-tune's run record (np.savez stores zip times, so the
400
+ # file's sha256 cannot equal the record's data_sha256 6ef821f0...)
401
+ "$PY" - "$M/unified_data.npz" "$A/nrd/c1_s62/run_config.json" "$TINY" <<'EOF'
402
+ import json, sys
403
+ import numpy as np
404
+ with np.load(sys.argv[1]) as f:
405
+ sp = f["splits"]
406
+ rec = json.load(open(sys.argv[2]))
407
+ n0, n1 = int((sp == 0).sum()), int((sp == 1).sum())
408
+ print(f"merged data: {len(sp)} episodes, train {n0}, validation {n1} (released fine-tune record: train "
409
+ f"{rec['training_episodes']}, validation {rec['validation_episodes']})")
410
+ if sys.argv[3] == "0" and (n0, n1) != (rec["training_episodes"], rec["validation_episodes"]):
411
+ sys.exit("the merged data do not have the episode counts of the released fine-tune")
412
+ EOF
413
+ # init_from as an absolute path (the training runs in the study worktree): the own base run with --parents own,
414
+ # else the released original base NRD (nrd/c0_s62/original/best.pt)
415
+ FT="$OUT/configs/ft_c1_s62.json"
416
+ if [ "$PARENTS" = own ] && [ -f "$RUNS/nrd_c0_s62/best.pt" ]; then INIT_RUN="$RUNS/nrd_c0_s62"; INIT_CK=best.pt
417
+ else INIT_RUN="$A/nrd/c0_s62"; INIT_CK=original/best.pt; fi
418
+ "$PY" - "$CODE/configs/so101_pick_place/nrd/ft_c1_s62.json" "$FT" "$INIT_RUN" "$INIT_CK" <<'EOF'
419
+ import json, sys
420
+ c = json.load(open(sys.argv[1]))
421
+ c["init_from"].update(run=sys.argv[3], checkpoint=sys.argv[4])
422
+ json.dump(c, open(sys.argv[2], "w"), indent=1)
423
+ EOF
424
+ log "nrd_train: fine-tune c1_s62 (20,000 updates, best at update 2,500; 1.6 GPU-h); init_from $INIT_RUN/$INIT_CK"
425
+ [ -f "$RUNS/nrd_c1_s62/complete.json" ] || (cd "$ST" && PYTHONPATH="$ST/src" "$PY" -P -m nedm.contact_nrd.train \
426
+ --data "$M" --output "$RUNS/nrd_c1_s62" --config "$FT" --device "$DEVICE" "${SMOKE_FLAG[@]}")
427
+ fi
428
+
429
+ # ---------------------------------------------------------------------------------------------------- nrd_strip
430
+ if has_step nrd_strip; then
431
+ mkdir -p "$OUT/nrd_strip"
432
+ for r in c1_s62 c0_s62; do # the released originals: the new file vs the released main-compatible best.pt
433
+ log "nrd_strip: $r: strip_ckpt.py on the released original, compared with the released best.pt"
434
+ mkdir -p "$OUT/nrd_strip/$r"
435
+ "$PY" -I scripts/so101_pick_place/nrd/strip_ckpt.py "$A/nrd/$r/original/best.pt" "$OUT/nrd_strip/$r/best.pt" \
436
+ "$OUT/nrd_strip/$r.json" "$A/nrd/$r/best.pt" > "$OUT/nrd_strip/$r.log" \
437
+ || die "nrd_strip: $r differs from the released best.pt ($OUT/nrd_strip/$r.json)"
438
+ "$PY" - "$OUT/nrd_strip/$r.json" "$r" <<'EOF'
439
+ import json, sys
440
+ r = json.load(open(sys.argv[1]))
441
+ same = r["bytes_equal_to_expected"]
442
+ print(f" {sys.argv[2]}: kept entries equal to the original: {r['all_kept_entries_equal']}; bytes equal to the released "
443
+ f"best.pt: {same}" + ("" if same else f" (every entry equal: {r['entries_equal_to_expected']}; the bytes depend on the torch version)"))
444
+ EOF
445
+ done
446
+ for r in c1_s62 c0_s62; do # own nrd_train runs -> main-compatible files for the tests and the policy stages
447
+ [ -f "$RUNS/nrd_$r/best.pt" ] || continue
448
+ log "nrd_strip: own run $RUNS/nrd_$r -> $OUT/nrd_main/$r/best.pt"
449
+ mkdir -p "$OUT/nrd_main/$r"
450
+ "$PY" -I scripts/so101_pick_place/nrd/strip_ckpt.py "$RUNS/nrd_$r/best.pt" "$OUT/nrd_main/$r/best.pt" \
451
+ "$OUT/nrd_main/$r.json" > "$OUT/nrd_main/$r.log" || die "nrd_strip: own $r ($OUT/nrd_main/$r.json)"
452
+ done
453
+ # the original in the training code vs the new file in main's code: 100-step rollouts, contact switches, metrics
454
+ if study_tree optional; then
455
+ EQ="$OUT/nrd_strip/equiv"; mkdir -p "$EQ"
456
+ N_EQ=$(tiny_or 4 64)
457
+ if [ -f "$A/nrd_data/policy_v3/unified_data.npz" ]; then # as the release: 64 validation episodes of each part
458
+ N_EQ=64 # (also in smoke: the per-family task metrics need every scored family with 1 s windows)
459
+ [ -f "$EQ/data/subsets.json" ] || "$PY" -I scripts/so101_pick_place/nrd/subsets.py "$EQ/data" "$N_EQ" \
460
+ production_plus="$A/nrd_data/production_plus" noisy_v1="$A/nrd_data/noisy_v1" \
461
+ expert_v2="$A/nrd_data/expert_v2" policy_v3="$A/nrd_data/policy_v3" > "$EQ/subsets.log"
462
+ SETS_EQ=(production_plus="$EQ/data/production_plus" noisy_v1="$EQ/data/noisy_v1"
463
+ expert_v2="$EQ/data/expert_v2" policy_v3="$EQ/data/policy_v3")
464
+ else # without the NRD data: test episodes
465
+ [ -f "$EQ/data/subsets.json" ] || "$PY" -I scripts/so101_pick_place/nrd/subsets.py "$EQ/data" "$N_EQ" \
466
+ --split 2 nrd_test="$A/nrd_test" > "$EQ/subsets.log"
467
+ SETS_EQ=(nrd_test="$EQ/data/nrd_test")
468
+ fi
469
+ PAIRS=()
470
+ for r in c1_s62 c0_s62; do
471
+ log "nrd_strip: $r: original/best.pt in the training code (f6f05c21c) vs best.pt in main's code ($N_EQ episodes per folder, $DEVICE)"
472
+ "$PY" -I scripts/so101_pick_place/nrd/equiv.py "$ST/src" "$A/nrd/$r/original/best.pt" "$DEVICE" \
473
+ "$EQ/${r}_train" "${SETS_EQ[@]}" > "$EQ/${r}_train.log"
474
+ "$PY" -I scripts/so101_pick_place/nrd/equiv.py "$CODE/src" "$A/nrd/$r/best.pt" "$DEVICE" \
475
+ "$EQ/${r}_main" "${SETS_EQ[@]}" > "$EQ/${r}_main.log"
476
+ PAIRS+=("$EQ/${r}_train" "$EQ/${r}_main")
477
+ done
478
+ "$PY" -I scripts/so101_pick_place/nrd/equiv_compare.py "$EQ/equiv.json" "${PAIRS[@]}" > "$EQ/equiv.log" \
479
+ || die "nrd_strip: equiv_compare.py failed ($EQ/equiv.log)"
480
+ echo " original (training code) vs main-compatible (main's code): $(tail -1 "$EQ/equiv.log") ($EQ/equiv.json)"
481
+ grep -q "^ALL EQUAL" "$EQ/equiv.log" || die "nrd_strip: the main-compatible files do not step like the originals"
482
+ else
483
+ log "nrd_strip: commit f6f05c21c not available (git fetch origin so101-pick-place-study): no training-code comparison"
484
+ fi
485
+ fi
486
+ # the NRD of the policy stages: the own c1 with --parents own when nrd_strip made it, else the released one
487
+ if [ "$PARENTS" = own ] && [ -f "$OUT/nrd_main/c1_s62/best.pt" ]; then NRD="$OUT/nrd_main/c1_s62/best.pt"; fi
488
+ NRD_MODELS=(c1_s62="$A/nrd/c1_s62" c0_s62="$A/nrd/c0_s62")
489
+ for r in c1_s62 c0_s62; do
490
+ if [ -f "$OUT/nrd_main/$r/best.pt" ]; then NRD_MODELS+=("own_$r=$OUT/nrd_main/$r"); fi
491
+ done
492
+
493
+ # ---------------------------------------------------------------------------------------------------- nrd_test
494
+ if has_step nrd_test; then
495
+ D_TEST="$A/nrd_test"
496
+ if [ "$TINY" = 1 ]; then # 2 episodes per family (24 of 3,050)
497
+ D_TEST="$OUT/nrd_test_subset"
498
+ "$PY" - "$A/nrd_test" "$D_TEST" <<'EOF'
499
+ import json, shutil, sys
500
+ from pathlib import Path
501
+ import numpy as np
502
+ src, out = Path(sys.argv[1]), Path(sys.argv[2])
503
+ out.mkdir(parents=True, exist_ok=True)
504
+ with np.load(src / "unified_data.npz") as f:
505
+ fam = f["family"]
506
+ rows = sorted(r for k in np.unique(fam) for r in np.flatnonzero(fam == k)[:2].tolist())
507
+ np.savez(out / "unified_data.npz", **{k: f[k][rows] for k in f.files})
508
+ shutil.copy2(src / "system.json", out / "system.json")
509
+ (out / "rows.json").write_text(json.dumps(rows))
510
+ EOF
511
+ fi
512
+ log "nrd_test: python -m nedm.contact_nrd.test on $D_TEST (main's code, unchanged)"
513
+ mkdir -p "$OUT/nrd"
514
+ "$PY" -P -m nedm.contact_nrd.test --data "$D_TEST" --model "${NRD_MODELS[@]}" \
515
+ --output "$OUT/nrd/nrd_test.json" --device "$DEVICE" > "$OUT/nrd/nrd_test.txt"
516
+ "$PY" - "$OUT/nrd/nrd_test.json" "$A/results/nrd/sealed_test.json" "$D_TEST" <<'EOF'
517
+ import json, sys
518
+ from pathlib import Path
519
+ mine, ref = json.loads(Path(sys.argv[1]).read_text()), json.loads(Path(sys.argv[2]).read_text())
520
+ rows_f = Path(sys.argv[3]) / "rows.json"
521
+ rows = json.loads(rows_f.read_text()) if rows_f.exists() else None
522
+ for m in mine["models"]:
523
+ if m not in ref["models"]: # own NRDs (nrd_strip): no released counterpart
524
+ print(f"{m}: selected score {mine['models'][m]['selected']['selection_score']:.4f}")
525
+ continue
526
+ a, b = mine["models"][m], ref["models"][m]
527
+ if rows is None:
528
+ print(f"{m}: selected score {a['selected']['selection_score']:.4f} (released {b['selected']['selection_score']:.4f}); "
529
+ f"all {a['selection_score']:.4f} (released {b['selection_score']:.4f})")
530
+ else: # per-episode free-rollout errors of the same episodes (the batch differs: float noise possible)
531
+ def flat(x, p=""):
532
+ if isinstance(x, dict):
533
+ for k, v in x.items():
534
+ yield from flat(v, f"{p}/{k}")
535
+ elif isinstance(x, (int, float)) and not isinstance(x, bool):
536
+ yield p, float(x)
537
+ diff, n = 0.0, 0
538
+ for j, r in enumerate(rows):
539
+ ea, eb = dict(flat(a["per_episode"][j]["free"])), dict(flat(b["per_episode"][r]["free"]))
540
+ for k in ea.keys() & eb.keys():
541
+ diff, n = max(diff, abs(ea[k] - eb[k])), n + 1
542
+ print(f"{m}: {len(rows)} test episodes, {n} per-episode free-rollout values vs the released test: max |diff| {diff:.3g}")
543
+ EOF
544
+ fi
545
+
546
+ # ---------------------------------------------------------------------------------------------------- nrd_val
547
+ if has_step nrd_val; then
548
+ [ -f "$A/nrd_data/production_plus/unified_data.npz" ] \
549
+ || die "step nrd_val needs production_plus: add --with-nrd-data to the download"
550
+ V_DIR="$OUT/nrd_val"
551
+ log "nrd_val: the validation episodes (split 1) of production_plus -> $V_DIR (smoke: 24 of 2,853)"
552
+ [ -f "$V_DIR/subsets.json" ] || "$PY" -I scripts/so101_pick_place/nrd/subsets.py "$V_DIR" "$(tiny_or 24 0)" \
553
+ production_plus="$A/nrd_data/production_plus" > "$OUT/nrd_val.log"
554
+ log "nrd_val: python -m nedm.contact_nrd.test on them (main's code, unchanged)"
555
+ mkdir -p "$OUT/nrd"
556
+ "$PY" -P -m nedm.contact_nrd.test --data "$V_DIR/production_plus" --model "${NRD_MODELS[@]}" \
557
+ --output "$OUT/nrd/validation.json" --device "$DEVICE" > "$OUT/nrd/validation.txt"
558
+ TEST_JSON="$A/results/nrd/sealed_test.json" # the README table: validation next to the sealed test
559
+ [ "$TINY" = 0 ] && [ -f "$OUT/nrd/nrd_test.json" ] && TEST_JSON="$OUT/nrd/nrd_test.json"
560
+ COLS=("c0 validation=$OUT/nrd/validation.json:c0_s62" "c0 test=$TEST_JSON:c0_s62"
561
+ "c1 validation=$OUT/nrd/validation.json:c1_s62" "c1 test=$TEST_JSON:c1_s62")
562
+ for r in c1_s62 c0_s62; do
563
+ if [ -f "$OUT/nrd_main/$r/best.pt" ]; then COLS+=("own $r validation=$OUT/nrd/validation.json:own_$r"); fi
564
+ done
565
+ "$PY" -I scripts/so101_pick_place/nrd/summarize.py "$OUT/nrd/summary_selected" "${COLS[@]}" > /dev/null
566
+ "$PY" - "$OUT/nrd/validation.json" "$A/results/nrd/validation_rescore.json" "$TINY" <<'EOF'
567
+ import json, sys
568
+ mine, ref = (json.load(open(p))["models"] for p in sys.argv[1:3])
569
+ for m, v in mine.items():
570
+ r = ref.get(m)
571
+ note = "" if not r else (f" (released validation re-score {r['selected']['selection_score']:.4f}"
572
+ + ("; smoke: 24 episodes only)" if sys.argv[3] == "1" else ")"))
573
+ print(f"nrd_val {m}: selected score {v['selected']['selection_score']:.4f}{note}")
574
+ EOF
575
+ echo "table: $OUT/nrd/summary_selected.md"
576
+ fi
577
+
578
+ # ---------------------------------------------------------------------------------------------------- teachers
579
+ # smoke env configs: the stage's env config with 200-step episodes
580
+ smoke_env() { # smoke_env <config> -> a copy with horizon 200 (smoke) or the config itself
581
+ if [ "$TINY" = 1 ]; then
582
+ local o="$OUT/configs/$(basename "$1")"
583
+ "$PY" -c "import json, sys; c = json.load(open(sys.argv[1])); c['horizon'] = 200; json.dump(c, open(sys.argv[2], 'w'), indent=1)" "$1" "$o"
584
+ echo "$o"
585
+ else echo "$1"; fi
586
+ }
587
+ teacher_ppo() { # teacher_ppo <run> <init> <env config> <train config> <critic warmup> <iterations> <eval/save every>
588
+ # <seed> <dev set> [<more dev sets> (then also --dev-match-env)]
589
+ local run="$RUNS/$1" init="$2" ecfg; ecfg="$(smoke_env "$3")"; local tc="$4" cw="$5" it="$6" every="$7" seed="$8"
590
+ shift 8
591
+ local dev=(--dev-tasks "$1"); shift
592
+ [ $# -gt 0 ] && dev+=(--dev-tasks-extra "$@" --dev-match-env)
593
+ local size=(--envs 8192 --iterations "$it" --eval-every "$every" --save-every "$every" --critic-warmup "$cw")
594
+ [ "$TINY" = 1 ] && size=(--envs 256 --iterations 2 --eval-every 2 --save-every 2 --critic-warmup 1)
595
+ [ -e "$run/ckpt" ] && { log "skip $run (exists)"; return 0; }
596
+ log "teacher PPO $(basename "$run"): init $init, env $ecfg"
597
+ env -u NEDM_SO101_DYN "$PY" -P scripts/so101_policy/vision_viral_teacher.py ppo --nrd-ckpt "$NRD" --init "$init" \
598
+ --env-config "$ecfg" --train-config "$tc" "${size[@]}" "${dev[@]}" --seed "$seed" --out "$run" \
599
+ --mj-python "$PY" --device "$DEVICE"
600
+ }
601
+ if has_step t0; then
602
+ run="$RUNS/t0_nC1_s62_b"
603
+ # the study job stopped at its time limit (--max-hours 3.3) after 171 iterations on one MI350X; here the run
604
+ # stops at 171 iterations (model_00171.pt) on any GPU
605
+ size=(--num-envs 16384 --max-iterations 171 --max-hours 1000 --val-every 10 --save-every 10 --val-n 512 --print-every 5)
606
+ [ "$TINY" = 1 ] && size=(--num-envs 256 --max-iterations 1 --val-every 1 --save-every 1 --val-n 16 --print-every 1)
607
+ log "t0: decoder PPO from scratch in the NRD (train_ppo.py; 171 iterations as the study: 3.3 h on one MI350X, model_00171)"
608
+ [ -e "$run/done.json" ] || "$PY" -P scripts/so101_policy/train_ppo.py train --world nrd --out "$run" \
609
+ --env-cfg configs/so101_policy/ppo/env_v2.json --train-cfg configs/so101_policy/ppo/train_v2.json \
610
+ --curriculum configs/so101_policy/ppo/curriculum_tol_v3.json "${size[@]}" --starts "$B/bank_pp_s0.npz" \
611
+ --set env.geom_path="\"$A/rl_inputs/geometry/task_geom_v2.npz\"" env.kin_points="\"$A/rl_inputs/geometry/kin_points_v1.npz\"" \
612
+ --ckpt "$NRD" --seed 2 --set 'env.grasp_shaping={"w_x":20.0,"w_y":10.0,"w_yaw":2.0}' algorithm.desired_kl=0.02 \
613
+ --device "$DEVICE"
614
+ fi
615
+ if has_step t1; then
616
+ [ -f "$A/nrd_data/production_plus/unified_data.npz" ] \
617
+ || die "step t1 reads its start states from nrd_data/production_plus (split 0): add --with-nrd-data to the download"
618
+ log "t1: expert data, T0 + the action decoder in the NRD (recipe only: the study code was not committed)"
619
+ mkdir -p "$RUNS/t1_expert_data"
620
+ for spec in "e0_n1 1.0 0 0" "e1_n2 2.0 1 8192" "e2_n15 1.5 2 16384"; do
621
+ set -- $spec
622
+ [ -f "$RUNS/t1_expert_data/$1.npz" ] || "$PY" -P scripts/so101_policy/vision_viral_teacher.py expert \
623
+ --teacher "$(ckpt t0)" --nrd-ckpt "$NRD" --n "$(tiny_or 64 8192)" --noise "$2" --noise-frac 0.5 --seed "$3" \
624
+ --first "$4" --mj-python "$PY" --device "$DEVICE" --out "$RUNS/t1_expert_data/$1.npz"
625
+ done
626
+ fi
627
+ if has_step t2; then
628
+ E="$RUNS/t1_expert_data" # own t1 data if this run made them (smoke: always), else the released data
629
+ { [ "$PARENTS" = released ] && [ "$TINY" = 0 ]; } || [ ! -f "$E/e2_n15.npz" ] && E="$A/teacher/t1_expert_data"
630
+ [ -f "$E/e2_n15.npz" ] || die "t2 needs the expert data: run step t1, or download them (--with-expert-data)"
631
+ log "t2: behaviour cloning of the joint-target teacher on $E (recipe only)"
632
+ [ -f "$RUNS/t2_bc_all/bc.pt" ] || "$PY" -P scripts/so101_policy/vision_viral_teacher.py bc \
633
+ --data "$E/e0_n1.npz" "$E/e1_n2.npz" "$E/e2_n15.npz" --steps "$(tiny_or 20 60000)" --batch "$(tiny_or 512 8192)" \
634
+ --hidden 1024 512 256 --lr 0.001 --seed 0 --device "$DEVICE" --out "$RUNS/t2_bc_all"
635
+ fi
636
+ # t3 / t4: the study planned 400 / 200 iterations and cancelled the jobs; the adaptive-lr loop does not depend on the
637
+ # planned count, so this script stops at the released checkpoint's iteration (140 / 110)
638
+ if has_step t3; then
639
+ teacher_ppo t3_jt_b140 "$(ckpt t2)" configs/so101_pick_place/teacher/env_jt_b140.json \
640
+ configs/so101_policy/ppo/joint_ppo_v3.json 20 140 10 0 "$TS/dev100.npz"
641
+ fi
642
+ if has_step t4; then
643
+ teacher_ppo t4_jt_h110 "$(ckpt t3)" configs/so101_pick_place/teacher/env_jt_h110.json \
644
+ configs/so101_policy/ppo/joint_ppo_v3.json 5 110 10 0 "$TS/dev100.npz"
645
+ fi
646
+ if has_step t5; then
647
+ teacher_ppo t5_tppo_roll_v8_s21 "$(ckpt t4)" configs/so101_policy/ppo/r2s/teacher_roll_v8.json \
648
+ configs/so101_policy/ppo/r2s/joint_ppo_v3_kl02.json 20 200 20 21 "$TS/home45_dev100.npz" "$TS/dev100.npz"
649
+ fi
650
+ if has_step t6; then
651
+ teacher_ppo t6_tppo_v12_fr10_s122 "$(ckpt t5)" configs/so101_policy/ppo/r2s/teacher_roll_v12_fr10.json \
652
+ configs/so101_policy/ppo/r2s/joint_ppo_v3_kl02.json 20 200 20 122 "$TS/home45_dev100.npz" "$TS/dev100.npz" \
653
+ "$TS/home_dev100.npz"
654
+ fi
655
+
656
+ # ---------------------------------------------------------------------------------------------------- students
657
+ GUARD=("$T/fresh100.npz" "$T/home45_fresh100.npz")
658
+ student_online() { # student_online <run> <init> <teacher> <online config> <seed> [--oset ...]
659
+ local run="$RUNS/$1" init="$2" jt="$3" oc="$4" seed="$5"; shift 5
660
+ local oset=("$@") size=(--render-worlds 128 --eval-workers 16)
661
+ local ev=(--eval-tasks "$T/dev100.npz" "$T/home45_dev100.npz")
662
+ if [ "$TINY" = 1 ]; then
663
+ size=(--render-worlds 16 --eval-workers 2); ev=(--eval-tasks "$TS/dev100.npz")
664
+ oset=(--oset iterations=12 eval_every=12 save_every=12 log_every=4 envs=64 buffer=4096
665
+ $(for o in "$@"; do case "$o" in roll_hi_deg=*) echo "$o" ;; esac; done))
666
+ fi
667
+ [ -e "$run/curve.csv" ] && { log "skip $run (exists)"; return 0; }
668
+ log "student online $(basename "$run"): init $init, teacher $jt, $(basename "$oc")"
669
+ "$PY" -P scripts/so101_policy/vision_viral.py online --init "$init" --out "$run" --jt "$jt" --nrd-ckpt "$NRD" \
670
+ --mj-python "$PY" --tasks "$TS/train_mix45_16k.npz" "${ev[@]}" --guard-tasks "${GUARD[@]}" \
671
+ --config configs/so101_policy/vision/viral_r2s_v1.json --set "${SETS[@]}" --online-config "$oc" \
672
+ --eval-randomise "${size[@]}" --seed "$seed" --device "$DEVICE" "${oset[@]}"
673
+ }
674
+ if has_step s0; then
675
+ run="$RUNS/s0_v2_start_s2"
676
+ size=(--r0-tasks 4096 --rounds 2 --round-tasks 2048 --train-steps0 10000 --train-steps 4000 --render-worlds 256
677
+ --eval-workers 16 --eval-tasks "$T/dev100.npz" "$T/home45_dev100.npz")
678
+ [ "$TINY" = 1 ] && size=(--r0-tasks 32 --rounds 1 --round-tasks 16 --train-steps0 4 --train-steps 2 --render-worlds 16
679
+ --eval-workers 2 --eval-tasks "$TS/dev100.npz")
680
+ log "s0: first student (offline rounds, ImageNet ResNet18 encoders from torchvision), labels of T4"
681
+ [ -e "$run/r$([ "$TINY" = 1 ] && echo 1 || echo 2)/last.pt" ] || "$PY" -P scripts/so101_policy/vision_viral.py run \
682
+ --out "$run" --jt "$(ckpt t4)" --nrd-ckpt "$NRD" --mj-python "$PY" --tasks "$TS/train_mix45_16k.npz" \
683
+ --guard-tasks "${GUARD[@]}" --config configs/so101_policy/vision/viral_r2s_v1.json \
684
+ --set "scene=\"$SCENE\"" "calib=\"$CALIB\"" --teacher-share 0.5 --noise 1.0 --r0-noise-frac 0.5 \
685
+ --collect-randomise --eval-randomise --seed 2 --device "$DEVICE" "${size[@]}"
686
+ fi
687
+ V=configs/so101_policy/vision
688
+ if has_step s1; then student_online s1_v2_online_s18 "$(ckpt s0)" "$(ckpt t4)" $V/viral_r2s_online_v1.json 18; fi
689
+ if has_step s2; then student_online s2_v2_online2_s28 "$(ckpt s1)" "$(ckpt t4)" $V/viral_r2s_online_v1.json 28; fi
690
+ if has_step s3; then # exact code of this stage: commit 977863c9e (550a58cb6 changed the relabel mask; README)
691
+ student_online s3_v4_relabel_s63 "$(ckpt s2)" "$(ckpt t4)" $V/viral_r2s_online_relabel_v4.json 63
692
+ fi
693
+ if has_step s4; then
694
+ student_online s4_v8_roll_s801 "$(ckpt s3)" "$(ckpt t5)" $V/viral_r2s_online_relabel_roll_v8.json 801 \
695
+ --oset iterations=2000
696
+ fi
697
+ if has_step s5; then # the teacher: --parents own and an own t6 run, else the released T6
698
+ student_online s5_v12_tb10_s1210 "$(ckpt s4)" "$(ckpt t6)" $V/viral_r2s_online_v12_tb10.json 1210 \
699
+ --oset iterations=1500 eval_every=750 save_every=250 roll_hi_deg=98
700
+ fi
701
+
702
+ # ---------------------------------------------------------------------------------------------------- simcheck
703
+ STUDENT="$(ckpt s5)"
704
+ if has_step simcheck; then
705
+ G="$OUT/simcheck"
706
+ if [ "$TINY" = 1 ]; then
707
+ log "simcheck (smoke): G2-type evaluation of $STUDENT, 4 J224 tasks, 300 steps"
708
+ ONLY=g2_a TASK_ROWS=4 HORIZON=300 WORKERS=4 PY="$PY" scripts/so101_pick_place/check/run_gates.sh run \
709
+ v12_tb10_s1210_it1000 "$STUDENT" "$G"
710
+ "$PY" - "$G/runs/gates/local/v12_tb10_s1210_it1000/g2_a.npz" <<'EOF'
711
+ import json, sys
712
+ sys.path.insert(0, "scripts/so101_pick_place/check")
713
+ import numpy as np
714
+ import check_analyze as CA
715
+ f = sys.argv[1]
716
+ rows, info = CA.run_episodes(f)
717
+ t = CA.j_task(f, tuple(info["plane"]) if info.get("plane") else None, info)
718
+ print("g2_a smoke:", json.dumps(t["all"]), "| check info: look", info.get("look"), "scene", info.get("scene_sha256", "")[:8])
719
+ EOF
720
+ else
721
+ log "simcheck: D's reference runs (12 evaluations), then tb10 (9); about 8-10 GPU-h of renders + CPU MuJoCo"
722
+ WORKERS="$WORKERS" PY="$PY" scripts/so101_pick_place/check/run_gates.sh run D "$A/student/s4_v8_roll_s801/it_02000.pt" "$G" ref
723
+ WORKERS="$WORKERS" PY="$PY" scripts/so101_pick_place/check/run_gates.sh run v12_tb10_s1210_it1000 "$STUDENT" "$G"
724
+ PY="$PY" scripts/so101_pick_place/check/run_gates.sh summary v12_tb10_s1210_it1000 "$G"
725
+ fi
726
+ fi
727
+
728
+ # ---------------------------------------------------------------------------------------------------- bundle
729
+ BUNDLE="$OUT/bundle/so101_hw_v13_tb10"
730
+ if has_step bundle; then
731
+ log "bundle: make_orin_bundle.sh $STUDENT -> $BUNDLE"
732
+ SO101_KIN_POINTS="$A/rl_inputs/geometry/kin_points_v1.npz" PYTHON="$PY" \
733
+ scripts/so101_policy/real2sim/hw/make_orin_bundle.sh "$STUDENT" "$BUNDLE" "$CALIB"
734
+ "$PY" - "$BUNDLE/MANIFEST.txt" "$A/bundle/so101_hw_v13_tb10/MANIFEST.txt" <<'EOF'
735
+ import sys
736
+ read = lambda p: {l.split(None, 1)[1].strip(): l.split()[0] for l in open(p).read().splitlines()[3:]}
737
+ mine, ref = read(sys.argv[1]), read(sys.argv[2])
738
+ same = sorted(k for k in mine.keys() & ref.keys() if mine[k] == ref[k])
739
+ diff = sorted(k for k in mine.keys() & ref.keys() if mine[k] != ref[k])
740
+ print(f"bundle vs the released bundle: {len(same)} files equal, {len(diff)} differ {diff}, only here "
741
+ f"{sorted(mine.keys() - ref.keys())}, only in the released one {sorted(ref.keys() - mine.keys())}")
742
+ EOF
743
+ fi
744
+
745
+ # ---------------------------------------------------------------------------------------------------- fake robot
746
+ if has_step fake; then
747
+ [ -d "$BUNDLE" ] || die "no bundle $BUNDLE (run the bundle step)"
748
+ FB="$OUT/fakebin"; mkdir -p "$FB"
749
+ PYABS="$(command -v "$PY")"
750
+ cat > "$FB/python" <<EOF
751
+ #!/usr/bin/env bash
752
+ # fake robot (reproduce.sh): run_student_real.py gets --backend fake --auto-confirm --device cpu and the LeRobot
753
+ # motor calibration of the lab robot; no device is opened
754
+ export PYTHONDONTWRITEBYTECODE=1 CUDA_VISIBLE_DEVICES=
755
+ if [[ "\${1:-}" == *run_student_real.py ]]; then
756
+ exec "$PYABS" "\$@" --backend fake --auto-confirm --device cpu --lerobot-calib "$CODE/configs/so101_pick_place/so101_follower_lerobot_calib.json"
757
+ fi
758
+ exec "$PYABS" "\$@"
759
+ EOF
760
+ chmod +x "$FB/python"
761
+ F="$OUT/fake"; mkdir -p "$F"
762
+ REC="$A/robot/lerobot_recordings"
763
+ for b in "$BUNDLE" "$A/bundle/so101_hw_v13_tb10"; do
764
+ tag=$([ "$b" = "$BUNDLE" ] && echo built || echo released)
765
+ [ "$tag" = released ] && { rm -rf "$F/released_bundle"; cp -r "$b" "$F/released_bundle"; b="$F/released_bundle"
766
+ chmod +x "$b/robot_test.sh"; } # the Hub keeps no file modes
767
+ (cd "$b" && sed -n '4,$p' MANIFEST.txt | sha256sum -c --quiet) || die "$tag bundle: MANIFEST.txt check failed"
768
+ echo "$tag bundle: MANIFEST OK"
769
+ if [ "$tag" = built ]; then
770
+ log "fake: robot_test.sh check (the sections that need the robot computer fail here: CUDA, port, cameras, LeRobot calibration)"
771
+ rc=0; (cd "$b" && PATH="$FB:$PATH" CONDA_DEFAULT_ENV=lerobot timeout 300 ./robot_test.sh check > "$F/check.log" 2>&1) || rc=$?
772
+ echo "check exit $rc (nonzero expected off the robot computer); $(grep -c -i 'fail\|missing' "$F/check.log") lines with FAIL / missing"
773
+ log "fake: robot_test.sh eval 1 6 (one 6 s episode on the fake robot)"
774
+ rc=0; (cd "$b" && PATH="$FB:$PATH" CONDA_DEFAULT_ENV=lerobot RUNS="$F/runs" timeout 900 \
775
+ script -qec "./robot_test.sh eval 1 6" /dev/null > "$F/eval.log" 2>&1) || rc=$?
776
+ echo "eval exit $rc"; [ "$rc" = 0 ] || die "fake eval failed ($F/eval.log)"
777
+ fi
778
+ log "fake: robot_test.sh replay with the $tag bundle (3 recordings)"
779
+ rc=0; (cd "$b" && PATH="$FB:$PATH" CONDA_DEFAULT_ENV=lerobot RUNS="$F/runs_$tag" DATA_ROOT="$REC" timeout 1800 \
780
+ ./robot_test.sh replay > "$F/replay_$tag.log" 2>&1) || rc=$?
781
+ echo "replay ($tag) exit $rc"; [ "$rc" = 0 ] || die "fake replay failed ($F/replay_$tag.log)"
782
+ done
783
+ "$PY" - "$F/runs_built" "$F/runs_released" <<'EOF'
784
+ import sys
785
+ from pathlib import Path
786
+ import numpy as np
787
+ def chunks(root):
788
+ out = {}
789
+ for f in sorted(Path(root).rglob("*.npz")):
790
+ z = np.load(f, allow_pickle=False)
791
+ key = str(f.relative_to(root)).split("/", 1)[-1]
792
+ out[key] = {k: z[k] for k in ("q_sim", "qd_sim", "qry_step", "qry_thumbs", "qry_chunk") if k in z.files}
793
+ return out
794
+ a, b = chunks(sys.argv[1]), chunks(sys.argv[2])
795
+ if not a or a.keys() != b.keys():
796
+ sys.exit(f"replay outputs differ in their files: {sorted(a)} vs {sorted(b)}")
797
+ worst, n = 0.0, 0
798
+ for k in a:
799
+ for name in a[k].keys() & b[k].keys():
800
+ x, y = a[k][name], b[k][name]
801
+ n += 1
802
+ worst = max(worst, float(np.abs(x.astype(np.float64) - y.astype(np.float64)).max()) if x.shape == y.shape else float("inf"))
803
+ print(f"replay, built vs released bundle: {len(a)} recordings, {n} arrays compared, max |diff| {worst:.3g}")
804
+ EOF
805
+ fi
806
+
807
+ # ---------------------------------------------------------------------------------------------------- robot results
808
+ if has_step robot; then
809
+ log "robot: the result tables from the released logs (build_results.py), next to results/robot/results.json"
810
+ mkdir -p "$OUT/robot"
811
+ "$PY" -I scripts/so101_pick_place/robot/build_results.py --logs "$A/robot/logs" \
812
+ --stress "$A/results/robot/stress_episodes.json" --out "$OUT/robot" > "$OUT/robot/build.log"
813
+ "$PY" - "$OUT/robot/results.json" "$A/results/robot/results.json" <<'EOF'
814
+ import json, sys
815
+ a, b = (json.load(open(p)) for p in sys.argv[1:3])
816
+ for d in (a, b):
817
+ for k in ("built_by", "logs_root", "stress_meta"):
818
+ d.pop(k)
819
+ for s in d["students"].values():
820
+ s.pop("local_bundle")
821
+ t = a["per_student"]["tb10"]["stress_20261027"]
822
+ print(f"robot tables: equal to the released results.json (source paths aside): {a == b}; tb10 stress {t['placed']}/{t['n']}")
823
+ EOF
824
+ fi
825
+
826
+ # ---------------------------------------------------------------------------------------------------- summary
827
+ if has_step summary; then
828
+ log "summary: this run next to the released records"
829
+ "$PY" - "$RUNS" "$A" <<'EOF'
830
+ import json, sys
831
+ from pathlib import Path
832
+ runs, A = Path(sys.argv[1]), Path(sys.argv[2])
833
+ REL = {"t3_jt_b140": None, "t4_jt_h110": None, "t5_tppo_roll_v8_s21": "teacher/t5_tppo_roll_v8_s21/dev_evals.jsonl",
834
+ "t6_tppo_v12_fr10_s122": "teacher/t6_tppo_v12_fr10_s122/dev_evals.jsonl"}
835
+ for name, rel in REL.items():
836
+ f = runs / name / "dev_evals.jsonl"
837
+ if not f.is_file():
838
+ continue
839
+ last = json.loads(f.read_text().splitlines()[-1])
840
+ ref = json.loads((A / rel).read_text().splitlines()[-1]) if rel else None
841
+ for s, v in last["sets"].items():
842
+ r = (ref or {}).get("sets", {}).get(s, {}) if ref else {}
843
+ print(f"{name} it {last['iteration']} {s}: lenient {v['lenient']:.2f} strict {v['strict']:.2f} | released it "
844
+ f"{ref['iteration'] if ref else '-'}: {r.get('lenient', '-')} / {r.get('strict', '-')}")
845
+ for d in sorted(runs.glob("s[1-5]_*")):
846
+ f = d / "progress.jsonl"
847
+ if not f.is_file():
848
+ continue
849
+ rel = A / "student" / d.name / "progress.jsonl"
850
+ ev = lambda p: [json.loads(l) for l in p.read_text().splitlines() if '"stage": "eval' in l]
851
+ mine, ref = ev(f), (ev(rel) if rel.is_file() else [])
852
+ for e in mine[-2:]:
853
+ print(f"{d.name} {e['stage']}: lenient {e['lenient']:.2f} strict {e['strict']:.2f}")
854
+ for e in ref[-2:]:
855
+ print(f"{d.name} released {e['stage']}: lenient {e['lenient']:.2f} strict {e['strict']:.2f}")
856
+ EOF
857
+ G="$OUT/simcheck/out/gates/local/v12_tb10_s1210_it1000.json"
858
+ if [ -f "$G" ]; then
859
+ "$PY" - "$G" "$A/results/sim_checks/v12_tb10_s1210_it1000.json" <<'EOF'
860
+ import json, sys
861
+ a, b = (json.load(open(p)) for p in sys.argv[1:3])
862
+ for k in ("G2",):
863
+ for m in ("grasp", "place", "carry_stop"):
864
+ print(f"sim check G2 {m}: {a['gates'][k][m]['cand']} (released, AMD MI350X: {b['gates'][k][m]['cand']})")
865
+ for p in ("g3_m3", "g3_p3"):
866
+ print(f"sim check G3 {p}: " + ", ".join(f"{m} {a['gates']['G3']['planes'][p][m]['cand']} / {b['gates']['G3']['planes'][p][m]['cand']}"
867
+ for m in ("grasp", "place", "carry_stop")))
868
+ print(f"G1 {a['gates']['G1']['cand']} % (released {b['gates']['G1']['cand']} %); veto {a['vetoed']} (released {b['vetoed']})")
869
+ EOF
870
+ fi
871
+ fi
872
+ log "done: $OUT"
so101_pick_place/code/scripts/so101_pick_place/robot/build_results.py ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Robot evidence tables for the SO101 pick-and-place release (read-only on robot_logs).
2
+
3
+ Reads the raw session logs (session.json + ep_*/episode_live.{json,npz}) and writes results.json / results.md.
4
+ Student identity = the bundle folder in ep_*/episode_live.json setup.kin_points (/home/sbel/<bundle>/assets/...);
5
+ the logs hold no checkpoint hash. The checkpoint and sha256 of each bundle are the study's record of its local copy of
6
+ that bundle (MANIFEST.txt, assets/student.pt), read from the released results.json (--students).
7
+ Place = session.json episodes[].place (the "p" letter typed by the person at the robot); re-checked against the typed
8
+ code and against ep_*/episode_live.json outcome.
9
+
10
+ python3 build_results.py --logs <Hub robot/logs> --stress <Hub results/robot/stress_episodes.json> --out DIR \
11
+ [--students <Hub results/robot/results.json>] [--bundles DIR]
12
+
13
+ Ported from the study's release script (the folders are arguments). Only the tb10 bundle is released
14
+ (bundle/so101_hw_v13_tb10/ on the Hub), so the bundle line, checkpoint and student.pt sha256 of each robot bundle come
15
+ from the "students" record of the released results.json (default: next to --stress); with --bundles DIR (a folder
16
+ that holds <bundle>/MANIFEST.txt and <bundle>/assets/student.pt) a bundle found there is read and checked against the
17
+ record. The results.json written equals the released one except the source paths it names; results.md has the Hub
18
+ checkpoint paths in place of the study's local ones.
19
+
20
+ The cube / plate positions, the direction labels and the end distances come from stress_episodes.json: an image +
21
+ kinematics analysis of the study whose script was not found (it is not released). This script only reads them.
22
+ """
23
+ import argparse
24
+ import glob
25
+ import hashlib
26
+ import json
27
+ import math
28
+ import os
29
+ import sys
30
+
31
+ import numpy as np
32
+
33
+ LOGS = OUT = STRESS_JSON = BUNDLE_DIR = None # set by main() from the arguments
34
+ BUNDLES = {} # bundle -> (label, record): main() fills it from --students
35
+
36
+ STRESS = ["eval_20261027_145520", "eval_20261027_150916", "eval_20261027_151136", "eval_20261027_151953",
37
+ "eval_20261027_153045", "eval_20261027_153943"]
38
+ SCREEN = ["eval_20261027_133039", "eval_20261027_133521", "eval_20261027_133953", "eval_20261027_134411",
39
+ "eval_20261027_134903", "eval_20261027_135259", "eval_20261027_135657", "eval_20261027_140036"]
40
+
41
+ # bundle folder on the robot computer -> label; the record of each bundle (MANIFEST.txt line 1, checkpoint, sha256 of
42
+ # assets/student.pt) is the "students" block of the released results.json
43
+ LABELS = {"so101_hw_v8_roll801": "D", "so101_hw_v13_tb10": "tb10", "so101_hw_v13_visR500": "visR500",
44
+ "so101_hw_v13q_visR_s1304_it750": "visR_s1304_it750",
45
+ "so101_hw_v13q_visRtb05_s1301_it500": "visRtb05_s1301_it500", "so101_hw_v13_tb05": "tb05",
46
+ "so101_hw_v13_visR0_250": "visR0_250"}
47
+ # the released checkpoints on the Hub (the other robot students are not released)
48
+ HUB_CKPT = {"tb10": "student/s5_v12_tb10_s1210/it_01000.pt", "D": "student/s4_v8_roll_s801/it_02000.pt"}
49
+ # plain names of the screened students (results/sim_checks/LAB_PLAN_v13.md on the Hub)
50
+ PLAIN = {"tb10": "lower table 10 mm, 1,000 steps (released)", "D": "previous robot student (released)",
51
+ "visR500": "visual fix, seed 1231, 500 steps", "visR_s1304_it750": "visual fix, seed 1304, 750 steps",
52
+ "visRtb05_s1301_it500": "visual fix + 5 mm lower table, 500 steps", "tb05": "lower table 5 mm, 1,500 steps",
53
+ "visR0_250": "real-look gripper, no randomisation, 250 steps"}
54
+
55
+
56
+ def load_bundles(students_json):
57
+ """BUNDLES from the "students" block of the released results.json (label -> bundle, built, checkpoint, sha256)."""
58
+ rec = json.load(open(students_json))["students"]
59
+ for name, label in LABELS.items():
60
+ r = rec[label]
61
+ if r["bundle"] != name:
62
+ raise SystemExit(f"{students_json}: student {label} has bundle {r['bundle']}, expected {name}")
63
+ BUNDLES[name] = (label, {k: r[k] for k in ("built", "student_ckpt_local", "student_sha256")})
64
+
65
+
66
+ def sha256(p):
67
+ h = hashlib.sha256()
68
+ with open(p, "rb") as f:
69
+ for b in iter(lambda: f.read(1 << 20), b""):
70
+ h.update(b)
71
+ return h.hexdigest()
72
+
73
+
74
+ def wilson(k, n, z=1.96):
75
+ if n == 0:
76
+ return (float("nan"), float("nan"))
77
+ p = k / n
78
+ d = 1 + z * z / n
79
+ c = (p + z * z / (2 * n)) / d
80
+ h = z * math.sqrt(p * (1 - p) / n + z * z / (4 * n * n)) / d
81
+ return (c - h, c + h)
82
+
83
+
84
+ def bundle_info(name):
85
+ label, rec = BUNDLES[name]
86
+ path = f"{BUNDLE_DIR}/{name}" if BUNDLE_DIR else None
87
+ if path is None or not os.path.exists(f"{path}/MANIFEST.txt"):
88
+ return dict(label=label, bundle=name, local_bundle=None, **rec)
89
+ man = open(f"{path}/MANIFEST.txt").read().splitlines()
90
+ ck = man[1].split()[1] if man[1].startswith("student ") else None
91
+ out = dict(label=label, bundle=name, local_bundle=path, built=man[0], student_ckpt_local=ck,
92
+ student_sha256=sha256(f"{path}/assets/student.pt"))
93
+ if out["student_sha256"] != rec["student_sha256"]:
94
+ raise SystemExit(f"{path}: student.pt sha256 {out['student_sha256'][:16]} is not the recorded "
95
+ f"{rec['student_sha256'][:16]}")
96
+ return out
97
+
98
+
99
+ def session_student(sess):
100
+ names = set()
101
+ for e in sorted(glob.glob(f"{LOGS}/{sess}/ep_*/episode_live.json")):
102
+ kp = json.load(open(e))["setup"]["kin_points"]
103
+ names.add(kp.split("/")[3])
104
+ assert len(names) == 1, (sess, names)
105
+ return names.pop()
106
+
107
+
108
+ def all_d_sessions():
109
+ out = []
110
+ for d in sorted(glob.glob(f"{LOGS}/eval_2026102[4-7]_*")):
111
+ s = os.path.basename(d)
112
+ if not os.path.exists(f"{d}/session.json"):
113
+ continue
114
+ if session_student(s) == "so101_hw_v8_roll801":
115
+ out.append(s)
116
+ return out
117
+
118
+
119
+ def parse_code(typed):
120
+ code = (typed or "").strip().partition(" ")[0].lower()
121
+ return dict(grasp="g" in code, lift="l" in code, place="p" in code)
122
+
123
+
124
+ def episodes(sess, group, binfo, stress_idx):
125
+ S = json.load(open(f"{LOGS}/{sess}/session.json"))
126
+ rows, excluded = [], []
127
+ listed = {e["episode"] for e in S["episodes"]}
128
+ for epdir in sorted(glob.glob(f"{LOGS}/{sess}/ep_*")):
129
+ k = int(epdir.rsplit("_", 1)[1])
130
+ J = json.load(open(f"{epdir}/episode_live.json"))
131
+ if k not in listed:
132
+ excluded.append(dict(session=sess, ep=f"ep_{k:02d}", end_reason=J.get("end_reason"),
133
+ outcome=J.get("outcome"), episode_start=J.get("episode_start"),
134
+ why="not in session.json episodes[]; no policy step was run"))
135
+ for e in S["episodes"]:
136
+ k = e["episode"]
137
+ epdir = f"{LOGS}/{sess}/ep_{k:02d}"
138
+ J = json.load(open(f"{epdir}/episode_live.json"))
139
+ z = np.load(f"{epdir}/episode_live.npz", allow_pickle=False)
140
+ t = z["t"]
141
+ qt = z["qry_t"]
142
+ pc = parse_code(e.get("typed"))
143
+ o = J.get("outcome") or {}
144
+ r = dict(session=sess, ep=f"ep_{k:02d}", group=group, student=binfo["label"], bundle=binfo["bundle"],
145
+ student_sha8=binfo["student_sha256"][:8], start=e.get("start"), typed=e.get("typed"),
146
+ grasp=e.get("grasp"), lift=e.get("lift"), place=int(bool(e.get("place"))),
147
+ end_reason=e.get("end_reason"), duration_s=round(float(t[-1]), 2), n_steps=int(len(t)),
148
+ n_queries=int(len(qt)),
149
+ check_typed_code=(pc["place"] == bool(e.get("place")) and pc["grasp"] == bool(e.get("grasp"))
150
+ and pc["lift"] == bool(e.get("lift"))),
151
+ check_episode_json=(o.get("place") == e.get("place") and o.get("typed") == e.get("typed")))
152
+ sid = f"{sess.split('_')[-1]}/ep_{k:02d}"
153
+ if stress_idx is not None:
154
+ s = stress_idx.get(sid)
155
+ if s is None:
156
+ r["stress_row"] = None
157
+ else:
158
+ r.update(dir=s["dir"], cube_side=s["side"], cube_r_mm=round(s["cube_r"], 1),
159
+ cube_deg=round(s["cube_deg"], 1), plate_r_mm=round(s["plate_r"], 1),
160
+ plate_deg=round(s["plate_deg"], 1),
161
+ end_to_plate_mm=(None if s.get("end_to_plate") is None else round(s["end_to_plate"], 1)),
162
+ fail_class=s.get("fail"),
163
+ plate_minus_cube_y_mm=round(s["plate_r"] * math.sin(math.radians(s["plate_deg"]))
164
+ - s["cube_r"] * math.sin(math.radians(s["cube_deg"])), 1),
165
+ check_stress_json=(bool(s["placed"]) == bool(e.get("place")) and s["typed"] == e.get("typed")))
166
+ rows.append(r)
167
+ return rows, excluded
168
+
169
+
170
+ def tally(rows):
171
+ k, n = sum(r["place"] for r in rows), len(rows)
172
+ lo, hi = wilson(k, n)
173
+ return dict(placed=k, n=n, rate=round(k / n, 4) if n else None, wilson95=[round(lo, 4), round(hi, 4)])
174
+
175
+
176
+ def main():
177
+ global LOGS, OUT, STRESS_JSON, BUNDLE_DIR
178
+ p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
179
+ p.add_argument("--logs", required=True, help="robot/logs of the Hub folder (one folder per session)")
180
+ p.add_argument("--stress", required=True, help="results/robot/stress_episodes.json of the Hub folder")
181
+ p.add_argument("--out", required=True, help="folder for results.json and results.md")
182
+ p.add_argument("--students", default="", help="the released results/robot/results.json (its 'students' record; "
183
+ "default: results.json next to --stress)")
184
+ p.add_argument("--bundles", default="", help="optional folder with local bundle copies (checked against the record)")
185
+ a = p.parse_args()
186
+ LOGS, OUT, STRESS_JSON, BUNDLE_DIR = a.logs, a.out, a.stress, a.bundles or None
187
+ missing = [s for s in STRESS + SCREEN if not glob.glob(f"{LOGS}/{s}/ep_*/episode_live.json")]
188
+ if missing:
189
+ sys.exit(f"robot logs not found in {LOGS} ({len(missing)} sessions, e.g. {missing[0]}): download the robot "
190
+ f"group (reproduce.sh --with-robot, or download.py --groups robot)")
191
+ load_bundles(a.students or os.path.join(os.path.dirname(os.path.abspath(a.stress)), "results.json"))
192
+ os.makedirs(OUT, exist_ok=True)
193
+ stress_list = json.load(open(STRESS_JSON))
194
+ sidx = {s["id"]: s for s in stress_list}
195
+ binfo = {}
196
+ rows, excluded = [], []
197
+ sessions = {}
198
+ d_sessions = all_d_sessions()
199
+ plan = [(s, "stress_tb10") for s in STRESS] + [(s, "screening_20261027") for s in SCREEN] + \
200
+ [(s, "D_20261024_26") for s in d_sessions if s not in SCREEN]
201
+ for sess, group in plan:
202
+ bname = session_student(sess)
203
+ if bname not in binfo:
204
+ binfo[bname] = bundle_info(bname)
205
+ rr, ex = episodes(sess, group, binfo[bname], sidx if group == "stress_tb10" else None)
206
+ rows += rr
207
+ excluded += ex
208
+ sessions[sess] = dict(group=group, student=binfo[bname]["label"], bundle=bname, n_episodes=len(rr),
209
+ placed=sum(r["place"] for r in rr), start=json.load(open(f"{LOGS}/{sess}/session.json"))["start"])
210
+
211
+ stress = [r for r in rows if r["group"] == "stress_tb10"]
212
+ # independent recount (raw session.json only, no stress_episodes.json)
213
+ raw_place = 0
214
+ raw_n = 0
215
+ for s in STRESS:
216
+ S = json.load(open(f"{LOGS}/{s}/session.json"))
217
+ raw_n += len(S["episodes"])
218
+ raw_place += sum(1 for e in S["episodes"] if e.get("place") is True)
219
+ by_dir = {}
220
+ for d in ("R->L", "L->R"):
221
+ by_dir[d] = tally([r for r in stress if r.get("dir") == d])
222
+ stress_ids = {f"{r['session'].split('_')[-1]}/{r['ep']}" for r in stress}
223
+ recount = dict(
224
+ source="robot_logs/<session>/session.json episodes[].place for the 6 stress sessions",
225
+ n_episodes=raw_n, placed=raw_place, report_claim="36/50", agrees=(raw_place == 36 and raw_n == 50),
226
+ typed_code_agrees_all=all(r["check_typed_code"] for r in stress),
227
+ episode_json_agrees_all=all(r["check_episode_json"] for r in stress),
228
+ stress_json_agrees_all=all(r.get("check_stress_json") for r in stress),
229
+ stress_json_ids_match=(stress_ids == set(sidx)),
230
+ dir_matches_lateral_y=sum((r["plate_minus_cube_y_mm"] > 0) == (r["dir"] == "R->L") for r in stress),
231
+ dir_near_ambiguous_lt15mm=[f"{r['session']}/{r['ep']}" for r in stress if abs(r["plate_minus_cube_y_mm"]) < 15],
232
+ by_dir=by_dir,
233
+ by_session={s: sessions[s]["placed"] for s in STRESS},
234
+ )
235
+
236
+ screen = [r for r in rows if r["group"] == "screening_20261027"]
237
+ d_all = [r for r in rows if r["student"] == "D"]
238
+ per_student = {}
239
+ for lab in [v[0] for v in BUNDLES.values()]:
240
+ per_student[lab] = dict(
241
+ screening_20261027=tally([r for r in screen if r["student"] == lab]),
242
+ )
243
+ per_student["tb10"]["stress_20261027"] = tally(stress)
244
+ per_student["tb10"]["stress_by_dir"] = by_dir
245
+ per_student["tb10"]["all_20261027"] = tally([r for r in rows if r["student"] == "tb10"])
246
+ per_student["D"]["all_20261024_27"] = tally(d_all)
247
+ per_student["D"]["by_day"] = {day: tally([r for r in d_all if r["session"].startswith(f"eval_{day}")])
248
+ for day in ("20261024", "20261025", "20261026", "20261027")}
249
+
250
+ res = dict(
251
+ built_by="scripts/so101_pick_place/robot/build_results.py", logs_root=LOGS, stress_meta=STRESS_JSON,
252
+ students={b["label"]: {k: v for k, v in b.items() if k != "label"} for b in binfo.values()},
253
+ sessions=sessions, excluded=excluded, stress_recount=recount, per_student=per_student,
254
+ screening_all=tally(screen), episodes=rows)
255
+ json.dump(res, open(f"{OUT}/results.json", "w"), indent=1)
256
+
257
+ # ---- markdown
258
+ L = []
259
+ L.append("# SO101 robot results (from the raw logs)\n")
260
+ L.append("Source: the session logs of the Hub folder `robot/logs/<session>/` (`session.json`: typed outcome; "
261
+ "`ep_NN/episode_live.{json,npz}`), counted by `scripts/so101_pick_place/robot/build_results.py`. "
262
+ "Place = the person at the robot typed `p` (cube on the plate). Cube / plate positions and directions: "
263
+ "`results/robot/stress_episodes.json` (an image + kinematics estimate; the script that wrote it was not "
264
+ "found and is not released).\n")
265
+ L.append("## Students\n")
266
+ L.append("| Label | Student | Bundle on the robot computer | Checkpoint on the Hub | student.pt sha256 (first 16) |")
267
+ L.append("|---|---|---|---|---|")
268
+ for b in binfo.values():
269
+ L.append(f"| {b['label']} | {PLAIN.get(b['label'], '')} | {b['bundle']} | "
270
+ f"{('`' + HUB_CKPT[b['label']] + '`') if b['label'] in HUB_CKPT else 'not released'} "
271
+ f"| {b['student_sha256'][:16]} |")
272
+ L.append("")
273
+ L.append("The logs do not record a checkpoint hash: the student of each session is known from the bundle folder "
274
+ "named in the logs (`setup.kin_points`) and the study's local copy of that bundle; the files on the robot "
275
+ "computer were not compared with `MANIFEST.txt`.\n")
276
+ L.append("## Totals\n")
277
+ L.append("| Student | Test | Places | Rate | 95 % (Wilson) |")
278
+ L.append("|---|---|---|---|---|")
279
+
280
+ def row(lab, test, t):
281
+ L.append(f"| {lab} | {test} | {t['placed']}/{t['n']} | {100 * t['rate']:.0f} % | "
282
+ f"{100 * t['wilson95'][0]:.0f}-{100 * t['wilson95'][1]:.0f} % |")
283
+ row("tb10", "stress 10-27 (6 sessions)", per_student["tb10"]["stress_20261027"])
284
+ for d in ("R->L", "L->R"):
285
+ row("tb10", f"stress, {d}", by_dir[d])
286
+ row("tb10", "all 10-27 (screening + stress)", per_student["tb10"]["all_20261027"])
287
+ row("D", "all 10-24..10-27 (7 sessions)", per_student["D"]["all_20261024_27"])
288
+ for day, t in per_student["D"]["by_day"].items():
289
+ row("D", f"day {day}", t)
290
+ for lab in per_student:
291
+ row(lab, "screening 10-27", per_student[lab]["screening_20261027"])
292
+ row("all 7", "screening 10-27", tally(screen))
293
+ L.append("")
294
+ L.append("## Independent recount of the stress test\n")
295
+ L.append(f"- session.json place flags, 6 sessions: **{raw_place}/{raw_n}** (report claim 36/50; agrees: "
296
+ f"{recount['agrees']}).")
297
+ L.append(f"- Per session: " + ", ".join(f"{s.split('_')[-1]} {sessions[s]['placed']}/{sessions[s]['n_episodes']}"
298
+ for s in STRESS))
299
+ L.append(f"- Typed code letters agree with the flags: {recount['typed_code_agrees_all']}; "
300
+ f"ep_NN/episode_live.json outcome agrees: {recount['episode_json_agrees_all']}; "
301
+ f"stress_episodes.json placed/typed agree: {recount['stress_json_agrees_all']}; "
302
+ f"same 50 episode ids: {recount['stress_json_ids_match']}.")
303
+ L.append(f"- Direction label (stress_episodes.json `dir`) = sign of the arm-frame lateral offset plate y - cube y "
304
+ f"(y = r sin(deg)): {recount['dir_matches_lateral_y']}/50 agree; |offset| < 15 mm (near ambiguous): "
305
+ f"{', '.join(recount['dir_near_ambiguous_lt15mm']) or 'none'}.")
306
+ for x in excluded:
307
+ L.append(f"- Excluded: {x['session']}/{x['ep']} ({x['end_reason']}; {x['why']}).")
308
+ L.append("")
309
+ L.append("## Episodes\n")
310
+ L.append("| Session | Ep | Group | Student | Typed | Place | Dir | Cube r mm / deg | End reason | Duration s |")
311
+ L.append("|---|---|---|---|---|---|---|---|---|---|")
312
+ for r in rows:
313
+ geo = f"{r['cube_r_mm']:.0f} / {r['cube_deg']:+.0f}" if "cube_r_mm" in r else ""
314
+ L.append(f"| {r['session']} | {r['ep']} | {r['group']} | {r['student']} | {r['typed']} | {r['place']} | "
315
+ f"{r.get('dir', '')} | {geo} | {r['end_reason']} | {r['duration_s']:.1f} |")
316
+ open(f"{OUT}/results.md", "w").write("\n".join(L) + "\n")
317
+ print(json.dumps(dict(recount=recount, per_student=per_student, excluded=excluded), indent=1))
318
+
319
+
320
+ if __name__ == "__main__":
321
+ sys.exit(main())
so101_pick_place/code/scripts/so101_pick_place/robot/render_videos.py ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Robot test videos from the logged student input images (read-only on robot_logs).
2
+
3
+ Source per episode: ep_NN/episode_live.npz qry_thumbs [n_query, 2 (external, wrist), 112, 112, 3] uint8 RGB and qry_t (s).
4
+ These are the student's 224 px input images (external: crop 52,103,288,288 of the 640x480 frame; wrist: the full frame
5
+ squashed to a square), logged at 112 px at every policy query (about 7.8 Hz). No full-resolution recording exists.
6
+
7
+ Outputs (H.264, CRF 23, yuv420p):
8
+ videos/stress_tb10/<session>_<ep>.mp4 one per stress episode, real time, 25 fps (each image held until the next query)
9
+ videos/tb10_stress_20261027_4x.mp4 all 50 stress episodes at 4x with a title card each + a final card
10
+ videos/screening_20261027_4x.mp4 the 10-27 screening (8 sessions x 4, 7 students) at 4x
11
+
12
+ python3 render_videos.py [all|per_episode|stress_comp|screen_comp] --logs <Hub robot/logs> \
13
+ --results <results.json of build_results.py> --out DIR (needs ffmpeg with libx264)
14
+
15
+ Ported from the study's ~/so101_r2s_claude/release/robot/scripts/render_videos.py: the folders are arguments.
16
+ """
17
+ import argparse
18
+ import json
19
+ import os
20
+ import subprocess
21
+
22
+ import cv2
23
+ import numpy as np
24
+
25
+ LOGS = OUT = RESULTS = None # set from the arguments
26
+ FPS = 25
27
+ UP = 3
28
+ PANEL = 112 * UP # 336
29
+ W = 2 * PANEL # 672
30
+ HDR = 78
31
+ H = PANEL + HDR # 414
32
+ FONT = cv2.FONT_HERSHEY_SIMPLEX
33
+
34
+
35
+ def encoder(path):
36
+ cmd = ["ffmpeg", "-hide_banner", "-loglevel", "error", "-y", "-f", "rawvideo", "-pix_fmt", "rgb24",
37
+ "-s", f"{W}x{H}", "-r", str(FPS), "-i", "-", "-c:v", "libx264", "-preset", "medium", "-crf", "23",
38
+ "-pix_fmt", "yuv420p", "-threads", "4", "-movflags", "+faststart", path]
39
+ return subprocess.Popen(cmd, stdin=subprocess.PIPE)
40
+
41
+
42
+ def text(img, s, y, scale=0.48, color=(255, 255, 255), x=6, th=1):
43
+ cv2.putText(img, s, (x, y), FONT, scale, color, th, cv2.LINE_AA)
44
+
45
+
46
+ def panels(th):
47
+ ext = cv2.resize(th[0], (PANEL, PANEL), interpolation=cv2.INTER_NEAREST)
48
+ wr = cv2.resize(th[1], (PANEL, PANEL), interpolation=cv2.INTER_NEAREST)
49
+ im = np.concatenate([ext, wr], 1)
50
+ text(im, "external", PANEL - 8, 0.45, (255, 255, 0))
51
+ text(im, "wrist", PANEL - 8, 0.45, (255, 255, 0), x=PANEL + 6)
52
+ return im
53
+
54
+
55
+ def frame(th, lines, colors=None):
56
+ f = np.zeros((H, W, 3), np.uint8)
57
+ f[:HDR] = 30
58
+ for i, s in enumerate(lines):
59
+ text(f, s, 20 + 24 * i, color=(colors or {}).get(i, (255, 255, 255)))
60
+ f[HDR:] = panels(th)
61
+ return f
62
+
63
+
64
+ def card(lines, big=None):
65
+ f = np.zeros((H, W, 3), np.uint8)
66
+ f[:] = 20
67
+ y = 60
68
+ if big:
69
+ sz = cv2.getTextSize(big, FONT, 1.6, 3)[0]
70
+ text(f, big, y + 30, 1.6, (255, 255, 255), x=(W - sz[0]) // 2, th=3)
71
+ y += 90
72
+ for s in lines:
73
+ text(f, s, y, 0.55)
74
+ y += 28
75
+ return f
76
+
77
+
78
+ def load_ep(sess, ep):
79
+ z = np.load(f"{LOGS}/{sess}/{ep}/episode_live.npz", allow_pickle=False)
80
+ return z["qry_thumbs"], z["qry_t"], float(z["t"][-1])
81
+
82
+
83
+ def episode_frames(th, qt, t_end, speed, header, place):
84
+ """Frames at FPS; output frame k shows real time k * speed / FPS (latest image logged at or before it)."""
85
+ n = int(np.floor(t_end * FPS / speed)) + 1
86
+ for k in range(n):
87
+ tk = k * speed / FPS
88
+ i = max(int(np.searchsorted(qt, tk, side="right")) - 1, 0)
89
+ yield frame(th[i], header(tk), {1: outcome_color(place)})
90
+
91
+
92
+ def short(sess):
93
+ return sess.split("_")[-1]
94
+
95
+
96
+ def outcome_color(place):
97
+ return (120, 255, 120) if place else (255, 120, 120)
98
+
99
+
100
+ def main(which):
101
+ R = json.load(open(RESULTS))
102
+ eps = R["episodes"]
103
+ stud = R["students"]
104
+ sizes = {}
105
+ stress = [r for r in eps if r["group"] == "stress_tb10"]
106
+ tb = stud["tb10"]
107
+ tb_ck = "v12_tb10_s1210 it_01000, sha256 " + tb["student_sha256"][:8]
108
+
109
+ if which in ("all", "per_episode"):
110
+ os.makedirs(f"{OUT}/videos/stress_tb10", exist_ok=True)
111
+ for r in stress:
112
+ th, qt, t_end = load_ep(r["session"], r["ep"])
113
+ sid = f"{short(r['session'])}/{r['ep']}"
114
+ geo = (f"{r['dir']} cube r {r['cube_r_mm']:.0f} mm {r['cube_deg']:+.0f} deg, "
115
+ f"plate r {r['plate_r_mm']:.0f} mm {r['plate_deg']:+.0f} deg")
116
+ res = "PLACED" if r["place"] else "NOT PLACED"
117
+
118
+ def hdr(tk, r=r, sid=sid, geo=geo, res=res):
119
+ return [f"tb10 stress {sid} | {r['typed']} | t {tk:5.1f} s",
120
+ f"{res} | {geo}",
121
+ f"real SO101 2026-10-27, student {tb_ck}, 1x"]
122
+ p = f"{OUT}/videos/stress_tb10/{r['session']}_{r['ep']}.mp4"
123
+ enc = encoder(p)
124
+ for f in episode_frames(th, qt, t_end, 1.0, hdr, r["place"]):
125
+ enc.stdin.write(f.tobytes())
126
+ enc.stdin.close()
127
+ assert enc.wait() == 0, p
128
+ sizes[p] = os.path.getsize(p)
129
+ print(p, sizes[p], flush=True)
130
+
131
+ if which in ("all", "stress_comp"):
132
+ p = f"{OUT}/videos/tb10_stress_20261027_4x.mp4"
133
+ enc = encoder(p)
134
+ rc = R["stress_recount"]
135
+ intro = card(["Real SO101 pick-and-place stress test, 2026-10-27 14:55-15:48",
136
+ f"Student tb10: {tb_ck}",
137
+ "Trained in simulation; bundle built 09:32, before the first test",
138
+ "50 policy episodes, 6 sessions; 4x speed",
139
+ "Images: the student's own camera inputs (logged at 112 px)",
140
+ "left: external camera (crop), right: wrist camera",
141
+ "Outcome typed by the person at the robot"], big="tb10 stress test")
142
+ for _ in range(FPS * 4):
143
+ enc.stdin.write(intro.tobytes())
144
+ for j, r in enumerate(stress, 1):
145
+ th, qt, t_end = load_ep(r["session"], r["ep"])
146
+ sid = f"{short(r['session'])}/{r['ep']}"
147
+ res = "PLACED" if r["place"] else "NOT PLACED"
148
+ c = card([f"{r['dir']}: cube r {r['cube_r_mm']:.0f} mm {r['cube_deg']:+.0f} deg, "
149
+ f"plate r {r['plate_r_mm']:.0f} mm {r['plate_deg']:+.0f} deg",
150
+ f"typed: {r['typed']}",
151
+ f"result: {res}"], big=f"{j}/50 {sid}")
152
+ for _ in range(int(FPS * 1.2)):
153
+ enc.stdin.write(c.tobytes())
154
+
155
+ def hdr(tk, r=r, sid=sid, res=res, j=j):
156
+ return [f"tb10 stress {sid} | {r['typed']} | t {tk:5.1f} s",
157
+ f"{res} | {r['dir']} | episode {j}/50",
158
+ "real SO101 2026-10-27, 4x speed"]
159
+ for f in episode_frames(th, qt, t_end, 4.0, hdr, r["place"]):
160
+ enc.stdin.write(f.tobytes())
161
+ bd = rc["by_dir"]
162
+ fin = card([f"R->L (plate left of the cube): {bd['R->L']['placed']}/{bd['R->L']['n']}",
163
+ f"L->R: {bd['L->R']['placed']}/{bd['L->R']['n']}",
164
+ "Session 150916 ep_03 was stopped at HOME before",
165
+ "the policy ran: not counted",
166
+ f"Student {tb_ck}"], big=f"{rc['placed']}/{rc['n_episodes']} placed")
167
+ for _ in range(FPS * 5):
168
+ enc.stdin.write(fin.tobytes())
169
+ enc.stdin.close()
170
+ assert enc.wait() == 0
171
+ sizes[p] = os.path.getsize(p)
172
+ print(p, sizes[p], flush=True)
173
+
174
+ if which in ("all", "screen_comp"):
175
+ p = f"{OUT}/videos/screening_20261027_4x.mp4"
176
+ enc = encoder(p)
177
+ scr = [r for r in eps if r["group"] == "screening_20261027"]
178
+ intro = card(["Real SO101, 2026-10-27 13:30-14:04",
179
+ "8 sessions x 4 episodes, 7 students (D at the start and the end)",
180
+ "Every session: ep 1-2 cube right, ep 3-4 cube left. 4x speed",
181
+ "Images: the student's own camera inputs (112 px logs)",
182
+ "left: external camera (crop), right: wrist camera",
183
+ "Outcome typed by the person at the robot"], big="Screening 10-27")
184
+ for _ in range(FPS * 4):
185
+ enc.stdin.write(intro.tobytes())
186
+ for j, r in enumerate(scr, 1):
187
+ th, qt, t_end = load_ep(r["session"], r["ep"])
188
+ sid = f"{short(r['session'])}/{r['ep']}"
189
+ res = "PLACED" if r["place"] else "NOT PLACED"
190
+ ck = stud[r["student"]]["student_ckpt_local"].split("/ckpt/")[-1]
191
+ c = card([f"student {r['student']} ({ck}, sha256 {r['student_sha8']})",
192
+ f"typed: {r['typed']}", f"result: {res}"], big=f"{j}/32 {sid}")
193
+ for _ in range(int(FPS * 1.2)):
194
+ enc.stdin.write(c.tobytes())
195
+
196
+ def hdr(tk, r=r, sid=sid, res=res, j=j):
197
+ return [f"{r['student']} screening {sid} | {r['typed']} | t {tk:5.1f} s",
198
+ f"{res} | episode {j}/32",
199
+ "real SO101 2026-10-27, 4x speed"]
200
+ for f in episode_frames(th, qt, t_end, 4.0, hdr, r["place"]):
201
+ enc.stdin.write(f.tobytes())
202
+ ps = R["per_student"]
203
+ lines = [f"{lab}: {ps[lab]['screening_20261027']['placed']}/{ps[lab]['screening_20261027']['n']}"
204
+ for lab in ps]
205
+ a = R["screening_all"]
206
+ fin = card(lines + [f"all: {a['placed']}/{a['n']}"], big="Screening places")
207
+ for _ in range(FPS * 5):
208
+ enc.stdin.write(fin.tobytes())
209
+ enc.stdin.close()
210
+ assert enc.wait() == 0
211
+ sizes[p] = os.path.getsize(p)
212
+ print(p, sizes[p], flush=True)
213
+
214
+
215
+
216
+ if __name__ == "__main__":
217
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
218
+ ap.add_argument("which", nargs="?", default="all", choices=("all", "per_episode", "stress_comp", "screen_comp"))
219
+ ap.add_argument("--logs", required=True)
220
+ ap.add_argument("--results", required=True)
221
+ ap.add_argument("--out", required=True, help="the videos go to <out>/videos/")
222
+ a = ap.parse_args()
223
+ LOGS, RESULTS, OUT = a.logs, a.results, a.out
224
+ main(a.which)
so101_pick_place/code/scripts/so101_policy/real2sim/hw/QDGAIN_TEST.md ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Robot test: joint-speed input gain (`--qd-gain`)
2
+
3
+ > Historical test plan of 2026-10-22 for an option that the released student does not use (kept because the
4
+ > robot bundle carries this file).
5
+
6
+ Written 2026-10-22 evening for an agent that guides the user at the SO101 robot (proxy, Jetson AGX Orin). The user runs
7
+ every command at the robot. The agent explains, reads the outputs and the logs, and keeps the rules below.
8
+
9
+ ## 1. Why this test
10
+
11
+ | Item | Value |
12
+ |---|---|
13
+ | Robot result on 2026-10-22 (today's student, `eval`) | Grasp and lift 12 of 12; release 2 of 12. The arm holds the cube still 1-5 cm above the plate and never opens the gripper. |
14
+ | Cause (found in the sim) | The student sets its step size from the MEASURED joint speed. The real arm is about 5 times slower than the sim arm. So near the plate the steps get smaller and smaller, and the arm stops. |
15
+ | Sim proof (today's student, robot-like sim, 48 episodes) | Joint-speed input x 0 / 1 / 2 / 3 / 4 / 5: success 10 / 50 / 88 / 94 / 83 / 48 %. At 5 the arm hits the table. |
16
+ | Same, normal-speed sim | x 1 / 2 / 3: 98 / 90 / 75 %. A high gain makes a FAST arm too aggressive. The real arm is slow, so 2-3 should fit. |
17
+ | What `--qd-gain g` does | Multiplies only the student's joint-speed input by g. The safety guard and the logs keep the measured speed. All other settings are the same as `eval`. Default 1 = today's behaviour. |
18
+
19
+ The gripper decision itself does not change: the student must first get low enough. If the gain works, the arm keeps
20
+ moving down to the plate and the student releases as in the sim.
21
+
22
+ ## 2. Rules (must)
23
+
24
+ 1. The user runs all commands. The agent does not run `dry`, `live` or `eval`, and does not open the robot port or
25
+ the cameras.
26
+ 2. Never write motor EEPROM, never recalibrate, never run LeRobot tools (`lerobot-calibrate`, `lerobot-setup-motors`,
27
+ `lerobot-teleoperate` ...) in this test.
28
+ 3. Keep a hand near the arm. Stop keys: space, q, Esc or Ctrl+C. After a stop the arm holds (torque on).
29
+ 4. Stop the test and lower the gain if the arm hits the table, presses the cube into the table, or oscillates.
30
+ 5. Do not change files in `~/so101_hw_robot` (the launcher refuses changed files).
31
+
32
+ ## 3. Before the first episode
33
+
34
+ 1. `cd ~/so101_hw_robot && ./robot_test.sh check` must end with `CHECK OK`. The first line under "bundle files"
35
+ must name git commit `bbcf9f792` or later (the commit that added `--qd-gain`).
36
+ 2. Start from the folded rest pose. In the `q real` line of the run output: the 2nd value (shoulder lift) must be
37
+ between -88 and -100, the 3rd value (elbow) between 80 and 90. Else the run refuses (move the arm by hand with the
38
+ torque off, then start again).
39
+ 3. The wrist camera cable must have slack for a wrist roll of about 76 deg real (HOME turns the wrist; since 10-24 HOME
40
+ has sim roll 0 = 75.8 deg real, before 120.8 deg; the cable pulled out once on 10-22).
41
+ 4. The cameras must stay in their USB ports (external = port 4.1.4, wrist = port 4.1.1). The script uses these paths.
42
+
43
+ ## 4. Test plan
44
+
45
+ Use the layout that worked on 10-22 for most episodes (from behind the robot, looking where the arm points at HOME):
46
+ green cube 16 cm forward of the shoulder axis and 7 cm to the right; red mat 19 cm forward and 7 cm to the left; both
47
+ square to the forward direction. Also use the mirrored layout (cube left, mat right) and 2 other layouts inside
48
+ 15-27 cm from the shoulder axis.
49
+
50
+ | Block | Command | Episodes | Layouts |
51
+ |---|---|---|---|
52
+ | A | `./robot_test.sh eval 4 --qd-gain 2` | 4 | 2 x working layout, 2 x mirrored |
53
+ | B | `./robot_test.sh eval 4 --qd-gain 2.5` | 4 | same 4 layouts |
54
+ | C | `./robot_test.sh eval 4 --qd-gain 3` | 4 | same 4 layouts, only if A and B had no table contact |
55
+ | D (optional) | `./robot_test.sh eval 4` (gain 1, reference) | 4 | same 4 layouts |
56
+
57
+ Episode limit: 40 s (the default of `eval`). A typical successful episode on 10-22 took about 22 s.
58
+
59
+ Each episode:
60
+ 1. At HOME, place the cube and the mat, then type `RUN`.
61
+ 2. Watch the arm. Push space when the cube is on the mat and the arm has moved away, or at a failure.
62
+ 3. Type the result: `g` grasp, `l` lift, `p` placed on the mat, for example `glp`, or `-`. Add a short note after a
63
+ space, for example `glp clean`, `gl hover 2cm`, `gl dropped high`, `g- slipped`, `table contact`.
64
+ 4. Type `r`: the arm goes back to HOME (the gripper opens). Reset the scene.
65
+
66
+ At the end of a block: type `s`, then in the menu `r` (return to the start pose, slow), then `t` with a hand under the
67
+ arm (torque off), or `h` to keep holding.
68
+
69
+ ## 5. What to watch for
70
+
71
+ | Sign | Meaning | Action |
72
+ |---|---|---|
73
+ | The arm goes down onto the mat and opens | The fix works | Continue |
74
+ | Hover 1-5 cm above the mat, no release (as on 10-22) | Gain too low | Next block (higher gain) |
75
+ | The gripper touches the table during the approach or the place | Gain too high | Stop; go back to the lower gain |
76
+ | Fast jerky motion or oscillation | Gain too high | Stop (space); lower the gain |
77
+ | "guard: command floor" or "measured floor" stop | The guard stopped a low command | Note it; if it repeats, lower the gain |
78
+ | Camera error / "frame ... old" stop | Cable or USB problem | Check the wrist cable; `ls /dev/v4l/by-path/` must show 4.1.1 and 4.1.4 |
79
+
80
+ ## 6. What to send back
81
+
82
+ - The session folders: `~/so101_hw_runs/eval_<date>_<time>/` (each has `session.json` with the typed results and
83
+ `ep_NN/episode_live.npz/json`).
84
+ - For each block: the gain, the typed results, and anything unusual.
85
+ - A phone video of 1-2 episodes per block helps.
86
+
87
+ ## 7. Version
88
+
89
+ Bundle built from git commit noted in `~/so101_hw_robot/MANIFEST.txt` (line 1), which must include `--qd-gain`
90
+ (`./robot_test.sh eval 1 --qd-gain 2` prints the line `qdot input gain 2.0` after the joint map lines). Earlier bundles
91
+ reject `--qd-gain` with "unrecognized arguments".
92
+
93
+ ## 8. Known issues from 10-22
94
+
95
+ | Issue | What to do |
96
+ |---|---|
97
+ | `preflight failed: measured q outside the calibrated range` | The rest pose is off. Use the ranges in section 3. |
98
+ | `HOME path refused` | Same. |
99
+ | The program ends and the arm stays stiff (torque on) | Run the program again and use the menu `t`, or: `conda activate lerobot` then `python -c "from lerobot.robots.so_follower import SOFollower, SOFollowerRobotConfig as C; r=SOFollower(C(port='/dev/serial/by-id/usb-1a86_USB_Single_Serial_5B8E115318-if00', id='so101_follower')); r.bus.connect(); r.bus.disconnect(disable_torque=True)"` with a hand under the arm. |
100
+ | `run` typed in lowercase | Refused: type `RUN`. The menu then appears. |
101
+ | Do not push `r` repeatedly after a stop near the table | Each hold lets the arm sag a little. Use `t` with a hand under the arm. |
so101_pick_place/code/scripts/so101_policy/real2sim/hw/README.md ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SO101 camera student on the real robot
2
+
3
+ > Study notes of 2026-10-22 to 10-24 (older students, the study's paths and tests that are not in this release),
4
+ > kept because the robot bundle carries this file. The current guide is "Deploy on the robot" in
5
+ > `so101_pick_place/README.md`.
6
+
7
+ Status 2026-10-24: eval sessions on the robot on 2026-10-22 / 23 (logs `~/so101_r2s_claude/robot_logs`); the
8
+ changes of 2026-10-24 (next section) ran only on the fake robot and in replay. First status (2026-10-22, before the
9
+ robot): student for the robot: `robot_v2_s28_it03000.pt` (AMD `runs/v2_online2_s28/ckpt/it_03000.pt`; cameras
10
+ `external` + `wrist`, 224 px, crops pinned in the checkpoint: external [52, 103, 288, 288], wrist [0, 0, 640, 480]).
11
+ It was chosen for the robot because it keeps 89-91 % success in CPU MuJoCo on the measured (lower, tilted) real table,
12
+ held-out tasks; the sim-best student (`final_v2_s26_it03000.pt`)
13
+ falls to 36-48 % there (`~/so101_r2s_claude/eval/SELECTION_RULE.md`). Checks done on luffy only (logs in
14
+ `~/so101_r2s_claude/hw_final/`, made with the sim-best student; the code path is the same): replay of 3 recordings
15
+ from the extracted bundle equals the worktree run exactly; dry and live loops on the fake robot; the HOME check from
16
+ the 15 recorded rest poses.
17
+
18
+ | File | What |
19
+ |---|---|
20
+ | `run_student_real.py` | modes `replay` (recording, no robot), `dry` (robot read only), `live` (moves the robot) |
21
+ | `hw_lib.py` | joint map, limits, image crop, action layer, hardware guard, joint paths, student wrapper, fake robot |
22
+ | `make_orin_bundle.sh` | builds the folder + `.tar.gz` for the Orin (sources, collision points, student, calib_v1.json, `assets/deploy.json`) |
23
+ | `robot_test.sh` | one command for each test on the Orin: check / replay / dry / live / live-tilt / eval (bundle root) |
24
+ | `tests/so101_policy/test_real2sim_hw.py` | 32 unit tests (CPU, about 15 s) |
25
+ | `tests/so101_policy/test_real2sim_hw_deploy.py` | 15 unit tests: anti-windup (both signs at the range end), floor mode (custom plane, no --q-offset-deg in plane mode), deploy.json, bundle (live-tilt refused in a plane bundle), HOME, no two-student mode |
26
+
27
+ ## Changes 2026-10-24 (read before the next robot day)
28
+
29
+ | Item | Before | Now |
30
+ |---|---|---|
31
+ | HOME (all bundles) | sim (0, -5, -15, 92, **45**, 30) deg | sim (0, -5, -15, 92, **0**, 30) deg = LeRobot (0.0, -3.2, -6.5, 93.1, 75.8, gripper 31.1). Sim tests with the real roll stop: robot-feasible success C1 59-66 % -> 87-88 %, s28 60-68 % -> 95 %. |
32
+ | Floor | one flat floor for every student | floor mode from the student checkpoint (section "Floor modes"): `flat` (C1, s28, roll-cap students: as before), `plane` (v8 table-trained students: floor above the calibrated mat) |
33
+ | Servo-error integral | wound up at a joint's range end (2 stalls "wrist_roll blocked" on 10-23) | anti-windup at the LeRobot-unit range (`GuardConfig.i_antiwindup`, on) |
34
+ | Two students in one episode (commit 39d2e5b72) | a second-student flag and bundle asset | removed (no policy stitching) |
35
+ | Bundle | student + calib | + `assets/deploy.json` (floor mode, table plane source, HOME, eval guard; `robot_test.sh` reads it) |
36
+
37
+ ## Floor modes (the table floor; `run_student_real.py --floor-mode`, `assets/deploy.json`)
38
+
39
+ The action-layer floor must have the clearance above the real mat that the student was trained with (sysid
40
+ `~/so101_r2s_claude/v8/sysid/sysid_v8.json`, coupling rule). The real mat is 8.3-17.5 mm below the sim table at the
41
+ observed cube and plate positions (calibrated plane z = -4.7 mm - 36.4 x + 18.4 y, mm per m; +-3 mm). The bundle
42
+ script reads the mode from the checkpoint (`v8_online.table_bias` present with p > 0 = plane, unless
43
+ `v8_online.student_floor` is `observed` = flat); live mode refuses another mode (`--allow-floor-mismatch` overrides).
44
+ The banner of every run prints the mode and these numbers.
45
+
46
+ | Student type | Floor mode | Eval settings (`robot_test.sh eval`) | Relative to the real mat at the observed positions | ... over the task area (r 0.15-0.27 m, +-75 deg) |
47
+ |---|---|---|---|---|
48
+ | Trained on the sim table: C1, s28, roll-cap students | `flat` | `--floor-mode flat --table-z 0 --home 0,-5,-15,92,0,30 --amp 0 --guard '{"cmd_floor_m":-0.015,"hard_floor_m":-0.02,"i_time_s":0.2,"i_max_deg":3.0,"i_antiwindup":true}'` (floors as on 10-22 / 23) | floor +9.8 .. +19.0 mm; command stop -6.7 .. +2.5 mm; measured stop -11.7 .. -2.5 mm | floor +5.3 .. +18.6 mm; command stop -11.2 .. +2.1 mm; measured stop -16.2 .. -2.9 mm (the mat is highest at the far +y edge: 3.85 mm below the sim table) |
49
+ | Round v12: trained in the table frame of a fixed plane with the flat floor (checkpoint `v8_online.student_floor` `observed`) | `flat` | as the sim-table students (`deploy.json` `table_frame` true: no `live-tilt` / `--q-offset-deg`; `--table-z` must stay 0, live refuses another value with no override) | as the sim-table students (in training the floor was 1.5 mm above z 0 of the arm frame, as here) | as the sim-table students |
50
+ | Trained with the v8 table randomisation (checkpoint `v8_online.table_bias`, p > 0) | `plane` | `--floor-mode plane --table-plane calib --home 0,-5,-15,92,0,30 --amp 0 --guard '{"cmd_floor_m":-0.002,"hard_floor_m":-0.005,"i_time_s":0.2,"i_max_deg":3.0,"i_antiwindup":true}'` | floor +1.5 mm (as in training: 1.5 mm above the true table); command stop -2.0 mm; measured stop -5.0 mm | the same (everywhere on the plane, +-3 mm calibration) |
51
+
52
+ Plane mode measures the floor stops above the plane, so the flat eval stops (-15 / -20 mm) on top of the plane would
53
+ put them 15-20 mm into the mat (double lowering): live refuses plane-mode stops deeper than 5 mm (command) / 8 mm
54
+ (measured). Live also refuses, in plane mode: a `--table-plane c0,c1,c2` that is more than 1 mm below the calibrated
55
+ plane anywhere on r 0.15-0.27 m, +-90 deg (`--allow-floor-mismatch` overrides; write a negative c0 with the = form,
56
+ `--table-plane=-0.0047,-0.0364,0.0184`), and any `--q-offset-deg` (no override). The mat plane is measured in the plain calib_v1 joint frame; the table-tilt correction `live-tilt` /
57
+ `--q-offset-deg 0,-2.086,0,0,0` turns the arm frame against it, so the floor and the floor checks see the gripper
58
+ 3.7-10 mm too high and the floor goes 2-8.5 mm into the mat. **live-tilt and `--q-offset-deg` are for flat students
59
+ only**; `robot_test.sh live-tilt` refuses a plane bundle. The plane floor is not used for the flat students: they were trained with the floor at sim z 0, and
60
+ the plane would let them press 8-18 mm lower than in training. With the plane floor and the servo-error integral, a
61
+ student that pushes down on the plate or the mat can reach the command stop (2 mm below the mat); that ends the
62
+ episode ("command floor") and is the intended protection.
63
+
64
+ ## Servo-error integral: anti-windup (2026-10-24)
65
+
66
+ On 10-23 two eval episodes ended with "stall: wrist_roll blocked" (eval_20261023_141614 ep 6, eval_20261023_144431
67
+ ep 1): the measured roll stayed at 100.69 sim deg (the real stop), the target 100.9-101.1 deg, the command clipped at
68
+ 101.21 deg (LeRobot range end), and the integral correction grew to +3 deg; the stall check compares the measured q
69
+ with the command without the correction (101.21 - 3 = 98.2 deg): 2.5 deg >= 0.9 x lead band for 25 steps. Now
70
+ (`GuardConfig.i_antiwindup`, default on): on a joint whose target is at / beyond its LeRobot-unit range, or whose
71
+ corrected command would be clipped there, the error is not integrated; the correction is 0 while the target is at /
72
+ beyond the range (either sign: the command is then the range end, as without the integral) and never pushes the
73
+ command past the range otherwise. Offline replay of the Guard on the two logged episodes (`~/so101_r2s_claude/v8/deploy/stall_replay.json`):
74
+ the old rule reproduces the logged commands exactly and stalls at the logged step; the new rule has no stall, the same
75
+ commands on the other 5 joints at every step, and the roll differs only after the first step at the range end (by up
76
+ to 0.65 / 0.37 deg, the removed wind-up; the integral stays <= 0.67 / 0.52 deg instead of 3.0). All 102 logged
77
+ robot episodes with the integral on (144,785 steps, `~/so101_r2s_claude/v8/deploy/stall_replay_all.json`): the old
78
+ rule reproduces 100 logs exactly (2 early live runs of 10-22 ran older guard code) and all 9 logged stalls (8 wrist
79
+ roll, 1 shoulder pan, every one a wind-up at the range end); the new rule: 0 stalls, commands changed only on the
80
+ pan (417 steps) and the roll (13,355 steps), always after the first step at the range end. The replay is open loop
81
+ (the logged q), so the later steps of a changed episode are not what the robot would have done. `{"i_antiwindup":
82
+ false}` in `--guard` gives the old rule. Training has the same rule as an option, off by default
83
+ (`joint_env.RobotDynConfig.i_antiwindup`).
84
+
85
+ ## Closed gripper at the start (fixed 2026-10-22)
86
+
87
+ A closed real gripper (LeRobot < 3) is below the sim jaw limit; 9 of the 15 recordings start like that. The HOME and
88
+ return path checks now accept a measured end pose outside the sim range (the path stays between its ends). The
89
+ calibrated LeRobot range is still checked.
90
+
91
+ ## 1. Build (luffy) and copy (you)
92
+
93
+ ```bash
94
+ cd /home/harry/.t3/worktrees/NeDM-push-ppo/r2s-v8 # branch claude/r2s-v8
95
+ scripts/so101_policy/real2sim/hw/make_orin_bundle.sh ~/so101_r2s_claude/ckpt/c1_relabel_s63_it02000.pt \
96
+ ~/so101_r2s_claude/v8/deploy/bundles/so101_hw_c1 # prints "floor mode flat"
97
+ scripts/so101_policy/real2sim/hw/make_orin_bundle.sh <v8 student .pt> \
98
+ ~/so101_r2s_claude/v8/deploy/bundles/so101_hw_v8 # prints "floor mode plane"
99
+ scp ~/so101_r2s_claude/v8/deploy/bundles/so101_hw_c1.tar.gz sbel@proxy:~/ # you do this
100
+ ```
101
+
102
+ The script reads the checkpoint (Python with torch: `$PYTHON`, default the so101_vision env) and writes
103
+ `assets/deploy.json` (floor mode, table plane source, HOME, eval guard; `HOME_SIM_DEG=a,b,c,d,e,f` sets another
104
+ HOME). MANIFEST.txt: 3 header lines (built, student + floor mode, calib), then the sha256 of every file.
105
+
106
+ On the Orin: `cd ~ && tar xzf so101_hw_c1.tar.gz && cd so101_hw_c1 && sed -n '4,$p' MANIFEST.txt | sha256sum -c --quiet`
107
+ (no output = all files intact). Needs only the `lerobot` conda env (torch, numpy, cv2, pyarrow, LeRobot 0.6.2); no
108
+ mujoco. Run every command below from the bundle folder (e.g. `~/so101_hw_c1`), in an interactive terminal (desktop or `ssh -t`): the stop
109
+ keys q / space / Esc need a TTY, else only Ctrl+C stops. Do not pipe into `tee` (Ctrl+C also stops `tee`); the
110
+ `--out` folder keeps the log.
111
+
112
+ ## 2. Commands on the Orin
113
+
114
+ Short form (`robot_test.sh`, in the bundle root; it activates `lerobot`, writes to `~/so101_hw_runs/<mode>_<time>`,
115
+ refuses dry / live without a TTY or with changed bundle files; `[s]` = the time limit; it refuses `--time-limit`,
116
+ `--q-offset-deg`, `--out` in the extra arguments, and `--floor-mode`, `--table-z`, `--table-plane`, `--home`: every
117
+ mode takes the floor mode, the table plane source and HOME from `assets/deploy.json`; the banner prints them). `run_student_real.py` dry / live refuses, just before it opens the
118
+ port and the cameras, while one of your processes has one of them open, or while a LeRobot robot tool
119
+ (`lerobot-teleoperate`, `-record`, `-calibrate`, ...) or another dry / live run of any user runs. The open files of
120
+ other users' processes (root, docker) are not visible: stop those yourself.
121
+
122
+ ```bash
123
+ cd ~/so101_hw_c1
124
+ ./robot_test.sh check # files, deploy settings, env, port, cameras, calibration (opens no device)
125
+ ./robot_test.sh replay # a) below
126
+ ./robot_test.sh dry # b) below, 30 s
127
+ ./robot_test.sh live # c) below, 15 s (live-tilt = c) + --q-offset-deg 0,-2.086,0,0,0; flat bundles only)
128
+ ./robot_test.sh eval [n] [s] # d) below: n episodes in a row (default 10 x 40 s)
129
+ ```
130
+
131
+ d) Eval session (first robot day, 2026-10-22: grasp, lift and carry worked with these settings). `eval` = live with
132
+ the floor mode and HOME of `assets/deploy.json`, `--amp 0`, `--guard <eval_guard of deploy.json>` and
133
+ `--episodes-n n` (the table in "Floor modes": flat students `{"cmd_floor_m":-0.015,"hard_floor_m":-0.02,
134
+ "i_time_s":0.2,"i_max_deg":3.0,"i_antiwindup":true}`, plane students `{"cmd_floor_m":-0.002,"hard_floor_m":-0.005,
135
+ "i_time_s":0.2,"i_max_deg":3.0,"i_antiwindup":true}`). Why: for the flat students the real table is 8-18 mm below the
136
+ sim table (the default floor stops at -2 / -5 mm ended good grasps); without the integral correction the real servos
137
+ (P 16, gearbox friction) did not follow the student's 0.45 deg lift steps after the grasp and the arm stayed on the
138
+ table. Flow: MOVE (HOME) -> each episode: reset the scene, RUN,
139
+ the student (space ends the episode), type the result (g grasp, l lift, p placed, for example `glp`; a note after a
140
+ space), `r` = back to HOME for the next episode (the gripper opens), `s` = end -> menu (r return to the start pose,
141
+ t torque off). Logs: `<out>/ep_NN/episode_live.{npz,json}` (outcome in the json), `<out>/session.json`.
142
+
143
+ e) Joint-speed input gain (`--qd-gain g`, default 1 = off; 2026-10-22 evening). The student's step size follows the
144
+ measured joint speed; the real arm is about 5 x slower than the sim arm, so near the plate the steps shrink until the
145
+ arm holds still and never releases (10 of 12 eval episodes). `--qd-gain` multiplies only the student's qdot input (the
146
+ guard and the log keep the measured qdot). CPU MuJoCo, today's student, 12 real layouts x 4: robot-like dynamics
147
+ 50 / 88 / 94 / 83 / 48 % at gain 1 / 2 / 3 / 4 / 5; nominal sim 98 / 90 / 75 % at 1 / 2 / 3 (more arm-table contacts).
148
+ Test plan: QDGAIN_TEST.md. Example: `./robot_test.sh eval 5 --qd-gain 2`.
149
+
150
+ Long form:
151
+
152
+ ```bash
153
+ conda activate lerobot
154
+ cd ~/so101_hw_robot
155
+ S="--student assets/student.pt --calib assets/calib_v1.json"
156
+ F="--floor-mode flat --table-z 0 --home 0,-5,-15,92,0,30" # plane students: --floor-mode plane --table-plane calib ...
157
+ # a) replay (no robot; Orin inference time; compare with luffy)
158
+ python scripts/so101_policy/real2sim/hw/run_student_real.py replay $S $F --data-root /home/sbel/lerobot/data \
159
+ --episodes green_cube_red_plate:0,green_cube_red_plate:2,green_cube_red_plate_1:5 --out ~/so101_hw_runs/replay_orin
160
+ # b) dry (robot and cameras connected, NO motor writes, torque untouched; stop other LeRobot processes first)
161
+ python scripts/so101_policy/real2sim/hw/run_student_real.py dry $S $F --out ~/so101_hw_runs/dry_1 --time-limit 30
162
+ # c) live (moves the robot)
163
+ python scripts/so101_policy/real2sim/hw/run_student_real.py live --i-am-supervising $S $F \
164
+ --out ~/so101_hw_runs/live_1 --time-limit 15
165
+ ```
166
+
167
+ Defaults used by these commands: HOME = sim (0, -5, -15, 92, 0, 30) deg = LeRobot (0.0, -3.2, -6.5, 93.1, 75.8,
168
+ gripper 31.1) (`hw_lib.ROBOT_HOME_SIM_DEG`; before 2026-10-24 the wrist roll was 45 sim = 120.8 real deg); HOME speed
169
+ 15 deg/s peak; `--floor-mode auto` (the student's: flat `--table-z 0` or plane `--table-plane calib`); `--configure
170
+ auto`; guard = `GuardConfig` defaults (table below). The run checks that `--calib` is the calibration the student was trained with (live refuses a mismatch).
171
+ Luffy replay of a) with the robot student: cube error before the grasp 25.3 / 21.1 / 28.9 mm, plate 15.2 / 12.8 /
172
+ 12.1 mm (bf16 on another GPU: small differences are normal). About 16 mm of the cube error is height (next section).
173
+
174
+ ## 3. Pre-run checklist (live)
175
+
176
+ 1. Dry run first. Check: the printed q matches the arm; `first_frames.npz` / the logged thumbnails show the fixed
177
+ camera as `external` and the gripper camera as `wrist` (a swap is not detected); the end of the run prints the
178
+ model and step time (p50 / p95). Gripper >= 5 (above).
179
+ 2. Arm in the folded rest pose. The HOME move takes about 10 s at <= 15 deg/s; the wrist roll turns to 75.8 deg real
180
+ (sim 0; before 2026-10-24: 120.8 deg real).
181
+ 3. Cube and plate: both 0.15-0.27 m from the shoulder pan axis (3.9 cm in front of the base origin), within +-75 deg
182
+ of straight ahead, 6-30 cm apart, plate yaw within 30 deg of the cube yaw (mod 90). Place them after HOME, before
183
+ you type `RUN`. (8 of the 15 recorded cubes were 0.28-0.34 m out: outside the training region.)
184
+ 4. Table height: the real table is 4-17 mm below the sim table over that region (tilted about 2 deg; 10-18 mm at the
185
+ 15 recorded cubes). Keep `--table-z 0`: the gripper floor then stays 5 mm or more above the real table.
186
+ CPU MuJoCo with this table (held-out tasks, 100 each): the robot student 89 % (normal starts) / 91 % (HOME).
187
+ Optional correction `--q-offset-deg 0,-2.086,0,0,0` (shoulder_lift joint-map offset = the x tilt of the fitted
188
+ table plane; correct only if the arm base is really tilted, not for a shoulder_lift calibration error): 90 / 94 %.
189
+ Flat students only (`live-tilt`); never with a plane bundle (the floor would go 2-8.5 mm into the mat; refused).
190
+ A flat table 10 mm lower: 96 / 98 %. Level table: 98 / 98 %. If you can, make the table level with the arm base.
191
+ `--table-z` is one flat height: a value below -0.005 lets the gripper reach the table at the high side.
192
+ Students trained with the v8 table randomisation (checkpoint `v8_online.table_bias`; configs
193
+ `configs/so101_policy/vision/viral_r2s_online_v8_*`) learned to go down to the real table: they run in floor mode
194
+ plane (section "Floor modes"; the bundle and `--floor-mode auto` choose it): the floor and the guard's floor
195
+ checks 1.5 mm / -5 mm / -2 mm above the calibrated table plane, never `--table-z 0` (that floor is ~13 mm above the
196
+ real table at the cubes and holds the descent up), never the flat eval stops on top of the plane and never
197
+ `live-tilt` / `--q-offset-deg`.
198
+ 5. Workspace clear, you at the robot, one hand near the arm, the other on the keyboard (q / space / Esc / Ctrl+C).
199
+ The student may command up to 0.06 rad per 20 ms step (3 rad/s); the sim teacher's per-step change p99 is
200
+ 0.03-0.04 rad.
201
+ 6. At the end the torque stays ON (holding). Menu: `r` slow return to the start pose, then `t` + `TORQUE OFF`
202
+ with a hand under the arm. `h` (or Enter) exits holding.
203
+
204
+ ## 4. What the live run does
205
+
206
+ 1. Before any write: LeRobot calibration file present and equal to the motors' registers; 3 joint reads finite and
207
+ inside the calibrated range; both cameras 640 x 480, frames younger than 200 ms.
208
+ 2. `--configure auto`: only if a register differs from LeRobot's `configure` values, it asks for `CONFIGURE` (torque
209
+ off for a moment; the arm must rest on its stops).
210
+ 3. HOME: the joint path is checked (sim joint range, calibrated range, lowest gripper point, grasp-point box); you
211
+ type `MOVE`; goal = present position, torque on, cosine move; the path waits while the arm lags > 0.25 rad and
212
+ stops after 2 s of lag.
213
+ 4. You place the cube and the plate and type `RUN`: the student loop, up to `--time-limit` s (sim episodes are 8 s).
214
+ 5. End (time, key, guard): HOLD (arm goal = measured q, gripper = its last command), then the menu.
215
+
216
+ | Per control step (20 ms; a student query every 5 steps) | Value |
217
+ |---|---|
218
+ | Images | newest frame of each camera, crop of the checkpoint (`cfg.crops`), resize to 224 (INTER_AREA), RGB |
219
+ | Joints | LeRobot units <-> sim rad by `calib_v1.json` `joint_map`; qdot from the last 3 reads |
220
+ | Executed target | 1 of the 5 first chunk targets: change vs the previous command <= 0.06 rad (roll 0.08, jaw 0.5); action layer (lead band to the measured q, sim joint range, floor: lowest gripper point >= 1.5 mm + `--table-z`, or 1.5 mm above the mat plane in floor mode plane); eval: + the servo-error integral (<= 3 deg, anti-windup at the range); calibrated range - 3 deg; <= 10 deg (gripper 60) from the measured q |
221
+ | Stops (live) | command not finite, below the floor (-2 mm + table_z or the plane, and below the measured pose; eval: the deploy.json value) or outside the box; measured q > 5 deg outside the allowed range (calibrated - 3 deg); measured lowest gripper point < -5 mm + table_z or the plane (eval: deploy.json); grasp point outside x -0.10..0.45, y +-0.42, z -0.01..0.40 m or > 0.45 m from the pan axis; camera frame > 150 ms old (camera loss); an arm joint >= 90 % of its lead band for 0.5 s (blocked); read / write error; time limit; q / space / Esc / Ctrl+C |
222
+
223
+ ## 5. What to record
224
+
225
+ - The `--out` folders (dry, live, replay): `episode_*.npz` / `.json`, `first_frames.npz`, `replay_*`.
226
+ - A phone video from the side, started before `RUN`.
227
+ - A photo of the scene and the cube / plate positions (x, y from the base, yaw) before `RUN`.
228
+ - Per run: end reason, reached the cube (yes / no), grasp height vs the cube, lift, place, manual stops.
229
+ - The timing lines at the end of the dry run (`latency ms_model`, `ms_step`, overruns).
230
+
231
+ ## Not tested / open
232
+
233
+ - Nothing ran against the real bus or cameras (`LeRobotIO` was checked only against LeRobot's source).
234
+ - Timing: on luffy's busy shared GPU the model took 25 ms p50 / 43 ms p95, so every query step overran its 20 ms slot
235
+ (46.7 Hz instead of 50). The Orin's time is unknown (dry run / replay a).
236
+ - Blank or wrong camera images are not detected (only the frame age). On the fake robot (constant grey images) the
237
+ student moved the arm 87 deg (shoulder lift) and 127 deg (wrist roll) in 15 s with no stop.
238
+ - The jaw may open at the measured arm pose even if the moving jaw then goes lower; the command-floor stop (-2 mm)
239
+ can end a good release. If so: `--guard '{"cmd_floor_m": -0.005}'`.
240
+ - Servo dynamics (STS3215, LeRobot P 16 / D 32) were not compared with the sim actuators. Replay images are H.264
241
+ re-encodes, live images MJPG decodes. No undistortion (the student was trained on renders with the calibrated fisheye models).
so101_pick_place/code/scripts/so101_policy/real2sim/hw/hw_lib.py ADDED
@@ -0,0 +1,1140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Real-robot side of the SO101 camera student (real2sim study): the pieces that the replay, dry and live modes of
2
+ ``run_student_real.py`` share, and that ``tests/so101_policy/test_real2sim_hw.py`` tests.
3
+
4
+ Pure numpy / torch (+ cv2 for images). No mujoco, no newton / warp, no LeRobot import in this file: it must run on
5
+ the Jetson AGX Orin of the real robot (aarch64, torch 2.11, LeRobot 0.6.2, no mujoco).
6
+
7
+ Units and frames
8
+ - Real joints = LeRobot 0.6.2 ``so101_follower`` units (``use_degrees=True``): 5 arm joints in degrees
9
+ (0 = middle of the calibrated range: deg = (raw - (range_min + range_max) / 2) * 360 / 4095), gripper 0-100
10
+ (0 = range_min). Order ``JOINTS``.
11
+ - Sim joints = the pinned MuJoCo Menagerie so101 joint angles (rad), same order, gripper = the moving jaw angle.
12
+ - Joint map (``calib_v1.json`` "joint_map"): sim_rad[i] = sign[i] * radians(real_deg[i]) + offset_rad[i] for the 5 arm
13
+ joints, sim jaw rad = a * real_gripper + b. ``JointMap.placeholder_identity`` (sign +1, offset 0, a = pi / 180,
14
+ b = 0) is a placeholder only (signs and offsets NOT verified); live mode refuses it.
15
+ - World = arm base frame, z up, sim table top z = 0 (``table_z`` shifts the floor if the real table is elsewhere; the
16
+ floor mode "plane" puts it above the calibrated real mat plane instead, ``student_floor_mode``).
17
+
18
+ Control timing (as in the sim: ``joint_env``): one 20 ms step per target; a student query every ``n_exec`` (5) steps
19
+ = 0.1 s; the query sees the measured q, a qdot estimate and the newest camera frames; it returns a chunk of 10 absolute
20
+ targets, the first 5 are executed, each through the stateless action layer (``ActionLayer`` = ``joint_env.safety``:
21
+ lead band around the measured q of THAT step, the collector's joint range, the table floor from the kinematics).
22
+ The hardware guard (``Guard``) adds limits that the sim does not have (command change per step, LeRobot-unit range
23
+ and max relative target, workspace box, hard floor, tracking error); it never loosens the action layer.
24
+ """
25
+ from __future__ import annotations
26
+
27
+ import json
28
+ import math
29
+ import time
30
+ from dataclasses import dataclass, field
31
+ from pathlib import Path
32
+
33
+ import numpy as np
34
+
35
+ JOINTS = ("shoulder_pan", "shoulder_lift", "elbow_flex", "wrist_flex", "wrist_roll", "gripper")
36
+ ARM = 5
37
+ DT = 0.02 # s, one control step (world.CONTROL_DT)
38
+ FPS_REC = 30 # LeRobot recordings
39
+ STS_RES = 4096 # STS3215 ticks per turn (LeRobot: max_res = resolution - 1 = 4095)
40
+ REAL_CAMERAS = ("external", "wrist")
41
+ DEFAULT_CAM_MAP = {"top": "external", "external": "external", "wrist": "wrist"}
42
+ # HOME45 pose in SIM degrees (the sim teacher check and its task sets, ``teacher_home_check.py``; the robot's HOME until
43
+ # 2026-10-23): the median start of the build9 development tasks (dev100.npz: 1.0, -5.2, -14.8, 92.1, 11.0, 36.3)
44
+ # rounded, pan set to 0, wrist roll 45 (teacher jt_h110 in CPU MuJoCo, 1,500 paired tasks: roll 45 98.1 % vs roll 0
45
+ # 95.1 %, McNemar p 0.002 on the 500 tasks not used to choose it; roll 30-60 all >= 97 %, roll -45 91 %;
46
+ # ~/so101_r2s_claude/teacher_check). Real LeRobot degrees with calib_v1: (0.0, -3.2, -6.5, 93.1, 120.8), gripper 31.2.
47
+ HOME_SIM_DEG = (0.0, -5.0, -15.0, 92.0, 45.0, 30.0)
48
+ # The robot's default HOME (run_student_real.py --home, the bundles' assets/deploy.json; 2026-10-24): HOME45 with wrist
49
+ # roll 0. The real wrist roll stops at +101.2 sim deg (RealLimits: calibrated range end - 3 deg); from roll 45 many
50
+ # episodes turn the roll into that stop (115 robot episodes: 26 reached it, 9 stalls; sysid_v8.json "roll"). Sim
51
+ # tests with the real roll stop (2026-10-24): robot-feasible success C1 59-66 % -> 87-88 %, s28 60-68 % -> 95 % with
52
+ # roll 0. Real LeRobot degrees with calib_v1: (0.0, -3.2, -6.5, 93.1, 75.8), gripper 31.2. Grasp point (0.27, 0.0,
53
+ # 0.14) m, lowest gripper point 121 mm.
54
+ ROBOT_HOME_SIM_DEG = (0.0, -5.0, -15.0, 92.0, 0.0, 30.0)
55
+
56
+
57
+ # ---- calibration file ---------------------------------------------------------------------------------------------
58
+ def parse_table_plane(spec, calib=None):
59
+ """``run_student_real.py --table-plane``: "" (off -> None), "calib" (calib_v1 scene.table_plane coef, the measured
60
+ real table) or "c0,c1,c2" (m, z = c0 + c1 x + c2 y) -> (c0, c1, c2) or None."""
61
+ spec = (spec or "").strip()
62
+ if not spec:
63
+ return None
64
+ if spec == "calib":
65
+ try:
66
+ c = (calib or {})["scene"]["table_plane"]["coef"]
67
+ except (KeyError, TypeError):
68
+ raise ValueError("--table-plane calib: the calibration has no scene.table_plane.coef") from None
69
+ else:
70
+ c = [float(v) for v in spec.split(",")]
71
+ c = tuple(float(v) for v in c)
72
+ if len(c) != 3 or not all(math.isfinite(v) for v in c):
73
+ raise ValueError(f"--table-plane {spec!r}: 'calib' or c0,c1,c2 (m)")
74
+ return c
75
+
76
+
77
+ # ---- floor mode (run_student_real.py --floor-mode; README "Floor") --------------------------------------------------
78
+ # The action-layer floor must have the clearance above the real mat that the student was trained with
79
+ # (~/so101_r2s_claude/v8/sysid/sysid_v8.json table_dz_range_m.coupling_rule):
80
+ # - "flat": students trained on the sim table only (C1, s28, the roll-cap students): floor FLOOR (1.5 mm) above sim
81
+ # z = table_z (0), as in their training; the guard's floor stops are relative to the same z.
82
+ # - "plane": students trained with the v8 table randomisation (checkpoint ``v8_online.table_bias``): in training the
83
+ # floor stays FLOOR above the TRUE table, i.e. above the table plane in the student's (= the real robot's) joint
84
+ # frame; on the robot: FLOOR above the calibrated mat plane (calib_v1 scene.table_plane), and the guard's floor
85
+ # stops relative to that plane too. Today's flat eval stops (-15 / -20 mm, set because the real mat is 8-18 mm
86
+ # below the sim table) must NOT be used on top of the plane (double lowering: stops 15-20 mm into the real mat).
87
+ # - round v12 (2026-10-26): students trained with a FIXED table plane and the flat observed-frame floor (checkpoint
88
+ # ``v8_online.student_floor`` "observed", ``viral.OnlineConfig.student_floor``): in training the floor is flat 1.5
89
+ # mm above z = 0 of the student's (= the robot's) joint frame, i.e. raised by the drop in the true frame -> "flat"
90
+ # (as C1 / D), never the plane floor. Such a student already corrects for the real table: no --q-offset-deg
91
+ # (live-tilt) on top (``floor_frame_problems`` table_frame).
92
+ FLOOR_MODES = ("flat", "plane")
93
+ STUDENT_FLOORS = ("true", "observed") # v8_online.student_floor (absent = "true", the v8 coupling rule)
94
+ # The guard's floor stops of the eval session (robot_test.sh eval, via the bundle's assets/deploy.json) per mode, m:
95
+ # flat = the eval values of 2026-10-22 .. 23 (relative to sim z = table_z 0; unchanged); plane = the GuardConfig
96
+ # defaults, relative to the calibrated mat plane.
97
+ EVAL_FLOOR_GUARD = {"flat": {"cmd_floor_m": -0.015, "hard_floor_m": -0.020},
98
+ "plane": {"cmd_floor_m": -0.002, "hard_floor_m": -0.005}}
99
+ # ... with the servo-error integral correction (both modes; anti-windup at the real joint range, GuardConfig)
100
+ EVAL_I_GUARD = {"i_time_s": 0.2, "i_max_deg": 3.0, "i_antiwindup": True}
101
+ # Plane mode: floor stops deeper than this below the mat plane are refused in live mode (double lowering; m)
102
+ PLANE_STOP_MIN_M = {"cmd_floor_m": -0.005, "hard_floor_m": -0.008}
103
+ # The calibrated mat plane at the 184 observed cube and plate positions of the robot logs, mm relative to sim z = 0
104
+ # (sysid_v8.json table.json "plane at cubes + plates" min / max): for the banner's flat-mode clearances
105
+ OBSERVED_MAT_MM = (-17.47, -8.31)
106
+ # ... and over the whole task area of the README checklist (cube and plate r 0.15-0.27 m about the pan axis, +-75 deg;
107
+ # sysid_v8.json table_dz_range_m.deployment.plane_on_task_annulus_mm): the mat is highest at the far +y edge
108
+ TASK_R_M, TASK_DEG = (0.15, 0.27), 75.0
109
+ TASK_MAT_MM = (-17.1036, -3.8492)
110
+ PAN_AXIS_X = 0.0388 # m, the vertical pan axis in the world (kin.PAN_AXIS_XY)
111
+ # A --table-plane c0,c1,c2 other than "calib": live refuses it if it is more than this below the calibrated mat plane
112
+ # anywhere on r TASK_R_M, +-PLANE_CHECK_DEG (the floor would be in the mat; m)
113
+ PLANE_CHECK_DEG, PLANE_LOW_TOL_M = 90.0, 0.001
114
+
115
+
116
+ def eval_guard(mode):
117
+ """The eval session's guard overrides (``GuardConfig`` dict) of floor mode ``mode``."""
118
+ if mode not in FLOOR_MODES:
119
+ raise ValueError(f"floor mode {mode!r}: one of {FLOOR_MODES}")
120
+ return {**EVAL_FLOOR_GUARD[mode], **EVAL_I_GUARD}
121
+
122
+
123
+ def student_floor_mode(meta):
124
+ """Checkpoint keys of a student (``StudentPolicy.meta``: everything but the weights) -> (floor mode, why): "plane"
125
+ if it was trained with the v8 table randomisation (``v8_online.table_bias`` on, ``table_bias.is_on``, with a
126
+ probability ``p`` > 0 of a lower / tilted table) under the v8 floor rule (``v8_online.student_floor`` absent or
127
+ "true"); "flat" for the round v12 students (``student_floor`` "observed": the flat arm-frame floor in training)
128
+ and for students trained on the sim table. An unknown ``student_floor`` raises ValueError (no guess)."""
129
+ from nedm.so101_policy import table_bias as TBI
130
+ v8 = dict((meta or {}).get("v8_online") or {})
131
+ tb = dict(v8.get("table_bias") or {})
132
+ sf = v8.get("student_floor", "true")
133
+ if sf not in STUDENT_FLOORS:
134
+ raise ValueError(f"checkpoint v8_online.student_floor {sf!r}: one of {STUDENT_FLOORS}")
135
+ p = float(tb.get("p", TBI.TableBiasConfig.p))
136
+ if TBI.is_on(tb) and p > 0.0 and sf == "observed":
137
+ return "flat", ("trained in the table frame of {what} under the flat arm-frame floor (checkpoint "
138
+ "v8_online.student_floor observed, round v12): floor 1.5 mm above z 0 of the arm frame, as "
139
+ "trained").format(what=f"the fixed plane {tb.get('plane')} (c0, c1, c2 m)" if tb.get("plane")
140
+ else f"table planes (p {tb.get('p')}, drop {tb.get('drop_mm')} mm)")
141
+ if TBI.is_on(tb) and p > 0.0:
142
+ return "plane", ("trained with the v8 table randomisation (checkpoint v8_online.table_bias: p {p}, drop {d} mm "
143
+ "at x {x} m, slope x {sx} / y {sy} mm per m)").format(
144
+ p=tb.get("p"), d=tb.get("drop_mm"), x=tb.get("x_ref_m"), sx=tb.get("slope_x"), sy=tb.get("slope_y"))
145
+ if TBI.is_on(tb):
146
+ return "flat", f"trained on the sim table (checkpoint v8_online.table_bias with p {p:g}: never a lower table)"
147
+ return "flat", "trained on the sim table (no v8_online.table_bias in the checkpoint)"
148
+
149
+
150
+ def plane_depth_below(plane, ref, r=TASK_R_M, deg=PLANE_CHECK_DEG):
151
+ """How far (m, >= 0) the plane ``plane`` (c0, c1, c2) lies below ``ref`` at most on r ``r`` about the pan axis,
152
+ angle +-``deg`` (0 = nowhere below)."""
153
+ rr, aa = np.meshgrid(np.linspace(r[0], r[1], 13), np.radians(np.linspace(-deg, deg, 181)))
154
+ x, y = PAN_AXIS_X + rr * np.cos(aa), rr * np.sin(aa)
155
+ d = np.asarray(plane, np.float64) - np.asarray(ref, np.float64)
156
+ return float(max(0.0, -(d[0] + d[1] * x + d[2] * y).min()))
157
+
158
+
159
+ def floor_problems(mode, student_mode, gcfg, plane_spec="calib", plane=None, calib_plane=None):
160
+ """Floor settings that do not fit the student -> list of strings (empty = ok): a floor mode other than the
161
+ student's (``student_floor_mode``), plane-mode floor stops deeper than ``PLANE_STOP_MIN_M`` (double lowering), or a
162
+ plane mode ``plane_spec`` other than "calib" whose ``plane`` lies more than ``PLANE_LOW_TOL_M`` below the
163
+ calibrated mat plane ``calib_plane`` (None: not known, also a problem) on the task area (``plane_depth_below``).
164
+ run_student_real.py: live refuses them (unless --allow-floor-mismatch), dry / replay warn. The joint-map offset
165
+ rule is ``floor_frame_problems`` (no override)."""
166
+ bad = []
167
+ if mode != student_mode:
168
+ bad.append(f"floor mode {mode} but the student needs {student_mode}")
169
+ if mode == "plane":
170
+ for k, lim in PLANE_STOP_MIN_M.items():
171
+ v = float(getattr(gcfg, k))
172
+ if v < lim:
173
+ bad.append(f"guard {k} {v * 1e3:g} mm below the mat plane (plane mode allows down to {lim * 1e3:g} "
174
+ f"mm: deeper stops = double lowering, the gripper may press the table)")
175
+ if plane is not None and (plane_spec or "calib") != "calib":
176
+ if calib_plane is None:
177
+ bad.append(f"--table-plane {plane_spec}: the calibration has no scene.table_plane to check it against")
178
+ else:
179
+ dz = plane_depth_below(plane, calib_plane)
180
+ if dz > PLANE_LOW_TOL_M:
181
+ bad.append(f"--table-plane {plane_spec} is up to {dz * 1e3:.1f} mm below the calibrated mat plane "
182
+ f"(r {TASK_R_M[0]}-{TASK_R_M[1]} m, +-{PLANE_CHECK_DEG:g} deg; allowed "
183
+ f"{PLANE_LOW_TOL_M * 1e3:g} mm): the floor would be in the mat")
184
+ return bad
185
+
186
+
187
+ def student_table_frame(meta) -> bool:
188
+ """True if the student was trained in a table frame (``v8_online.table_bias`` on with p > 0: v8 plane students and
189
+ the round v12 flat-floor table students): it already corrects for the real table."""
190
+ from nedm.so101_policy import table_bias as TBI
191
+ tb = dict(((meta or {}).get("v8_online") or {}).get("table_bias") or {})
192
+ return bool(TBI.is_on(tb) and float(tb.get("p", TBI.TableBiasConfig.p)) > 0.0)
193
+
194
+
195
+ def student_floor_observed(meta) -> bool:
196
+ """True for the round v12 students trained under the flat arm-frame floor (checkpoint ``v8_online.student_floor``
197
+ "observed"): their floor in training was 1.5 mm above z 0 of the arm frame, so the robot's --table-z must stay 0."""
198
+ return ((meta or {}).get("v8_online") or {}).get("student_floor", "true") == "observed"
199
+
200
+
201
+ def floor_frame_problems(mode, q_offset_deg=None, table_frame=False, observed=False, table_z=0.0):
202
+ """Plane mode with an extra joint-map offset (run_student_real.py --q-offset-deg, e.g. live-tilt's table-tilt
203
+ correction 0,-2.086,0,0,0) -> list of strings (empty = ok). The calibrated mat plane is measured in the plain
204
+ calib_v1 joint frame; an offset turns the arm frame against it, and the floor and the floor checks then see the
205
+ gripper at a wrong height above the mat (live-tilt: 3.7-10 mm too high at r 0.15-0.27 m, i.e. the floor 2-8.5 mm
206
+ in the mat). The tilt correction is for flat students only (the plane floor already follows the real table).
207
+ ``table_frame`` (``student_table_frame``: also the round v12 flat-floor table students): any offset is refused as
208
+ well (the student corrects for the real table itself). ``observed`` (``student_floor_observed``: the round v12
209
+ students trained under the flat floor 1.5 mm above z 0 of the arm frame) with a ``table_z`` (--table-z) other than
210
+ 0: the floor would move by table_z from the floor the student was trained with (e.g. -0.0126 = 12.6 mm lower),
211
+ refused as well. run_student_real.py: live refuses these with no override, dry / replay warn."""
212
+ bad = []
213
+ if observed and float(table_z) != 0.0: # round v12 flat-floor students (``student_floor_observed``)
214
+ bad.append(f"--table-z {float(table_z):g} with a student trained under the flat arm-frame floor (checkpoint "
215
+ "v8_online.student_floor observed): its floor was 1.5 mm above z 0 of the arm frame in training; "
216
+ f"--table-z moves it {abs(float(table_z)) * 1e3:.1f} mm {'lower' if table_z < 0 else 'higher'} "
217
+ "(leave --table-z at 0)")
218
+ qo = np.zeros(ARM) if q_offset_deg is None else np.asarray(q_offset_deg, np.float64)
219
+ if mode == "plane" and np.any(qo != 0.0):
220
+ return bad + [f"--q-offset-deg {','.join(f'{v:g}' for v in qo)} in floor mode plane: the mat plane is in the "
221
+ "calib_v1 joint frame, an offset moves the floor into the mat (live-tilt / --q-offset-deg are "
222
+ "for flat students only)"]
223
+ if table_frame and np.any(qo != 0.0): # round v12 flat-floor table students (``student_table_frame``)
224
+ return bad + [f"--q-offset-deg {','.join(f'{v:g}' for v in qo)} with a student trained in the table frame: "
225
+ "it already corrects for the real table (the offset would correct twice; live-tilt / "
226
+ "--q-offset-deg are for students trained on the sim table only)"]
227
+ return bad
228
+
229
+
230
+ def floor_lines(mode, why, table_z, plane, gcfg):
231
+ """The banner's floor lines (mm, relative to the real mat at the observed cube / plate positions)."""
232
+ from nedm.so101_policy import joint_env as JE
233
+ f = JE.FLOOR * 1e3
234
+ cmd, hard = gcfg.cmd_floor_m * 1e3, gcfg.hard_floor_m * 1e3
235
+ if mode == "plane":
236
+ c0, c1, c2 = plane
237
+ return [f"FLOOR MODE plane: student {why}",
238
+ f" floor {f:.1f} mm above the mat plane z = {c0 * 1e3:.1f} mm {c1 * 1e3:+.1f} x {c2 * 1e3:+.1f} y "
239
+ f"(mm per m; calib_v1 scene.table_plane); stops: command {-cmd:.1f} mm, measured {-hard:.1f} mm below "
240
+ f"the plane. Relative to the real mat (everywhere, +-3 mm calibration): floor {f:+.1f} mm, command "
241
+ f"stop {cmd:+.1f} mm, measured stop {hard:+.1f} mm"]
242
+ z = table_z * 1e3
243
+
244
+ def rng(v, mat): # a height relative to sim z = 0 -> relative to the mat (mat range vs sim z 0, mm)
245
+ a, b = v - mat[1], v - mat[0]
246
+ return f"{a:+.1f} .. {b:+.1f} mm"
247
+ (lo, hi), (tlo, thi) = OBSERVED_MAT_MM, TASK_MAT_MM
248
+ return [f"FLOOR MODE flat: student {why}",
249
+ f" floor {f:.1f} mm above sim z = table_z {z:+.1f} mm; stops: command {cmd:+.1f} mm, measured {hard:+.1f} "
250
+ f"mm (+ table_z). Relative to the real mat at the observed cube / plate positions ({lo:.1f} .. {hi:.1f} mm "
251
+ f"vs sim z 0): floor {rng(z + f, OBSERVED_MAT_MM)}, command stop {rng(z + cmd, OBSERVED_MAT_MM)}, measured "
252
+ f"stop {rng(z + hard, OBSERVED_MAT_MM)}",
253
+ f" task area r {TASK_R_M[0]}-{TASK_R_M[1]} m +-{TASK_DEG:g} deg (mat {tlo:.2f} .. {thi:.2f} mm vs sim z "
254
+ f"0): floor {rng(z + f, TASK_MAT_MM)}, command stop {rng(z + cmd, TASK_MAT_MM)}, measured stop "
255
+ f"{rng(z + hard, TASK_MAT_MM)}"]
256
+
257
+
258
+ def load_calib(path):
259
+ """calib_v1.json (the study's calibration contract) -> dict, or None if the path is empty / missing."""
260
+ if not path:
261
+ return None
262
+ p = Path(path).expanduser()
263
+ if not p.exists():
264
+ return None
265
+ return json.loads(p.read_text())
266
+
267
+
268
+ @dataclass
269
+ class JointMap:
270
+ """real (LeRobot units) <-> sim (rad), module docstring."""
271
+ sign: np.ndarray
272
+ offset_rad: np.ndarray
273
+ grip_a: float
274
+ grip_b: float
275
+ placeholder: bool = False
276
+ source: str = ""
277
+
278
+ def __post_init__(self):
279
+ self.sign = np.asarray(self.sign, np.float64).reshape(ARM)
280
+ self.offset_rad = np.asarray(self.offset_rad, np.float64).reshape(ARM)
281
+ if not np.all(np.isin(self.sign, (-1.0, 1.0))):
282
+ raise ValueError(f"joint_map sign must be +1 / -1, got {self.sign.tolist()}")
283
+ if not np.all(np.isfinite(self.offset_rad)):
284
+ raise ValueError("joint_map offset_rad must be finite")
285
+ self.grip_a, self.grip_b = float(self.grip_a), float(self.grip_b)
286
+ if not (math.isfinite(self.grip_a) and math.isfinite(self.grip_b)) or abs(self.grip_a) < 1e-9:
287
+ raise ValueError(f"joint_map gripper_lin invalid: {[self.grip_a, self.grip_b]}")
288
+
289
+ @staticmethod
290
+ def placeholder_identity():
291
+ return JointMap(np.ones(ARM), np.zeros(ARM), math.pi / 180.0, 0.0, placeholder=True,
292
+ source="placeholder identity (no calib_v1.json joint_map; signs / offsets NOT verified)")
293
+
294
+ @staticmethod
295
+ def from_dict(d, source="calib"):
296
+ names = d.get("names")
297
+ if names is not None and tuple(names)[:ARM] != JOINTS[:ARM]:
298
+ raise ValueError(f"joint_map names {names} differ from {JOINTS}")
299
+ lin = d["gripper_lin"]
300
+ return JointMap(d["sign"][:ARM], d["offset_rad"][:ARM], lin[0], lin[1],
301
+ placeholder=bool(d.get("placeholder", False)), source=source)
302
+
303
+ @staticmethod
304
+ def from_calib(calib, source="calib"):
305
+ if calib is None or "joint_map" not in calib:
306
+ return JointMap.placeholder_identity()
307
+ return JointMap.from_dict(calib["joint_map"], source)
308
+
309
+ def real_to_sim(self, real):
310
+ r = np.asarray(real, np.float64)
311
+ out = np.empty_like(r)
312
+ out[..., :ARM] = self.sign * np.radians(r[..., :ARM]) + self.offset_rad
313
+ out[..., ARM] = self.grip_a * r[..., ARM] + self.grip_b
314
+ return out
315
+
316
+ def sim_to_real(self, sim):
317
+ s = np.asarray(sim, np.float64)
318
+ out = np.empty_like(s)
319
+ out[..., :ARM] = np.degrees(self.sign * (s[..., :ARM] - self.offset_rad))
320
+ out[..., ARM] = (s[..., ARM] - self.grip_b) / self.grip_a
321
+ return out
322
+
323
+ def describe(self):
324
+ return dict(sign=self.sign.tolist(), offset_rad=self.offset_rad.tolist(), gripper_lin=[self.grip_a, self.grip_b],
325
+ placeholder=self.placeholder, source=self.source)
326
+
327
+
328
+ @dataclass
329
+ class RealLimits:
330
+ """Allowed real targets (LeRobot units) from the LeRobot calibration file: the calibrated range of every motor
331
+ minus ``margin`` (arm deg / gripper units)."""
332
+ lo: np.ndarray
333
+ hi: np.ndarray
334
+ source: str = ""
335
+
336
+ @staticmethod
337
+ def from_lerobot_calibration(cal, margin_deg=3.0, margin_grip=0.0, source=""):
338
+ if isinstance(cal, (str, Path)):
339
+ source = source or str(cal)
340
+ cal = json.loads(Path(cal).expanduser().read_text())
341
+ lo, hi = np.zeros(6), np.zeros(6)
342
+ for i, m in enumerate(JOINTS):
343
+ c = cal[m]
344
+ mn, mx = float(c["range_min"]), float(c["range_max"])
345
+ if int(c.get("drive_mode", 0)) != 0:
346
+ raise ValueError(f"{m}: drive_mode {c['drive_mode']} not handled (expected 0)")
347
+ if i < ARM:
348
+ mid = (mn + mx) / 2
349
+ lo[i] = (mn - mid) * 360.0 / (STS_RES - 1) + margin_deg
350
+ hi[i] = (mx - mid) * 360.0 / (STS_RES - 1) - margin_deg
351
+ else:
352
+ lo[i], hi[i] = 0.0 + margin_grip, 100.0 - margin_grip
353
+ return RealLimits(lo, hi, source)
354
+
355
+ def clip(self, real):
356
+ r = np.asarray(real, np.float64)
357
+ c = np.minimum(np.maximum(r, self.lo), self.hi)
358
+ return c, np.abs(c - r) > 1e-9
359
+
360
+ def outside(self, real, tol=0.0):
361
+ r = np.asarray(real, np.float64)
362
+ return (r < self.lo - tol) | (r > self.hi + tol)
363
+
364
+
365
+ # ---- images ---------------------------------------------------------------------------------------------------------
366
+ # ONE crop + resize for sim and real: src/nedm/render/student_view.py (numpy + cv2 only), also used by the renderer
367
+ # (nedm.render.so101.RealScene). Loaded by file path, so no nedm.render package import (no torch / newton / warp).
368
+ def _load_student_view():
369
+ import importlib.util
370
+ import os
371
+ import sys
372
+ mod = sys.modules.get("nedm.render.student_view")
373
+ if mod is not None:
374
+ return mod
375
+ roots = [os.environ.get("NEDM_SRC"), str(Path(__file__).resolve().parents[4] / "src")]
376
+ for root in roots:
377
+ if not root:
378
+ continue
379
+ path = Path(root) / "nedm/render/student_view.py"
380
+ if path.exists():
381
+ spec = importlib.util.spec_from_file_location("_nedm_student_view", path)
382
+ mod = importlib.util.module_from_spec(spec)
383
+ sys.modules[spec.name] = mod # dataclasses need the module registered
384
+ spec.loader.exec_module(mod)
385
+ return mod
386
+ raise ImportError("src/nedm/render/student_view.py not found (NEDM_SRC or the repo / bundle layout): the robot "
387
+ "bundle must contain it (make_orin_bundle.sh)")
388
+
389
+
390
+ _SV = _load_student_view()
391
+ ViewSpec = _SV.ViewSpec
392
+ centre_square = _SV.centre_square
393
+ view_specs = _SV.view_specs # (calib, real_cams, out_res, width=640, height=480, interp="area")
394
+ preprocess = _SV.crop_resize # (img, spec, bgr): crop box, then cv2 resize -> RGB uint8 [out_h, out_w, 3]
395
+ _INTERP = _SV._INTERP
396
+
397
+
398
+ def thumb(img, res):
399
+ import cv2
400
+ return cv2.resize(img, (res, res), interpolation=cv2.INTER_AREA) if res and img.shape[0] != res else img
401
+
402
+
403
+ # ---- qdot ---------------------------------------------------------------------------------------------------------
404
+ class QdotEstimator:
405
+ """Joint velocity (rad/s) from the measured q of the last ``window`` control steps: least-squares slope over the
406
+ window (window 3 = 40 ms span, about 20 ms lag). Restarts after a gap > ``max_gap`` s. The sim student saw the exact
407
+ joint velocity (training noise 0.3 x its std); the STS3215 position resolution is 1.5 mrad."""
408
+
409
+ def __init__(self, window=3, max_gap=0.1):
410
+ self.window, self.max_gap = int(window), float(max_gap)
411
+ self.reset()
412
+
413
+ def reset(self):
414
+ self.t, self.q = [], []
415
+
416
+ def update(self, t, q):
417
+ q = np.asarray(q, np.float64)
418
+ if self.t and (t - self.t[-1] > self.max_gap or t <= self.t[-1]):
419
+ self.reset()
420
+ self.t.append(float(t))
421
+ self.q.append(q)
422
+ if len(self.t) > self.window:
423
+ self.t.pop(0)
424
+ self.q.pop(0)
425
+ if len(self.t) < 2:
426
+ return np.zeros_like(q)
427
+ tt = np.asarray(self.t)
428
+ qq = np.stack(self.q)
429
+ tc = tt - tt.mean()
430
+ return (tc[:, None] * (qq - qq.mean(0))).sum(0) / (tc ** 2).sum()
431
+
432
+
433
+ # ---- the action layer (sim) and the hardware guard ---------------------------------------------------------------
434
+ def default_kin_points():
435
+ """The SO101 gripper / moving-jaw collision points (.npz, ``kin.save_points``): first that exists of
436
+ $SO101_HW_ASSETS/kin_points_v1.npz, <bundle>/assets/kin_points_v1.npz,
437
+ <repository>/artifacts/so101_pick_place/rl_inputs/geometry/kin_points_v1.npz (the downloaded file)."""
438
+ import os
439
+ here = Path(__file__).resolve()
440
+ cands = []
441
+ if os.environ.get("SO101_HW_ASSETS"):
442
+ cands.append(Path(os.environ["SO101_HW_ASSETS"]) / "kin_points_v1.npz")
443
+ if len(here.parents) > 4:
444
+ cands.append(here.parents[4] / "assets" / "kin_points_v1.npz")
445
+ if len(here.parents) > 4:
446
+ cands.append(here.parents[4] / "artifacts" / "so101_pick_place" / "rl_inputs" / "geometry" / "kin_points_v1.npz")
447
+ for c in cands:
448
+ if c.exists():
449
+ return c
450
+ return None
451
+
452
+
453
+ class ActionLayer:
454
+ """``joint_env.safety`` for one robot (the action layer of teacher and student): arm targets within ``joint_env.LEAD``
455
+ of the measured q, all targets within the collector's range (kin.TLO .. THI), the table floor (``floor_guard``:
456
+ lowest gripper / moving-jaw point >= ``joint_env.FLOOR`` + table_z unless the measured pose is lower). The kinematics
457
+ use the saved collision points (no mujoco).
458
+
459
+ ``table_plane`` (c0, c1, c2) (real2sim v8; None = off, the old flat floor bit for bit): the floor follows a tilted
460
+ table instead: the lowest point's height ABOVE the plane z = c0 + c1 x + c2 y (``kin.lowest_point(plane=)``) >=
461
+ FLOOR, and the guard's floor checks (``Guard``, ``check_path``) measure above the plane too (``floor_height``). A
462
+ student trained with the v8 table randomisation (the floor 1.5 mm above the TRUE table in training) deploys with
463
+ the calibrated plane (``run_student_real.py --table-plane calib``), never with the flat ``table_z`` 0 (~13 mm above
464
+ the real table at the cubes). Exclusive with ``table_z``."""
465
+
466
+ def __init__(self, kin_points, table_z=0.0, lead=True, floor=True, table_plane=None):
467
+ import torch
468
+
469
+ from nedm.so101_policy import joint_env as JE
470
+ from nedm.so101_policy.kin import SO101Kin
471
+ if kin_points is None or not Path(kin_points).expanduser().exists():
472
+ raise FileNotFoundError(f"kin points file {kin_points} missing (needed for the table floor without mujoco)")
473
+ self.torch, self.JE = torch, JE
474
+ self.kin = SO101Kin("cpu", points=str(Path(kin_points).expanduser()))
475
+ self.tlo, self.thi = self.kin.tlo.clone(), self.kin.thi.clone()
476
+ self.lead = torch.tensor(JE.LEAD, dtype=torch.float64) if lead else None
477
+ self.table_z = float(table_z)
478
+ self.plane = None
479
+ if table_plane is not None:
480
+ self.plane = tuple(float(c) for c in table_plane)
481
+ if len(self.plane) != 3 or not all(math.isfinite(c) for c in self.plane):
482
+ raise ValueError(f"table_plane {table_plane}: (c0, c1, c2), z = c0 + c1 x + c2 y (m)")
483
+ if self.table_z != 0.0:
484
+ raise ValueError("table_plane and table_z: give one of them")
485
+ self.floor = JE.FLOOR + self.table_z if floor else None
486
+ self.lowest(np.zeros(6)) # builds the reduced point set now (0.4 s on luffy), not in the first step
487
+
488
+ def __call__(self, u, q):
489
+ """u, q: sim rad [6] -> (u' [6], dict lead / range / floor: which rule changed the target)."""
490
+ t = self.torch
491
+ u0 = t.as_tensor(np.asarray(u, np.float64))[None]
492
+ q0 = t.as_tensor(np.asarray(q, np.float64))[None]
493
+ if self.plane is None:
494
+ out = self.JE.safety(u0, q0, self.tlo, self.thi, self.lead, self.kin, self.floor)[0].numpy()
495
+ else:
496
+ out = self.JE.safety(u0, q0, self.tlo, self.thi, self.lead, self.kin, self.floor,
497
+ floor_plane=self.plane)[0].numpy()
498
+ # attribution of the change (diagnostics only)
499
+ u1 = u0.clone()
500
+ if self.lead is not None:
501
+ u1[:, :ARM] = t.minimum(t.maximum(u1[:, :ARM], q0[:, :ARM] - self.lead), q0[:, :ARM] + self.lead)
502
+ lead_on = bool((u1 - u0).abs().max() > 1e-12)
503
+ u2 = t.minimum(t.maximum(u1, self.tlo), self.thi)
504
+ range_on = bool((u2 - u1).abs().max() > 1e-12)
505
+ floor_on = bool(np.abs(out - u2[0].numpy()).max() > 1e-12)
506
+ return out, dict(lead=lead_on, range=range_on, floor=floor_on)
507
+
508
+ def lowest(self, q):
509
+ """Lowest gripper / moving-jaw point (m, world z) of sim poses q [..., 6] (fast point set, as the floor rule)."""
510
+ t = self.torch
511
+ qq = t.as_tensor(np.asarray(q, np.float64)).reshape(-1, 6)
512
+ return self.kin.lowest_point(qq, exact=False).numpy().reshape(np.shape(q)[:-1])
513
+
514
+ def floor_height(self, q):
515
+ """(lowest gripper / moving-jaw point, the floor checks' reference): (``lowest(q)`` world z, ``table_z``) with
516
+ the flat floor (the old checks unchanged), (height above ``table_plane``, 0.0) with a plane floor."""
517
+ if self.plane is None:
518
+ return self.lowest(q), self.table_z
519
+ t = self.torch
520
+ qq = t.as_tensor(np.asarray(q, np.float64)).reshape(-1, 6)
521
+ return self.kin.lowest_point(qq, exact=False, plane=self.plane).numpy().reshape(np.shape(q)[:-1]), 0.0
522
+
523
+ def tcp(self, q):
524
+ """Grasp point (m, world) of sim poses q [..., 6]."""
525
+ t = self.torch
526
+ qq = t.as_tensor(np.asarray(q, np.float64)).reshape(-1, 6)
527
+ p, _ = self.kin.fk(qq)
528
+ return p.numpy().reshape(*np.shape(q)[:-1], 3)
529
+
530
+
531
+ @dataclass
532
+ class GuardConfig:
533
+ """Hardware limits on top of the action layer (module docstring). Sim teacher labels for scale (build9 d1 r0,
534
+ 49k decisions): per-step target change p99 0.030-0.037 rad (arm), max 0.04-0.07 rad inside a decision and up to
535
+ 0.18 rad between decisions; jaw up to 1.4 rad between decisions."""
536
+ max_step_rad: tuple = (0.06, 0.06, 0.06, 0.06, 0.08, 0.5) # command change per 20 ms step (sim rad)
537
+ max_rel_real: tuple = (10.0, 10.0, 10.0, 10.0, 10.0, 60.0) # |command - measured| (LeRobot units)
538
+ range_margin_deg: float = 3.0 # inside the LeRobot calibrated range
539
+ measured_range_tol: float = 5.0 # measured q may be this far outside (deg) before a stop
540
+ hard_floor_m: float = -0.005 # stop if the MEASURED lowest gripper point is below table_z + this (or this
541
+ # above the layer's table_plane)
542
+ cmd_floor_m: float = -0.002 # stop if the COMMANDED lowest point is below table_z + this (after the layer)
543
+ tcp_x: tuple = (-0.10, 0.45) # grasp point box (m, world)
544
+ tcp_y: tuple = (-0.42, 0.42)
545
+ tcp_z: tuple = (-0.01, 0.40)
546
+ tcp_r_max: float = 0.45 # grasp point distance from the pan axis (m)
547
+ stall_frac: float = 0.9 # live only: an arm joint that stays >= stall_frac x its lead band (joint_env.LEAD)
548
+ stall_steps: int = 25 # from the previous command for stall_steps steps (0.5 s) is blocked: stop
549
+ i_time_s: float = 0.0 # integral correction of the real servos' static error (0 = off; arm joints):
550
+ i_max_deg: float = 3.0 # each step adds (command - measured q) * DT / i_time_s, the sum <= i_max_deg,
551
+ i_v_min: float = 0.02 # only while the joint does not move to its command faster than this (rad/s)
552
+ i_e_max_deg: float = 1.0 # and only while |command - measured q| < this (not for a blocked joint)
553
+ i_antiwindup: bool = True # not on a joint at its LeRobot-unit range (Guard.apply; False = the rule
554
+ # of the robot days 2026-10-22 .. 23)
555
+
556
+ @staticmethod
557
+ def from_dict(d):
558
+ d = dict(d or {})
559
+ known = set(GuardConfig.__dataclass_fields__)
560
+ bad = sorted(set(d) - known)
561
+ if bad:
562
+ raise ValueError(f"unknown guard keys {bad}")
563
+ return GuardConfig(**{k: (tuple(v) if isinstance(v, list) else v) for k, v in d.items()})
564
+
565
+
566
+ class Guard:
567
+ """Hardware guard (``GuardConfig``). ``check_measured`` -> stop reasons of the measured state; ``apply`` -> the
568
+ command (sim and real units) after: step limit vs the previous command, the action layer, LeRobot-unit range and
569
+ max relative target vs the measured q, then the final checks (finite, workspace box, commanded floor).
570
+
571
+ ``u_layer`` (sim rad [6], None before the first ``apply`` or after a non-finite target): the target of the last
572
+ ``apply`` right after the step limit and the action layer, BEFORE the integral correction and the LeRobot-unit
573
+ clamps = the sim's executed target (``joint_env`` ``u_exe``). The command input of a ``cmd_in`` student reads it,
574
+ never the sent command (``u_sim``: + the integral correction) or ``prev`` (+ the LeRobot clamps).
575
+
576
+ Anti-windup of the integral correction (``GuardConfig.i_antiwindup``, on by default; real2sim 2026-10-24): a joint
577
+ at its LeRobot-unit range (``real_range_sim``) cannot follow a correction. Without the rule the integral grew there
578
+ (robot 2026-10-23, eval_20261023_141614 ep 6 and eval_20261023_144431 ep 1: measured wrist roll 100.69 sim deg,
579
+ target 100.9-101.1, range end 101.21, the error 0.4 deg < i_e_max_deg so the integral reached +3 deg; the sent
580
+ command stayed clipped at 101.21, ``prev`` = 101.21 - 3 = 98.2 deg, 2.5 deg >= 0.9 x LEAD from the measured roll:
581
+ "stall: wrist_roll blocked" after 25 steps). With the rule, on a joint whose action-layer target or student target
582
+ is at / beyond its range, or whose corrected command would be clipped there, the error is not integrated; the
583
+ correction is 0 on a joint whose action-layer target is at / beyond its range (either sign: the sent command is
584
+ the clipped target and ``prev`` = that command, as without the integral), else limited to [lo - target,
585
+ hi - target] (it never pushes the command past the range; ``prev`` = the target). Joints inside their range are
586
+ not changed. ``i_aw`` [5] bool: the arm joints the rule held in the last ``apply`` (at /
587
+ beyond the range; logged per step as ``i_aw``)."""
588
+
589
+ def __init__(self, cfg: GuardConfig, layer: ActionLayer, jmap: JointMap, limits: RealLimits):
590
+ self.cfg, self.layer, self.jmap, self.limits = cfg, layer, jmap, limits
591
+ self.max_step = np.asarray(cfg.max_step_rad, np.float64)
592
+ self.max_rel = np.asarray(cfg.max_rel_real, np.float64)
593
+ self.prev = None
594
+ self.err_run = 0
595
+ self.integ = np.zeros(ARM)
596
+ self.i_aw = np.zeros(ARM, bool)
597
+ self.u_layer = None
598
+
599
+ def reset(self, q_sim):
600
+ self.prev = np.asarray(q_sim, np.float64).copy()
601
+ self.err_run = 0
602
+ self.integ = np.zeros(ARM)
603
+ self.i_aw = np.zeros(ARM, bool)
604
+ self.u_layer = None
605
+
606
+ def real_range_sim(self):
607
+ """The LeRobot-unit range (``limits``: calibrated range - margin) of the 5 arm joints in sim rad -> (lo, hi)."""
608
+ a = self.jmap.real_to_sim(self.limits.lo)[:ARM]
609
+ b = self.jmap.real_to_sim(self.limits.hi)[:ARM]
610
+ return np.minimum(a, b), np.maximum(a, b)
611
+
612
+ def _box(self, p):
613
+ c = self.cfg
614
+ r = math.hypot(p[0] - 0.0388, p[1])
615
+ bad = []
616
+ if not (c.tcp_x[0] <= p[0] <= c.tcp_x[1] and c.tcp_y[0] <= p[1] <= c.tcp_y[1] and c.tcp_z[0] <= p[2] <= c.tcp_z[1]):
617
+ bad.append(f"workspace box: grasp point {np.round(p, 3).tolist()} outside")
618
+ if r > c.tcp_r_max:
619
+ bad.append(f"reach: grasp point {r:.3f} m from the pan axis > {c.tcp_r_max}")
620
+ return bad
621
+
622
+ def check_measured(self, q_sim, q_real):
623
+ c, stop = self.cfg, []
624
+ if not (np.all(np.isfinite(q_sim)) and np.all(np.isfinite(q_real))):
625
+ return ["measured q: not finite"]
626
+ out = self.limits.outside(q_real, c.measured_range_tol)
627
+ if out.any():
628
+ stop.append("measured range: outside the calibrated range: " + ", ".join(
629
+ f"{JOINTS[i]} {q_real[i]:.1f}" for i in np.flatnonzero(out)))
630
+ low, ref = self.layer.floor_height(q_sim) # (flat floor: lowest(q), table_z as before)
631
+ low = float(low)
632
+ if low < ref + c.hard_floor_m:
633
+ stop.append(f"measured floor: lowest gripper point {low * 1e3:.1f} mm"
634
+ + (" above the table plane" if self.layer.plane is not None else "") + ", below the hard floor")
635
+ stop += ["measured " + s for s in self._box(self.layer.tcp(q_sim))]
636
+ return stop
637
+
638
+ def apply(self, u_sim, q_sim, q_real, qd_sim=None):
639
+ """-> (command sim [6], command real [6], events dict, stop reasons). ``qd_sim``: the measured joint speed for
640
+ the integral correction (None: the joints count as not moving)."""
641
+ c = self.cfg
642
+ ev = dict(step=False, lead=False, range=False, floor=False, real_range=False, max_rel=False)
643
+ u = np.asarray(u_sim, np.float64)
644
+ self.u_layer, self.i_aw = None, np.zeros(ARM, bool)
645
+ if not np.all(np.isfinite(u)):
646
+ return None, None, ev, ["student target: not finite"]
647
+ if self.prev is None:
648
+ self.reset(q_sim)
649
+ d = np.clip(u - self.prev, -self.max_step, self.max_step)
650
+ ev["step"] = bool(np.any(np.abs(d - (u - self.prev)) > 1e-12))
651
+ u = self.prev + d
652
+ u, info = self.layer(u, q_sim)
653
+ self.u_layer = np.array(u, np.float64) # the sim's executed target (class docstring): before the integral
654
+ ev.update(info)
655
+ if c.i_time_s > 0: # the real servos stop short of a small command under load (sim: they follow)
656
+ imax = math.radians(c.i_max_deg)
657
+ e = u[:ARM] - np.asarray(q_sim)[:ARM]
658
+ if qd_sim is not None: # a joint that follows its command needs no correction (no wind-up in motion)
659
+ e = np.where(np.asarray(qd_sim)[:ARM] * np.sign(e) > c.i_v_min, 0.0, e)
660
+ e = np.where(np.abs(e) < math.radians(c.i_e_max_deg), e, 0.0) # blocked joint / new target: no more push
661
+ if c.i_antiwindup: # a joint at its real range: no integration (class docstring)
662
+ rlo, rhi = self.real_range_sim()
663
+ t5, s5, c5 = u[:ARM], np.asarray(u_sim, np.float64)[:ARM], u[:ARM] + self.integ
664
+ tol = 1e-9
665
+ self.i_aw = ((t5 >= rhi - tol) | (t5 <= rlo + tol) | (s5 > rhi) | (s5 < rlo) | (c5 >= rhi - tol)
666
+ | (c5 <= rlo + tol))
667
+ e = np.where(self.i_aw, 0.0, e)
668
+ self.integ = np.clip(self.integ + e * (DT / c.i_time_s), -imax, imax)
669
+ if c.i_antiwindup: # bleed off: 0 for a target at / beyond the range, else never past it
670
+ at = (t5 >= rhi - tol) | (t5 <= rlo + tol)
671
+ self.integ = np.where(at, 0.0, np.clip(self.integ, rlo - t5, rhi - t5))
672
+ u = u.copy()
673
+ u[:ARM] += self.integ
674
+ ur = self.jmap.sim_to_real(u)
675
+ ur, m1 = self.limits.clip(ur)
676
+ lo, hi = np.asarray(q_real) - self.max_rel, np.asarray(q_real) + self.max_rel
677
+ ur2 = np.minimum(np.maximum(ur, lo), hi)
678
+ ev["real_range"], ev["max_rel"] = bool(m1.any()), bool(np.any(np.abs(ur2 - ur) > 1e-9))
679
+ ur = ur2
680
+ u = self.jmap.real_to_sim(ur)
681
+ stop = []
682
+ if not np.all(np.isfinite(ur)):
683
+ stop.append("command: not finite")
684
+ low, ref = self.layer.floor_height(u)
685
+ low = float(low)
686
+ if low < ref + c.cmd_floor_m and low < float(self.layer.floor_height(q_sim)[0]) - 1e-4:
687
+ stop.append(f"command floor: lowest gripper point {low * 1e3:.1f} mm"
688
+ + (" above the table plane" if self.layer.plane is not None else "") + ", below the floor")
689
+ stop += ["command " + s for s in self._box(self.layer.tcp(u))]
690
+ self.prev = u.copy() # the step limit and the stall check: the command without the correction
691
+ self.prev[:ARM] -= self.integ
692
+ return u, ur, ev, stop
693
+
694
+ def stall(self, q_sim, cmd_prev_sim):
695
+ """Live only: the lead band keeps every arm command within LEAD of the measured q, so a blocked joint shows as a
696
+ command error that stays near its lead band. -> stop reason after stall_steps such steps in a row."""
697
+ if cmd_prev_sim is None or self.layer.lead is None:
698
+ return []
699
+ lead = self.layer.lead.numpy()
700
+ e = np.abs(np.asarray(q_sim)[:ARM] - np.asarray(cmd_prev_sim)[:ARM])
701
+ sat = e >= self.cfg.stall_frac * lead
702
+ self.err_run = self.err_run + 1 if sat.any() else 0
703
+ if self.err_run >= self.cfg.stall_steps:
704
+ j = int(np.argmax(e / lead))
705
+ return [f"stall: {JOINTS[j]} blocked, command error {e[j]:.3f} rad (lead band {lead[j]:.3f}) for {self.err_run} steps"]
706
+ return []
707
+
708
+
709
+ # ---- joint-space moves (HOME, return) --------------------------------------------------------------------------
710
+ def plan_joint_path(q_from, q_to, max_speed, dt=DT, min_time=1.0):
711
+ """Joint-space straight line q_from -> q_to (sim rad [6]) with a cosine time law whose peak joint speed stays
712
+ within max_speed (rad/s, scalar or [6]). -> waypoints [N, 6] (excludes q_from, ends at q_to), duration s."""
713
+ a, b = np.asarray(q_from, np.float64), np.asarray(q_to, np.float64)
714
+ v = np.broadcast_to(np.asarray(max_speed, np.float64), a.shape)
715
+ T = max(float(min_time), float(np.max(np.abs(b - a) / v)) * math.pi / 2)
716
+ n = max(1, int(math.ceil(T / dt)))
717
+ s = 0.5 - 0.5 * np.cos(math.pi * np.arange(1, n + 1) / n)
718
+ return a + s[:, None] * (b - a), n * dt
719
+
720
+
721
+ def check_path(path, layer: ActionLayer, jmap: JointMap, limits: RealLimits, clearance=0.02, start=None,
722
+ goal_measured=False):
723
+ """Problems of a joint path (sim rad [N, 6]): a waypoint outside the collector's range or the LeRobot calibrated
724
+ range, or with its lowest gripper point below min(table_z + clearance, the lowest point of either end) - 1 mm, or
725
+ its grasp point outside the guard box (checked by the caller's Guard). A measured end pose (``start``; the last
726
+ waypoint if ``goal_measured``) may lie outside the collector's range (the real gripper closed: LeRobot gripper
727
+ < 2.9 = sim jaw < kin.TLO); a straight path stays between its ends, so waypoints between that end and the range
728
+ are accepted. -> list of strings (empty = ok)."""
729
+ p = np.asarray(path, np.float64)
730
+ ends = p[[0, -1]] if start is None else np.stack((np.asarray(start, np.float64), p[-1]))
731
+ bad = []
732
+ tlo, thi = layer.tlo.numpy(), layer.thi.numpy()
733
+ for m in ([] if start is None else [np.asarray(start, np.float64)]) + ([p[-1]] if goal_measured else []):
734
+ tlo, thi = np.minimum(tlo, m), np.maximum(thi, m)
735
+ if np.any(p < tlo - 1e-9) or np.any(p > thi + 1e-9):
736
+ bad.append("path leaves the sim joint range (kin.TLO .. THI)")
737
+ if limits.outside(jmap.sim_to_real(p)).any():
738
+ bad.append("path leaves the LeRobot calibrated range (minus margin)")
739
+ low, z0 = layer.floor_height(p) # (flat floor: lowest(p), table_z as before; plane: above it)
740
+ ref = min(z0 + clearance, float(layer.floor_height(ends)[0].min()))
741
+ if float(low.min()) < ref - 1e-3:
742
+ k = int(low.argmin())
743
+ bad.append(f"path waypoint {k} lowest gripper point {low[k] * 1e3:.1f} mm < {ref * 1e3:.1f} mm")
744
+ return bad
745
+
746
+
747
+ # ---- the student ----------------------------------------------------------------------------------------------------
748
+ def resolve_cam_map(student_cams, spec=None):
749
+ """{student camera: real camera}: ``spec`` "top=external,wrist=wrist" or a dict; default DEFAULT_CAM_MAP."""
750
+ m = dict(DEFAULT_CAM_MAP)
751
+ if isinstance(spec, str) and spec:
752
+ for kv in spec.split(","):
753
+ k, v = kv.split("=")
754
+ m[k.strip()] = v.strip()
755
+ elif isinstance(spec, dict):
756
+ m.update(spec)
757
+ out = {}
758
+ for c in student_cams:
759
+ if c not in m:
760
+ raise ValueError(f"student camera {c!r} has no real camera (use --cam-map {c}=external)")
761
+ if m[c] not in REAL_CAMERAS:
762
+ raise ValueError(f"real camera {m[c]!r} unknown (expected one of {REAL_CAMERAS})")
763
+ out[c] = m[c]
764
+ if len(set(out.values())) != len(out):
765
+ raise ValueError(f"two student cameras read the same real camera: {out}")
766
+ return out
767
+
768
+
769
+ class StudentPolicy:
770
+ """The build9 camera student (``vision.viral.ViralNet``) as a real-robot policy: images of its cameras (the student's
771
+ RGB uint8 [res, res, 3], ``preprocess``), q and qdot (sim units) -> absolute chunk [K, 6] (sim rad), the executed
772
+ part [n_exec, 6] (jaw ``jaw_lead`` steps ahead, as ``viral.Actor``), the auxiliary predictions (block = plate
773
+ x, y, yaw mod 90 deg; cube x, y, z). Same normalisation and bf16 autocast as ``viral.Actor``.
774
+
775
+ Input options (as ``viral.OnlineDAgger`` / ``viral.Actor``; ``reset`` at every episode start; independent of each
776
+ other; robot vector order [q, qd, history, cmd, last command]):
777
+ - ``cfg.hist``: [q, qd] of the previous ``hist`` queries, newest first (the current values repeated at the first
778
+ query).
779
+ - ``cfg.cmd_in``: the previous decision's 5 executed targets - q now, raw rad [5, 6] flattened after the history
780
+ (the net divides by ``cmd_scale``); 0 at the first query. ``query(..., u_prev=)`` = ``Guard.u_layer`` of the 5
781
+ loop steps since the last query (``Controller`` passes them); a missing ``u_prev`` after the first query is
782
+ refused.
783
+ - ``cfg.lastcmd`` (``lastcmd``): ``query(..., last_cmd=(u_last, u_prev))`` = the commands sent in the last two
784
+ 20 ms steps before the query (sim rad [6]; ``Guard.prev``: without the integral correction), None at an episode
785
+ start (input 0; ``start=True``, else refused) -> ``viral.lastcmd_raw``, as the sim's ``u_exe[:, -1]`` /
786
+ ``[:, -2]``; 12 values after the cmd input.
787
+ - ``cfg.img_hist``: the previous query's image features (cached, no second encoder pass; the current ones at the
788
+ first query) appended to the head input.
789
+ A student whose head input is not exactly [features, robot vector above without the last command, (previous
790
+ features)] (an input option this class does not know) is refused. ``query`` returns the robot vector it fed
791
+ (``robot``)."""
792
+
793
+ def __init__(self, ckpt, device="cuda", cam_map=None, jaw_lead=None, amp=None):
794
+ import torch
795
+
796
+ from nedm.so101_policy.vision import viral as VI
797
+ self.torch, self.VI = torch, VI
798
+ self.dev = torch.device(device)
799
+ self.st, ck = VI.load_student(ckpt, device)
800
+ self.ckpt = str(Path(ckpt).expanduser())
801
+ self.meta = {k: v for k, v in ck.items() if k not in ("state_dict", "stats")}
802
+ self.cfg = self.st.cfg
803
+ self.cams = tuple(self.cfg.cameras)
804
+ self.cam_map = resolve_cam_map(self.cams, cam_map)
805
+ self.res = int(self.cfg.res)
806
+ self.n_exec, self.chunk = int(self.cfg.n_exec), int(self.cfg.chunk)
807
+ self.jaw_lead = int(self.cfg.jaw_lead if jaw_lead is None else jaw_lead)
808
+ self.amp = bool(self.cfg.amp if amp is None else amp) and self.dev.type == "cuda"
809
+ self.H = int(self.cfg.hist)
810
+ self.cmd_in = bool(getattr(self.cfg, "cmd_in", False))
811
+ self.img_hist = bool(getattr(self.cfg, "img_hist", False))
812
+ fd = int(self.st.fd)
813
+ want = fd + 12 * (1 + self.H) + (6 * self.n_exec if self.cmd_in else 0) + (fd if self.img_hist else 0)
814
+ got = int(self.st.head[0].in_features)
815
+ if got != want:
816
+ raise ValueError(f"student {self.ckpt}: head input {got} != {want} = features {fd} + [q, qd] x (1 + hist "
817
+ f"{self.H}) + cmd_in {self.cmd_in} + img_hist {self.img_hist}: an input option that the "
818
+ f"robot code does not implement")
819
+ self.rhist = None
820
+ self.lastcmd = bool(getattr(self.cfg, "lastcmd", False)) # own input layer: not in the head input
821
+ self.prev_feat = None # img_hist: the previous query's image features
822
+ self.n_query = 0 # queries since ``reset``
823
+
824
+ def reset(self):
825
+ self.rhist = None
826
+ self.prev_feat = None
827
+ self.n_query = 0
828
+
829
+ def warmup(self, n=3):
830
+ """``n`` (>= 2) queries on black images (the history / image-history / cmd / last-command paths included), then
831
+ ``reset``."""
832
+ z = {self.cam_map[c]: np.zeros((self.res, self.res, 3), np.uint8) for c in self.cams}
833
+ for i in range(max(2, int(n))):
834
+ self.query(z, np.zeros(6), np.zeros(6), u_prev=np.zeros((self.n_exec, 6)) if i else None,
835
+ last_cmd=(np.zeros(6), np.zeros(6)) if i else None, start=i == 0)
836
+ self.reset()
837
+
838
+ def query(self, images, q_sim, qd_sim, u_prev=None, last_cmd=None, start=False):
839
+ """``u_prev`` (``cmd_in`` students; others ignore it): the previous decision's executed targets [n_exec, 6]
840
+ (sim rad, ``Guard.u_layer`` of the loop steps since the last query); ignored at the first query (input 0).
841
+ ``last_cmd`` / ``start`` (``lastcmd`` students; others ignore them): class docstring."""
842
+ torch, VI = self.torch, self.VI
843
+ t0 = time.perf_counter()
844
+ with torch.no_grad():
845
+ rgb = np.stack([images[self.cam_map[c]] for c in self.cams])[None] # [1, C, H, W, 3]
846
+ if rgb.shape[2:4] != (self.res, self.res):
847
+ raise ValueError(f"student images must be {self.res} px, got {rgb.shape[2:4]}")
848
+ img = VI.to_input(torch.from_numpy(rgb).to(self.dev))
849
+ q = torch.as_tensor(np.asarray(q_sim, np.float32), device=self.dev)[None]
850
+ qd = torch.as_tensor(np.nan_to_num(np.asarray(qd_sim, np.float32)), device=self.dev)[None]
851
+ robot = torch.cat((q, qd), -1)
852
+ if self.H:
853
+ if self.rhist is None:
854
+ self.rhist = robot[:, None, :].expand(-1, self.H, -1).clone()
855
+ now = robot
856
+ robot = torch.cat((now, self.rhist.reshape(1, -1)), -1)
857
+ self.rhist = torch.cat((now[:, None, :], self.rhist[:, :-1]), 1)
858
+ if self.cmd_in: # the previous decision's executed targets - q now (0 at the first query)
859
+ if self.n_query == 0:
860
+ cmd = torch.zeros(1, 6 * self.n_exec, device=self.dev)
861
+ else:
862
+ if u_prev is None:
863
+ raise ValueError("cmd_in student: pass u_prev (Guard.u_layer of the loop steps since the last "
864
+ "query) after the first query of an episode")
865
+ up = np.asarray(u_prev, np.float32)
866
+ if up.shape != (self.n_exec, 6):
867
+ raise ValueError(f"u_prev shape {up.shape}, expected ({self.n_exec}, 6)")
868
+ cmd = (torch.as_tensor(up, device=self.dev) - q[:, None, :]).nan_to_num().reshape(1, -1)
869
+ robot = torch.cat((robot, cmd), -1)
870
+ lc = None
871
+ if self.lastcmd: # the last commands sent (None: the episode start, input 0)
872
+ if last_cmd is None:
873
+ if not start: # a caller that does not know the option would feed 0 at every query
874
+ raise ValueError("lastcmd student: pass last_cmd=(u_last, u_prev), or start=True at the "
875
+ "episode start")
876
+ lc = VI.lastcmd_zeros(1, self.dev)
877
+ else:
878
+ f64 = dict(dtype=torch.float64, device=self.dev)
879
+ lc = VI.lastcmd_raw(torch.as_tensor(np.asarray(last_cmd[0], np.float64), **f64)[None],
880
+ torch.as_tensor(np.asarray(last_cmd[1], np.float64), **f64)[None],
881
+ torch.as_tensor(np.asarray(q_sim, np.float64), **f64)[None])
882
+ robot = torch.cat((robot, lc.to(robot)), -1)
883
+ with torch.autocast(self.dev.type, dtype=torch.bfloat16, enabled=self.amp):
884
+ if self.img_hist: # the previous query's features (the first query: the current ones)
885
+ f = self.st.features(img)
886
+ p = self.st.head_from_features(f, robot, self.prev_feat)
887
+ self.prev_feat = f
888
+ else:
889
+ p, f = self.st(img, robot)
890
+ aux = self.st.aux(f)
891
+ delta = VI.denormalise(self.st, p.float())
892
+ aux = aux.float() * self.st.aux_std + self.st.aux_mean
893
+ u = (q[:, None, :] + delta)[0] # [K, 6]
894
+ jj = torch.arange(self.n_exec, device=self.dev)
895
+ kk = (jj + self.jaw_lead).clamp_max(u.shape[0] - 1)
896
+ ex = torch.cat((u[jj, :ARM], u[kk, ARM:]), -1)
897
+ out = dict(chunk=u.double().cpu().numpy(), exec=ex.double().cpu().numpy(),
898
+ aux=aux[0].double().cpu().numpy(), robot=robot[0].double().cpu().numpy())
899
+ if lc is not None:
900
+ out["lastcmd"] = lc[0].cpu().numpy()
901
+ self.n_query += 1
902
+ a = out["aux"]
903
+ out["plate_xy"] = a[:2]
904
+ out["plate_yaw4_deg"] = math.degrees(math.atan2(a[2], a[3]) / 4)
905
+ out["cube_xyz"] = a[4:7]
906
+ out["t_model_ms"] = (time.perf_counter() - t0) * 1e3
907
+ return out
908
+
909
+
910
+ # ---- one control step (replay, dry, live) ---------------------------------------------------------------------------
911
+ @dataclass
912
+ class StepOut:
913
+ u_sim: np.ndarray | None
914
+ u_real: np.ndarray | None
915
+ query: bool
916
+ stop: list = field(default_factory=list) # stop reasons (enforced in live)
917
+ events: dict = field(default_factory=dict)
918
+ timing: dict = field(default_factory=dict)
919
+
920
+
921
+ class Controller:
922
+ """The student's control step, identical for a replayed recording and the robot: measured q (real units) at time
923
+ t -> qdot estimate, every n_exec steps a query (``get_frames()`` -> {real camera: (image uint8 [480, 640, 3],
924
+ age ms)}; ``bgr``: images are BGR), the executed target of this step through ``Guard.apply`` (step limit, action
925
+ layer, LeRobot-unit limits). Keeps a per-step and per-query log (``arrays``: per-query keys start with "qry_").
926
+ Per step ``u_layer`` (``Guard.u_layer``: the action-layer target, before the integral correction and the LeRobot
927
+ clamps); a ``cmd_in`` student gets the ``u_layer`` of the 5 loop steps since the last query (by loop step: a query
928
+ every ``n_exec`` steps); a student with history / new inputs logs the robot vector it was fed (``qry_robot``).
929
+ A student with the last-command input (``StudentPolicy.lastcmd``) gets ``Guard.prev`` after the last two steps
930
+ (``cmd``; none since ``reset``: 0), logged as ``qry_lastcmd`` (raw, ``viral.lastcmd_raw``). Offline from a log:
931
+ Guard.prev of step s = ``u_sim[s]`` with ``u_sim[s, :5] - i_corr[s]``; a query at step k > 0 gets (prev[k - 1],
932
+ prev[k - 2]) (k - 2 < 0: prev[k - 1] twice)."""
933
+
934
+ def __init__(self, policy: StudentPolicy, jmap: JointMap, guard: Guard, views: dict, qdot: QdotEstimator,
935
+ bgr: bool, max_frame_age_ms=150.0, thumb_res=112, qd_gain=1.0):
936
+ self.p, self.jm, self.g, self.views, self.qdot = policy, jmap, guard, views, qdot
937
+ # real2sim (2026-10-22): the student's qdot INPUT x qd_gain (1 = off). The student's step size follows the
938
+ # measured speed; the real arm is ~5x slower than the sim arm, so its steps shrink until the arm holds still
939
+ # above the plate (robot-like sim, today's student: 50 % at gain 1, 88 % at 2, 94 % at 3; nominal sim 98 / 90 /
940
+ # 75 %). The guard and the log keep the measured qdot.
941
+ self.qd_gain = float(qd_gain)
942
+ self.bgr, self.max_age, self.thumb_res = bool(bgr), float(max_frame_age_ms), int(thumb_res)
943
+ self.k = 0
944
+ self.ex = None
945
+ self.cmd = [] # Guard.prev after the last two steps (oldest first): the last-command input
946
+ self.u_layer = [] # Guard.u_layer of the last n_exec loop steps (NaN: no command that step)
947
+ self.S = {k: [] for k in ("t", "q_real", "q_sim", "qd_sim", "u_target", "u_layer", "u_sim", "u_real", "i_corr",
948
+ "i_aw", "query", "ev_step", "ev_lead", "ev_range", "ev_floor", "ev_real_range",
949
+ "ev_max_rel", "n_stop", "ms_qdot", "ms_frames", "ms_pre", "ms_model", "ms_guard",
950
+ "ms_ctrl")}
951
+ self.Q = {k: [] for k in ("t", "step", "chunk", "exec", "aux", "plate_xy", "plate_yaw4_deg", "cube_xyz",
952
+ "frame_age_ms", "thumbs", "robot", "lastcmd")} # robot / lastcmd: empty (no
953
+ # key) when not used
954
+ self.events = {}
955
+
956
+ def reset(self, q_real=None):
957
+ self.k = 0
958
+ self.ex = None
959
+ self.cmd = []
960
+ self.u_layer = []
961
+ self.qdot.reset()
962
+ self.p.reset()
963
+ if q_real is not None:
964
+ self.g.reset(self.jm.real_to_sim(q_real))
965
+
966
+ def step(self, t, q_real, get_frames):
967
+ T = {}
968
+ t0 = time.perf_counter()
969
+ q_real = np.asarray(q_real, np.float64)
970
+ q_sim = self.jm.real_to_sim(q_real)
971
+ qd = self.qdot.update(t, q_sim)
972
+ T["ms_qdot"] = (time.perf_counter() - t0) * 1e3
973
+ stop = self.g.check_measured(q_sim, q_real)
974
+ query = self.k % self.p.n_exec == 0
975
+ T["ms_frames"] = T["ms_pre"] = T["ms_model"] = float("nan") # query steps only
976
+ if query:
977
+ t1 = time.perf_counter()
978
+ fr = get_frames()
979
+ T["ms_frames"] = (time.perf_counter() - t1) * 1e3
980
+ t2 = time.perf_counter()
981
+ imgs, ages = {}, []
982
+ for c in self.p.cams:
983
+ rc = self.p.cam_map[c]
984
+ im, age = fr[rc]
985
+ ages.append(float(age))
986
+ if np.isfinite(age) and age > self.max_age:
987
+ stop.append(f"camera age: {rc} frame {age:.0f} ms old")
988
+ imgs[rc] = preprocess(im, self.views[rc], self.bgr)
989
+ T["ms_pre"] = (time.perf_counter() - t2) * 1e3
990
+ qd_in = qd if self.qd_gain == 1.0 else qd * self.qd_gain
991
+ kw = {} # input options (a plain student: the old 3-argument call)
992
+ if getattr(self.p, "cmd_in", False): # the action-layer targets of the last n_exec loop steps
993
+ n = self.p.n_exec
994
+ kw["u_prev"] = np.stack(self.u_layer[-n:]) if len(self.u_layer) >= n else None
995
+ lc_on = bool(getattr(self.p, "lastcmd", False))
996
+ if lc_on: # the commands of the last two steps (none yet: 0)
997
+ lc = (self.cmd[-1], self.cmd[-2] if len(self.cmd) > 1 else self.cmd[-1]) if self.cmd else None
998
+ kw.update(last_cmd=lc, start=lc is None)
999
+ r = self.p.query(imgs, q_sim, qd_in, **kw)
1000
+ if lc_on:
1001
+ self.Q["lastcmd"].append(np.asarray(r["lastcmd"]))
1002
+ T["ms_model"] = r["t_model_ms"]
1003
+ self.ex = r["exec"]
1004
+ Q = self.Q
1005
+ if "robot" in r and (getattr(self.p, "H", 0) or getattr(self.p, "cmd_in", False)
1006
+ or getattr(self.p, "img_hist", False)):
1007
+ Q["robot"].append(np.asarray(r["robot"]))
1008
+ Q["t"].append(t)
1009
+ Q["step"].append(self.k)
1010
+ for kk in ("chunk", "exec", "aux", "plate_xy", "plate_yaw4_deg", "cube_xyz"):
1011
+ Q[kk].append(np.asarray(r[kk]))
1012
+ Q["frame_age_ms"].append(np.asarray(ages))
1013
+ Q["thumbs"].append(np.stack([thumb(imgs[self.p.cam_map[c]], self.thumb_res) for c in self.p.cams]))
1014
+ t3 = time.perf_counter()
1015
+ target = self.ex[self.k % self.p.n_exec]
1016
+ u_sim, u_real, ev, stop2 = self.g.apply(target, q_sim, q_real, qd)
1017
+ if u_sim is not None: # the command without the integral correction (the last-command input)
1018
+ self.cmd = (self.cmd + [self.g.prev.copy()])[-2:]
1019
+ nan6 = np.full(6, np.nan)
1020
+ ul = nan6 if self.g.u_layer is None else self.g.u_layer.copy()
1021
+ self.u_layer = (self.u_layer + [ul])[-self.p.n_exec:]
1022
+ stop += stop2
1023
+ T["ms_guard"] = (time.perf_counter() - t3) * 1e3
1024
+ T["ms_ctrl"] = (time.perf_counter() - t0) * 1e3
1025
+ S = self.S
1026
+ for kk, v in (("t", t), ("q_real", q_real), ("q_sim", q_sim), ("qd_sim", qd), ("u_target", target),
1027
+ ("u_layer", ul), ("u_sim", nan6 if u_sim is None else u_sim),
1028
+ ("u_real", nan6 if u_real is None else u_real),
1029
+ ("i_corr", self.g.integ.copy()), ("i_aw", self.g.i_aw.copy()), ("query", query),
1030
+ ("n_stop", len(stop))):
1031
+ S[kk].append(v)
1032
+ for kk in ("step", "lead", "range", "floor", "real_range", "max_rel"):
1033
+ S["ev_" + kk].append(bool(ev.get(kk, False)))
1034
+ for kk, v in T.items():
1035
+ S[kk].append(v)
1036
+ for s in stop:
1037
+ key = s.split(":")[0] # one entry per kind of reason: first time, count
1038
+ e = self.events.setdefault(key, dict(first_t=float(t), first=s, count=0))
1039
+ e["count"] += 1
1040
+ self.k += 1
1041
+ return StepOut(u_sim, u_real, query, stop, ev, T)
1042
+
1043
+ def arrays(self):
1044
+ out = {}
1045
+ for pre, D in (("", self.S), ("qry_", self.Q)):
1046
+ for k, v in D.items():
1047
+ if len(v):
1048
+ out[pre + k] = np.asarray(np.stack(v) if isinstance(v[0], np.ndarray) else v)
1049
+ return out
1050
+
1051
+
1052
+ # ---- logs and latency ----------------------------------------------------------------------------------------------
1053
+ def latency_summary(cols):
1054
+ """{name: list of ms} -> {name: {n, p50, p95, p99, max}}."""
1055
+ out = {}
1056
+ for k, v in cols.items():
1057
+ a = np.asarray([x for x in v if x is not None and np.isfinite(x)], np.float64)
1058
+ if len(a):
1059
+ out[k] = dict(n=int(len(a)), p50=float(np.percentile(a, 50)), p95=float(np.percentile(a, 95)),
1060
+ p99=float(np.percentile(a, 99)), max=float(a.max()))
1061
+ return out
1062
+
1063
+
1064
+ def save_log(path, arrays, meta):
1065
+ p = Path(path)
1066
+ p.parent.mkdir(parents=True, exist_ok=True)
1067
+ np.savez_compressed(p, **arrays, meta=np.asarray(json.dumps(meta, default=str)))
1068
+ p.with_suffix(".json").write_text(json.dumps(meta, indent=1, default=str))
1069
+
1070
+
1071
+ def precise_wait(deadline):
1072
+ """Sleep until time.perf_counter() >= deadline (sleep, then spin the last 2 ms)."""
1073
+ while True:
1074
+ r = deadline - time.perf_counter()
1075
+ if r <= 0:
1076
+ return
1077
+ if r > 0.003:
1078
+ time.sleep(r - 0.002)
1079
+
1080
+
1081
+ # ---- a fake robot (tests of the dry / live loop without hardware) -------------------------------------------------
1082
+ class FakeRobotIO:
1083
+ """Stand-in for the LeRobot robot in tests: 6 servos that move toward the goal with a first-order lag (``tau`` s)
1084
+ and a speed limit (deg/s), torque flag, a write counter, constant camera images. Same methods as
1085
+ ``run_student_real.LeRobotIO``."""
1086
+
1087
+ def __init__(self, q0_real, writes=True, tau=0.04, vmax=200.0, image=None):
1088
+ self.q = np.asarray(q0_real, np.float64).copy()
1089
+ self.goal = self.q.copy()
1090
+ self.writes, self.tau, self.vmax = bool(writes), float(tau), float(vmax)
1091
+ self.torque = False
1092
+ self.n_writes = 0
1093
+ self.t_last = None
1094
+ self.img = np.full((480, 640, 3), 90, np.uint8) if image is None else image
1095
+ self.bgr = False
1096
+ self.connected = False
1097
+
1098
+ def connect(self):
1099
+ self.connected = True
1100
+
1101
+ def _advance(self):
1102
+ now = time.perf_counter()
1103
+ if self.t_last is not None and self.torque:
1104
+ dt = now - self.t_last
1105
+ d = (self.goal - self.q) * (1 - math.exp(-dt / self.tau))
1106
+ self.q += np.clip(d, -self.vmax * dt, self.vmax * dt)
1107
+ self.t_last = now
1108
+
1109
+ def read_q(self):
1110
+ self._advance()
1111
+ return self.q.copy()
1112
+
1113
+ def frames(self, max_age_ms=500):
1114
+ return {c: (self.img, 5.0) for c in REAL_CAMERAS}
1115
+
1116
+ def write_goal(self, q_real):
1117
+ if not self.writes:
1118
+ raise RuntimeError("fake robot: writes are blocked (dry mode)")
1119
+ self._advance()
1120
+ self.goal = np.asarray(q_real, np.float64).copy()
1121
+ self.n_writes += 1
1122
+
1123
+ def torque_on_at_present(self):
1124
+ if not self.writes:
1125
+ raise RuntimeError("fake robot: writes are blocked (dry mode)")
1126
+ self.goal = self.q.copy()
1127
+ self.torque = True
1128
+
1129
+ def disable_torque(self):
1130
+ if not self.writes:
1131
+ raise RuntimeError("fake robot: writes are blocked (dry mode)")
1132
+ self.torque = False
1133
+
1134
+ def configure(self, mode):
1135
+ return "fake: nothing to configure"
1136
+
1137
+ def close(self, disable_torque=False):
1138
+ if disable_torque:
1139
+ self.disable_torque()
1140
+ self.connected = False
so101_pick_place/code/scripts/so101_policy/real2sim/hw/make_orin_bundle.sh ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Build the folder (and .tar.gz) that run_student_real.py needs on the robot's Jetson AGX Orin: the nedm.so101_policy
3
+ # Python sources, this folder's scripts, the SO101 collision points (table floor without mujoco), the student
4
+ # checkpoint, calib_v1.json and assets/deploy.json (the floor mode of the student, read from its checkpoint, the table
5
+ # plane source, HOME and the eval guard: robot_test.sh passes them to every run). It writes locally only; copying it to
6
+ # the Orin is the user's step (README.md).
7
+ #
8
+ # scripts/so101_policy/real2sim/hw/make_orin_bundle.sh <student.pt> [out_dir] [calib_v1.json]
9
+ # HOME_SIM_DEG=a,b,c,d,e,f ... another HOME (sim deg; default hw_lib.ROBOT_HOME_SIM_DEG = 0,-5,-15,92,0,30)
10
+ # PYTHON=<python with torch> ... the Python that reads the checkpoint (default python3)
11
+ set -euo pipefail
12
+ HW="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13
+ ROOT="$(cd "$HW/../../../.." && pwd)"
14
+ CKPT="${1:?usage: make_orin_bundle.sh <student.pt> [out_dir] [calib_v1.json]}"
15
+ OUT="${2:-$ROOT/artifacts/so101_pick_place_repro/bundle/so101_hw}"
16
+ CALIB="${3:-$ROOT/configs/so101_pick_place/calib_v1.json}"
17
+ POINTS="${SO101_KIN_POINTS:-$ROOT/artifacts/so101_pick_place/rl_inputs/geometry/kin_points_v1.npz}"
18
+ PY="${PYTHON:-python3}"
19
+
20
+ [ -f "$CKPT" ] || { echo "student checkpoint $CKPT missing"; exit 1; }
21
+ [ -f "$POINTS" ] || { echo "kin points $POINTS missing"; exit 1; }
22
+ rm -rf "$OUT"
23
+ mkdir -p "$OUT/src/nedm/so101_policy/vision" "$OUT/src/nedm/render" "$OUT/scripts/so101_policy/real2sim/hw" "$OUT/assets"
24
+ cp "$ROOT/src/nedm/__init__.py" "$OUT/src/nedm/"
25
+ cp "$ROOT/src/nedm/render/student_view.py" "$OUT/src/nedm/render/" # the crop code shared with the renderer
26
+ cp "$ROOT"/src/nedm/so101_policy/*.py "$OUT/src/nedm/so101_policy/"
27
+ cp "$ROOT"/src/nedm/so101_policy/vision/*.py "$OUT/src/nedm/so101_policy/vision/"
28
+ cp "$HW/hw_lib.py" "$HW/run_student_real.py" "$HW/README.md" "$OUT/scripts/so101_policy/real2sim/hw/"
29
+ cp "$HW/robot_test.sh" "$HW/QDGAIN_TEST.md" "$OUT/" # the launcher + the qd-gain test plan (bundle root)
30
+ cp "$POINTS" "$OUT/assets/kin_points_v1.npz"
31
+ cp "$CKPT" "$OUT/assets/student.pt"
32
+ if [ -f "$CALIB" ]; then cp "$CALIB" "$OUT/assets/calib_v1.json"; else echo "NOTE: no $CALIB (live mode will refuse)"; fi
33
+ # the deploy settings, from the bundle's own copies (the bundle's sources: the same rules as on the robot)
34
+ HOME_ARG=(); [ -n "${HOME_SIM_DEG:-}" ] && HOME_ARG=(--home "$HOME_SIM_DEG")
35
+ NEDM_SRC="$OUT/src" PYTHONDONTWRITEBYTECODE=1 CUDA_VISIBLE_DEVICES="" "$PY" \
36
+ "$OUT/scripts/so101_policy/real2sim/hw/run_student_real.py" deploy-json --student "$OUT/assets/student.pt" \
37
+ --calib "$OUT/assets/calib_v1.json" --out "$OUT/assets/deploy.json" "${HOME_ARG[@]}"
38
+ find "$OUT" -name __pycache__ -prune -exec rm -rf {} + # only the built files in the manifest
39
+ FLOOR_MODE="$("$PY" -c 'import json, sys; print(json.load(open(sys.argv[1]))["floor_mode"])' "$OUT/assets/deploy.json")"
40
+ {
41
+ echo "built $(date -Iseconds) from $ROOT (git $(git -C "$ROOT" rev-parse --short HEAD 2>/dev/null || echo ?)"\
42
+ "$(git -C "$ROOT" status --porcelain -- src/nedm/so101_policy scripts/so101_policy/real2sim/hw 2>/dev/null | wc -l)"\
43
+ "changed files under the copied paths)"
44
+ echo "student $CKPT (floor mode $FLOOR_MODE, assets/deploy.json)" # header: 3 lines (robot_test.sh: lines 4-)
45
+ echo "calib $CALIB"
46
+ (cd "$OUT" && find . -type f ! -name MANIFEST.txt -print0 | sort -z | xargs -0 sha256sum)
47
+ } > "$OUT/MANIFEST.txt"
48
+ tar -C "$(dirname "$OUT")" -czf "$OUT.tar.gz" "$(basename "$OUT")"
49
+ du -sh "$OUT" "$OUT.tar.gz"
50
+ echo "bundle: $OUT.tar.gz floor mode $FLOOR_MODE (copy it to the Orin yourself, e.g. scp $OUT.tar.gz sbel@proxy:~/ ;"\
51
+ "README.md)"