gaitkeeper 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. gaitkeeper-0.1.0/LICENSE +202 -0
  2. gaitkeeper-0.1.0/PKG-INFO +449 -0
  3. gaitkeeper-0.1.0/README.md +406 -0
  4. gaitkeeper-0.1.0/pyproject.toml +66 -0
  5. gaitkeeper-0.1.0/setup.cfg +4 -0
  6. gaitkeeper-0.1.0/src/gaitkeeper/__init__.py +3 -0
  7. gaitkeeper-0.1.0/src/gaitkeeper/behavior.py +736 -0
  8. gaitkeeper-0.1.0/src/gaitkeeper/checks.py +558 -0
  9. gaitkeeper-0.1.0/src/gaitkeeper/cli.py +725 -0
  10. gaitkeeper-0.1.0/src/gaitkeeper/compare.py +1102 -0
  11. gaitkeeper-0.1.0/src/gaitkeeper/contract.py +283 -0
  12. gaitkeeper-0.1.0/src/gaitkeeper/counterfactual.py +535 -0
  13. gaitkeeper-0.1.0/src/gaitkeeper/data/fixtures.json +363 -0
  14. gaitkeeper-0.1.0/src/gaitkeeper/data/floors.json +80 -0
  15. gaitkeeper-0.1.0/src/gaitkeeper/data/issue145_tour.yaml +13 -0
  16. gaitkeeper-0.1.0/src/gaitkeeper/deviation.py +180 -0
  17. gaitkeeper-0.1.0/src/gaitkeeper/diagnose.py +234 -0
  18. gaitkeeper-0.1.0/src/gaitkeeper/e4.py +199 -0
  19. gaitkeeper-0.1.0/src/gaitkeeper/env.py +14 -0
  20. gaitkeeper-0.1.0/src/gaitkeeper/envelope.py +357 -0
  21. gaitkeeper-0.1.0/src/gaitkeeper/fixtures.py +180 -0
  22. gaitkeeper-0.1.0/src/gaitkeeper/infer.py +548 -0
  23. gaitkeeper-0.1.0/src/gaitkeeper/inject.py +651 -0
  24. gaitkeeper-0.1.0/src/gaitkeeper/metrics.py +79 -0
  25. gaitkeeper-0.1.0/src/gaitkeeper/models.py +191 -0
  26. gaitkeeper-0.1.0/src/gaitkeeper/policy.py +77 -0
  27. gaitkeeper-0.1.0/src/gaitkeeper/presets.py +158 -0
  28. gaitkeeper-0.1.0/src/gaitkeeper/readers/__init__.py +1 -0
  29. gaitkeeper-0.1.0/src/gaitkeeper/readers/mjlab_export.py +462 -0
  30. gaitkeeper-0.1.0/src/gaitkeeper/readers/numtext.py +75 -0
  31. gaitkeeper-0.1.0/src/gaitkeeper/readers/unitree_deploy.py +343 -0
  32. gaitkeeper-0.1.0/src/gaitkeeper/recorders/__init__.py +4 -0
  33. gaitkeeper-0.1.0/src/gaitkeeper/recorders/mjlab.py +683 -0
  34. gaitkeeper-0.1.0/src/gaitkeeper/recorders/schedule.py +133 -0
  35. gaitkeeper-0.1.0/src/gaitkeeper/residual.py +750 -0
  36. gaitkeeper-0.1.0/src/gaitkeeper/runner.py +846 -0
  37. gaitkeeper-0.1.0/src/gaitkeeper/tables.py +67 -0
  38. gaitkeeper-0.1.0/src/gaitkeeper/task.py +301 -0
  39. gaitkeeper-0.1.0/src/gaitkeeper/terms.py +416 -0
  40. gaitkeeper-0.1.0/src/gaitkeeper/trace.py +187 -0
  41. gaitkeeper-0.1.0/src/gaitkeeper/verdict.py +377 -0
  42. gaitkeeper-0.1.0/src/gaitkeeper.egg-info/PKG-INFO +449 -0
  43. gaitkeeper-0.1.0/src/gaitkeeper.egg-info/SOURCES.txt +68 -0
  44. gaitkeeper-0.1.0/src/gaitkeeper.egg-info/dependency_links.txt +1 -0
  45. gaitkeeper-0.1.0/src/gaitkeeper.egg-info/entry_points.txt +2 -0
  46. gaitkeeper-0.1.0/src/gaitkeeper.egg-info/requires.txt +18 -0
  47. gaitkeeper-0.1.0/src/gaitkeeper.egg-info/top_level.txt +1 -0
  48. gaitkeeper-0.1.0/tests/test_behavior.py +236 -0
  49. gaitkeeper-0.1.0/tests/test_blind.py +110 -0
  50. gaitkeeper-0.1.0/tests/test_checks.py +162 -0
  51. gaitkeeper-0.1.0/tests/test_cli.py +74 -0
  52. gaitkeeper-0.1.0/tests/test_compare.py +110 -0
  53. gaitkeeper-0.1.0/tests/test_counterfactual.py +198 -0
  54. gaitkeeper-0.1.0/tests/test_deviation.py +25 -0
  55. gaitkeeper-0.1.0/tests/test_e4.py +91 -0
  56. gaitkeeper-0.1.0/tests/test_envelope.py +63 -0
  57. gaitkeeper-0.1.0/tests/test_fixtures.py +165 -0
  58. gaitkeeper-0.1.0/tests/test_infer.py +162 -0
  59. gaitkeeper-0.1.0/tests/test_mjlab_export.py +44 -0
  60. gaitkeeper-0.1.0/tests/test_numtext_contract.py +59 -0
  61. gaitkeeper-0.1.0/tests/test_policy_recurrent.py +41 -0
  62. gaitkeeper-0.1.0/tests/test_regression.py +93 -0
  63. gaitkeeper-0.1.0/tests/test_rename_compat.py +52 -0
  64. gaitkeeper-0.1.0/tests/test_residual.py +171 -0
  65. gaitkeeper-0.1.0/tests/test_runner.py +100 -0
  66. gaitkeeper-0.1.0/tests/test_stream.py +79 -0
  67. gaitkeeper-0.1.0/tests/test_terms.py +96 -0
  68. gaitkeeper-0.1.0/tests/test_trace.py +33 -0
  69. gaitkeeper-0.1.0/tests/test_unitree_deploy.py +132 -0
  70. gaitkeeper-0.1.0/tests/test_verdict.py +321 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,449 @@
1
+ Metadata-Version: 2.4
2
+ Name: gaitkeeper
3
+ Version: 0.1.0
4
+ Summary: Find why a humanoid locomotion policy fails between simulators: contract, physics, or task.
5
+ Author-email: Dundy Pasupuleti <dundysm@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/dundysm/gaitkeeper
8
+ Project-URL: Source, https://github.com/dundysm/gaitkeeper
9
+ Project-URL: Issues, https://github.com/dundysm/gaitkeeper/issues
10
+ Project-URL: Changelog, https://github.com/dundysm/gaitkeeper/blob/main/CHANGELOG.md
11
+ Keywords: robotics,humanoid,locomotion,reinforcement-learning,mujoco,isaac-lab,mjlab,sim2sim,sim-to-real
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: Scientific/Engineering :: Physics
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: numpy>=1.24
28
+ Requires-Dist: pyyaml>=6
29
+ Requires-Dist: onnxruntime>=1.16
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=7; extra == "dev"
32
+ Requires-Dist: ruff>=0.4; extra == "dev"
33
+ Requires-Dist: onnx>=1.15; extra == "dev"
34
+ Provides-Extra: sim
35
+ Requires-Dist: mujoco>=3.3; extra == "sim"
36
+ Provides-Extra: record-mjlab
37
+ Requires-Dist: mjlab==1.2.0; extra == "record-mjlab"
38
+ Requires-Dist: mujoco==3.5.0; extra == "record-mjlab"
39
+ Requires-Dist: mujoco-warp==3.5.0; extra == "record-mjlab"
40
+ Requires-Dist: warp-lang==1.12.*; extra == "record-mjlab"
41
+ Requires-Dist: scipy; extra == "record-mjlab"
42
+ Dynamic: license-file
43
+
44
+ <p align="center">
45
+ <img src="https://raw.githubusercontent.com/dundysm/gaitkeeper/main/docs/assets/banner.svg" alt="gaitkeeper: why does a walking policy that works in training fail in a second simulator?" width="900">
46
+ </p>
47
+
48
+ <p align="center">
49
+ <a href="https://github.com/dundysm/gaitkeeper/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/dundysm/gaitkeeper/actions/workflows/ci.yml/badge.svg"></a>
50
+ <img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10%2B-3776ab">
51
+ <img alt="MuJoCo on CPU" src="https://img.shields.io/badge/MuJoCo-CPU-1f6feb">
52
+ <a href="https://github.com/dundysm/gaitkeeper/blob/main/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/badge/license-Apache--2.0-2ea043"></a>
53
+ <a href="https://github.com/dundysm/gaitkeeper/blob/main/STATUS.md"><img alt="Status: early" src="https://img.shields.io/badge/status-early-d29922"></a>
54
+ </p>
55
+
56
+ A humanoid locomotion policy that walks in the simulator it was trained in often
57
+ fails in a second one, or scores nothing in someone else's harness. Three
58
+ different things can be wrong, and they need different fixes:
59
+
60
+ * **the contract**: the harness does not build the observation or apply the
61
+ action the way training did (layout, scale, gains, joint order),
62
+ * **the physics**: the two simulators disagree on the robot (mass, friction,
63
+ armature, how the drive is integrated),
64
+ * **the policy under the task**: it was never able to do what it is being asked.
65
+
66
+ gaitkeeper tells them apart, and says how much evidence backs the answer.
67
+
68
+ <p align="center">
69
+ <img src="https://raw.githubusercontent.com/dundysm/gaitkeeper/main/docs/assets/dead-zone.gif" alt="Two G1 robots in MuJoCo. Left: commanded 0.15 m/s forward, it stands still. Right: commanded 0.50 m/s, it walks at 0.48 m/s." width="808">
70
+ <br>
71
+ <sub>The official unitree_rl_lab G1 policy in unitree_mujoco, rendered from gaitkeeper's runner
72
+ (<code>tools/render_readme_media.py</code>). Below about 0.2 m/s it stands still. A waypoint tour is
73
+ mostly small commands, which is one reason it can score 0% with a harness that follows the contract.</sub>
74
+ </p>
75
+
76
+ ## How it decides
77
+
78
+ <p align="center">
79
+ <img src="https://raw.githubusercontent.com/dundysm/gaitkeeper/main/docs/assets/boundaries.svg" alt="Boundaries A to D, from a golden trace recorded in the training simulator: A signals to observation, B observation to action, C action to effort, D effort to next state." width="900">
80
+ </p>
81
+
82
+ It reads the policy's contract from the exported files, with the source of
83
+ every field (`live`, `file`, `file+table`, `default`, `preset`, `inferred`,
84
+ `user`, `unknown` or `conflicting`). Against a golden trace recorded in the
85
+ training simulator it checks one boundary at a time and stops at the first that
86
+ disagrees:
87
+
88
+ | | Boundary | Question | A mismatch means |
89
+ |---|---|---|---|
90
+ | **B** | observation → action | Does the policy file give the recorded actions on the recorded inputs? | `CONTRACT` (wrong file, normalizer, state) |
91
+ | **A** | signals → observation | Is each observation term rebuilt from raw state the way training built it? | `CONTRACT`, with the term and the pattern (scale, permutation, frame, layout, time shift) |
92
+ | **C** | action → effort | Same scale, offset, clip, delay, gains by name? | `CONTRACT`; effort limits are reported, never a mismatch |
93
+ | **D** | effort → next state | Does the target model's inverse dynamics explain the recorded motion? | evidence for `PHYSICS`, never a cause by itself |
94
+
95
+ `PHYSICS` needs a golden trace this tool did not write, A to C passing, the
96
+ nominal closed loop failing, a residual above a floor calibrated for that
97
+ source engine, **and** a counterfactual: copying one parameter group from the
98
+ source model into the target changes the outcome. Without a golden trace,
99
+ gaitkeeper still runs the policy in a target MJCF and reports what the robot
100
+ does, labeled as a behavioral finding under stated assumptions, not a cause.
101
+
102
+ ## Quick start
103
+
104
+ ```bash
105
+ python -m venv .venv && . .venv/bin/activate
106
+ pip install "gaitkeeper[sim]"
107
+ gaitkeeper demo
108
+ ```
109
+
110
+ `demo` runs the [unitree_rl_lab issue 145](https://github.com/unitreerobotics/unitree_rl_lab/issues/145)
111
+ setup end to end on the CPU: unitree_rl_lab's G1 velocity policy, as shipped, on
112
+ unitree_mujoco's G1 scene, driven through a tour of small commands and in-place
113
+ turns with the arms held, then 600 N punches. On first use it downloads the
114
+ policy and the scene (about 20 MB, pinned commits, sha256 checked) into
115
+ `~/.cache/gaitkeeper`. It takes under a minute and prints the contract it read,
116
+ the command response map with its dead zones, the task segment by segment, and
117
+ the finding:
118
+
119
+ ```text
120
+ DEAD ZONE vx ignored for |cmd| <= 0.20 on the + side (first tracked +0.22); ...
121
+ Task 'issue 145 tour' (3 seeds) on .../scene_29dof.xml: misses the bar on 3/3 seeds
122
+ 2.0 to 6.0 s (+0.15, +0.00, +0.00) achieved (+0.00, -0.00, +0.00) misses the bar on 3/3 seeds: dead zone
123
+ ...
124
+ Finding TASK_FAILURE_OBSERVED / BEHAVIORAL_LIMITATION (evidence L1, exit 5)
125
+ caveat: a silent contract error is not excluded
126
+ caveat: no attribution: neither PHYSICS nor CONTRACT can be concluded without a reference
127
+ ```
128
+
129
+ That is a finding about the policy in this runner, not a verdict on anyone's
130
+ harness. See [Evidence levels](#evidence-levels).
131
+
132
+ ## Evidence levels
133
+
134
+ | Level | Name | Backed by |
135
+ |---|---|---|
136
+ | L0 | parsed | A file or preset. Static checks only. |
137
+ | L1 | behaves | This runner only: behavioral findings under stated controller assumptions. |
138
+ | L2 | conformant | Boundaries A to C match an independently recorded source trace on the covered states and channels. |
139
+ | L3 | matched | L2, and the dynamics residual is at the calibrated floor on the measured channels. |
140
+
141
+ "Verified" appears only at L2 or above. A trace written by gaitkeeper's own
142
+ runner never raises the level.
143
+
144
+ **Exit codes** (`verify`, `task`): `0` PASS (or L1 findings with nothing
145
+ failing) · `1` CONTRACT · `2` INVALID_INPUT · `3` PHYSICS · `4`
146
+ POLICY_UNDER_TASK · `5` UNDETERMINED or an L1 finding such as
147
+ TASK_FAILURE_OBSERVED · `6` UNSUPPORTED. Every command exits 2 with a one line
148
+ message when an input is missing or unreadable (`GAITKEEPER_DEBUG=1` shows the
149
+ traceback), and warns when the MJCF has no floor. `demo` exits 0 when it ran.
150
+
151
+ ## Commands
152
+
153
+ | Command | What it does | Level it can reach |
154
+ |---|---|---|
155
+ | `demo` | The issue 145 setup, end to end | L1 |
156
+ | `fetch` | Pinned policies and MJCF scenes, sha256 checked | |
157
+ | `inspect` | Contract from an mjlab ONNX export or a Unitree `deploy.yaml` (G1 29 dof, H1) | a reading |
158
+ | `verify <trace>` | Boundaries B, A, C | L2 on a golden trace, L1 on a harness log or a self trace |
159
+ | `verify <trace> --mjcf` | Plus D, the nominal closed loop and the model counterfactual | L2 for PHYSICS and POLICY_UNDER_TASK, L3 for PASS |
160
+ | `residual` | D alone, plus parameter fits that stay out of the verdict | detection only |
161
+ | `task` | A command schedule, held joints and punches, with no reference | L1 |
162
+ | `run`, `check`, `envelope` | Closed loop, static and linearized checks, the command response map | L1 |
163
+ | `infer` | Observation layout from a trace, abstaining when ambiguous | |
164
+ | `deviation` | Deploy values against training values, per joint | |
165
+
166
+ <details>
167
+ <summary><b>Usage examples, runner backends and controller assumptions</b></summary>
168
+
169
+ # golden trace in the training env (runs in the mjlab environment)
170
+ python tools/record_mjlab.py --task-path <unitree_rl_mjlab> --onnx <policy.onnx> --out runs/g1_golden
171
+
172
+ # contract from the exported files
173
+ gaitkeeper inspect --onnx <policy.onnx> --yaml <deploy.yaml> --out contract.yaml
174
+
175
+ # verify a golden trace or a harness log against a contract
176
+ gaitkeeper verify runs/g1_golden --onnx <policy.onnx> --yaml <deploy.yaml>
177
+ gaitkeeper verify harness_log.npz --contract contract.yaml --policy <policy.onnx>
178
+
179
+ # with a target: boundary D, the nominal closed loop and the model counterfactual
180
+ gaitkeeper verify runs/g1_golden --contract runs/g1_golden/contract.live.yaml \
181
+ --onnx <policy.onnx> --mjcf <scene.xml> --seeds 12
182
+ gaitkeeper residual runs/g1_golden --contract runs/g1_golden/contract.live.yaml --mjcf <scene.xml>
183
+
184
+ # a task without a reference (L1 at most): schedule, held joints, punches
185
+ gaitkeeper task --deploy <deploy.yaml> --onnx <policy.onnx> --mjcf <scene.xml> \
186
+ --schedule tour.yaml --hold left_elbow_joint,right_elbow_joint \
187
+ --push-every 3 --push-first 20 --push-force 600
188
+
189
+ # Unitree deploy.yaml, read as what the robot runs (SDK tables: G1 29-DoF, H1)
190
+ gaitkeeper inspect --deploy <deploy.yaml> --onnx <policy.onnx>
191
+
192
+ # closed loop in a target MJCF; every result prints the controller assumptions
193
+ gaitkeeper run --deploy <deploy.yaml> --onnx <policy.onnx> --mjcf <scene.xml> \
194
+ --command 0.5,0,0 --kick 3,0.5,0 --push 6,0,150,0,torso_link,0.1
195
+
196
+ # checks S16, S17a, S17b, S18, S19, S21 and the command response map
197
+ gaitkeeper check --deploy <deploy.yaml> --onnx <policy.onnx> --mjcf <scene.xml> --scenario 0,0,0.2
198
+ gaitkeeper envelope --deploy <deploy.yaml> --onnx <policy.onnx> --mjcf <scene.xml>
199
+
200
+ # behavior probes: standstill in the dead zone (two backends), after a kick,
201
+ # yaw while walking, trained kicks and force punches over seeds, fragility sweep
202
+ gaitkeeper envelope --deploy <deploy.yaml> --onnx <policy.onnx> --mjcf <scene.xml> \
203
+ --push-seeds 10 --physics --json envelope.json
204
+
205
+ # observation layout from a trace (exit 0 inferred, 3 partial or abstained)
206
+ gaitkeeper infer runs/g1_golden --json layout.json
207
+ gaitkeeper infer harness_log.npz --no-raw # (obs, action) only
208
+
209
+ # deploy values against training values, per joint
210
+ gaitkeeper deviation --deploy <deploy.yaml> --reference runs/g1_golden/contract.live.yaml --trace runs/g1_golden
211
+
212
+ Runner backends: `native_implicit` (default; PD inside MuJoCo every step),
213
+ `explicit_zoh` (torque held over the training `sim_dt`; the MuJoCo step is
214
+ changed to divide it and the change is printed), `python_pd` (debugging),
215
+ `standin_implicit` (a position-implicit drive in damping and Euler, the way
216
+ some engines integrate PD; used to test that boundary D does not turn a drive
217
+ difference into a cause).
218
+ Torque limits come from the MJCF unless `--limits contract`. A field the
219
+ contract takes from no source prints `CONTROLLER_ASSUMED`. `--preset` fills
220
+ named training facts (for example
221
+ `unitree_rl_lab_g1_29dof_velocity@4960b84`) with provenance `preset`. A
222
+ controller field from a preset still prints `CONTROLLER_ASSUMED`: the preset
223
+ reads the training config at a commit, not the run that produced the policy.
224
+
225
+ </details>
226
+
227
+ ## Install
228
+
229
+ ```bash
230
+ pip install "gaitkeeper[sim]" # runner, check, envelope, task, demo (MuJoCo)
231
+ pip install gaitkeeper # contracts and trace comparison only
232
+
233
+ git clone https://github.com/dundysm/gaitkeeper && cd gaitkeeper
234
+ pip install -e ".[sim,dev]" # from source, with tests and lint
235
+ pip install -e ".[record-mjlab]" # recorder (mjlab 1.2.0, MuJoCo 3.5.0, CPU is enough)
236
+ ```
237
+
238
+ Python 3.10 or newer. Reading contracts and comparing traces needs only the
239
+ base install (numpy, pyyaml, onnxruntime).
240
+
241
+ ### Third-party files
242
+
243
+ Nothing third party is vendored. `gaitkeeper fetch` downloads pinned files from
244
+ their upstream repositories at fixed commits and checks each sha256
245
+ (`src/gaitkeeper/data/fixtures.json`):
246
+
247
+ | Set | Source | What |
248
+ |---|---|---|
249
+ | `g1_rl_lab` | unitree_rl_lab @ 4960b84 | G1 29 dof velocity policy: deploy.yaml, policy.onnx |
250
+ | `g1_rl_mjlab` | unitree_rl_mjlab @ 1425b15 | G1 velocity policy: deploy.yaml, policy.onnx |
251
+ | `g1_unitree_mujoco` | unitree_mujoco @ 1eb6642 | G1 29 dof scene and meshes (BSD-3-Clause) |
252
+ | `g1_menagerie` | mujoco_menagerie @ 0059d43 | Unitree G1 scene and meshes (BSD-3-Clause) |
253
+
254
+ ```bash
255
+ gaitkeeper fetch # list the sets and whether they are present
256
+ gaitkeeper fetch all # download every set
257
+ ```
258
+
259
+ The two policy repositories have no LICENSE file at those commits
260
+ (unitree_rl_lab's README shows an Apache-2.0 badge; unitree_rl_mjlab states
261
+ no license); the files are fetched for local use, not redistributed. The directory is
262
+ `$GAITKEEPER_DATA` when set, else `~/.cache/gaitkeeper`.
263
+
264
+ ## What has been measured
265
+
266
+ The source engine for every attribution so far is mjlab 1.2.0 on mujoco_warp
267
+ 3.5.0. Nothing has been recorded in Isaac Lab or PhysX yet, so no Isaac source
268
+ is calibrated and nothing about issue 145 goes past L1. See
269
+ [STATUS.md](https://github.com/dundysm/gaitkeeper/blob/main/STATUS.md) for what works, what was measured and what is left.
270
+
271
+ <details>
272
+ <summary><b>What the tests and the measurements show</b></summary>
273
+
274
+ `pytest` runs the unit suite on synthetic traces with a stand-in linear
275
+ policy anywhere. Integration tests run on the fixtures (`gaitkeeper fetch all`)
276
+ and on golden traces recorded with the mjlab recorder under `runs/`
277
+ (`$GAITKEEPER_RUNS`); each skips, naming what is missing, when its files are
278
+ absent. They show:
279
+
280
+ * A harness log built correctly from the contract passes B, A and C, where
281
+ contract numbers printed to 3 decimals are admitted only through the
282
+ `export_rounding` tolerance class; with that class removed, C fails.
283
+ * A wrong policy file fails B.
284
+ * For each injected defect (history layout, order and reset fill; both
285
+ quaternion misreads, (w, x, y, z) read as (x, y, z, w) and the reverse; gyro
286
+ in the world frame; joint remap skipped on input or on output; joint
287
+ velocity scale; a term never filled; action scale taken from the rounded
288
+ yaml; one action scale factor on every joint; action offset dropped; one
289
+ and two step action delays, with a repeated or an empty (zero) delay line;
290
+ raw action clipped; kp scaled, kd scaled, both scaled; gains bound by index
291
+ in the wrong joint order; three defects at once; simulator state read one
292
+ step late), the comparator names the boundary, the term and the defect, and
293
+ nothing else, without using falls.
294
+ * Effort limits are reported, never compared. A harness that clips effort
295
+ below the contract's limit passes C with a `LIMIT_DIFFERENCE_ACTIVE`
296
+ finding; the clip level is inferred from the effort plateau only when the
297
+ joint follows the PD law on every other row, so a gain error is not
298
+ explained away as a clip.
299
+ * On segments that cannot tell the contract from a known alternative
300
+ (standing at zero command; one constant walking command), it returns
301
+ UNDETERMINED rather than PASS, including when such an invisible defect is
302
+ present.
303
+ * When two equally simple explanations fit, it names neither.
304
+ * A trace written by gaitkeeper's own runner is labeled SELF_CONSISTENT and capped
305
+ at evidence L1.
306
+ * The reader finds the rounded wrist action scale in the shipped deploy.yaml,
307
+ and the recorded mjlab G1 golden trace passes against the contract read from
308
+ the exported files (integration tests).
309
+
310
+ * The Unitree deploy reader binds gains by SDK index and pose, scale and
311
+ history by policy index, skips H1's empty SDK slot, and reads the mjlab G1
312
+ wrist action scale 0.07 as exact; against the ONNX metadata that is 6.7% low
313
+ and the wrist kd 3.0% high, reported as deviations of the deployment.
314
+ * The streaming observation builder used by the runner gives the same vectors
315
+ as the batch builder the comparator uses. Recurrent state is carried and
316
+ zeroed at reset.
317
+ * S17a's bound of 4 matches a simulated one-joint PD (3.9 decays, 4.1
318
+ diverges). S17b separates a slow tipping mode from negative, complex and
319
+ fast modes. S16 finds 0 mismatched pairs in the shipped unitree_rl_lab G1
320
+ yaml, 9 when the default pose is read in SDK order, and 3 kp and 3 kd when
321
+ the gains are read in policy order.
322
+ * On the unitree_mujoco G1 scene (integration tests, Appendix A bounds): the
323
+ unitree_rl_lab policy walks 4.69 m in 10 s at 0.5 m/s under python_pd;
324
+ ignores vx 0.20 and walks at 0.22, ignores vy 0.25 and walks at 0.28, under
325
+ both python_pd and native_implicit; does not turn in place at wz 0.2; falls
326
+ in 1 to 2 s under zero action; falls under 1 s with armature 0 under
327
+ python_pd and walks under native_implicit. The wrist roll margin is 3.88 at
328
+ 2 ms; native_implicit has only the tipping mode outside the unit circle and
329
+ python_pd with armature 0 has 11, the most negative near -49. The mjlab
330
+ policy walks 4.82 m.
331
+
332
+ * Behavior probes (unit tests on hand-built inputs; integration tests on the
333
+ unitree_mujoco G1 scene with the unitree_rl_lab policy): stillness needs all
334
+ three measures (action std, joint speed, no contact change); the fall time
335
+ comparison is suppressed when S17a warns or a joint sits at its torque
336
+ limit; a fragility row names numerical instability only when S17a or S17b
337
+ fires beyond the nominal model. The dead zone is a true standstill under
338
+ both backends; after a (0.5, 0.5) m/s kick the robot returns to standstill
339
+ at the vx and wz edges but starts walking sideways at the vy edge (+-0.25)
340
+ and does not stop; over 3 seeds it survives the trained kicks and falls to
341
+ 300 to 600 N punches; with armature 0 under python_pd it falls in under 1 s
342
+ (no-policy baseline 0.62 s on the same model and backend), S17a warns, S17b
343
+ fails with a tipping time constant between 0.2 and 0.6 s, and the fall time
344
+ comparison is suppressed; under native_implicit it walks.
345
+ * Boundary D on the three mjlab golden traces against their own recorded
346
+ model: at the calibrated floor (legs 1e-6 to 4e-5 N m clean RMS, arms
347
+ 8e-5 to 5e-4, waist up to 1.8e-3, root 0.51 N and 0.11 N m; float32 source,
348
+ float64 analysis). Legs are judged on swing steps only. An injected ankle
349
+ armature change (+0.01, -0.002) is named on both legs, and the research fit
350
+ recovers it with the right sign and size; armature, damping and effort
351
+ limit changed together on one leg are named as that chain, never as one
352
+ parameter (AT11); with joint friction on both sides an armature search
353
+ recovers a wrist change; the stand-in drive shows armature -h^2 kp and
354
+ damping -h kp exactly (Appendix B).
355
+ * The counterfactual on the mjlab golden trace with the target changed: floor
356
+ friction 0.1 gives `PHYSICS` with contact parameters as the group whose swap
357
+ restores the outcome; torso +15 kg gives mass and inertia, then body masses.
358
+ The source's own model with a dead-zone task gives `POLICY_UNDER_TASK`
359
+ (AT9). Armature 0 and floor friction 2.0 never give `CONTRACT` (AT1). A
360
+ source with the stand-in drive is far above floor on every chain, its
361
+ behavior unchanged, and a dead-zone task failure gives `POLICY_UNDER_TASK`,
362
+ never `PHYSICS` (AT15).
363
+ * Every row of the plan's decision table is a test, with the invariants
364
+ (no `PHYSICS` without a nominal failure, D above a calibrated floor and a
365
+ counterfactual change; no `PHYSICS` or `CONTRACT` without a reference).
366
+ * The issue 145 setup (unitree_rl_lab policy on unitree_mujoco's G1, arms
367
+ held, small commands, in-place turns, 600 N punches) gives
368
+ `TASK_FAILURE_OBSERVED / BEHAVIORAL_LIMITATION` at L1, exit 5, with the
369
+ caveats that a silent contract error is not excluded and nothing is
370
+ attributed.
371
+ * `infer` recovers history length, layout, order and init on all four layouts
372
+ from `(obs, action)` alone; labels every term with its scale and joint order
373
+ from raw state (including a world-frame gyro); abstains with no boundaries
374
+ when a column is constant or copies more than one column (a constant
375
+ command, AT4), and claims no history length when noise removes the exact
376
+ copies. On a 30 s closed-loop rl_lab trace with a command schedule it
377
+ returns history 5, term major, oldest first, repeat-first init, gyro scale
378
+ 0.2, joint velocity scale 0.05 and the Isaac joint order.
379
+
380
+ Measured outside the test suite (scripts and outputs under `runs/`, not
381
+ committed):
382
+
383
+ * The 29 development harness logs (G1, unitree_rl_lab policy, unitree_mujoco
384
+ scene, regenerated with `qpos` and `qvel`): `verify` names 29 of 29 as
385
+ labeled (16 observation, 12 gain or action, 1 clean that returns
386
+ UNDETERMINED because its command never changes). E0's baseline named 11 of
387
+ 16 and 0 of 12. This is a development set: the comparator was fixed on it
388
+ (effort clip levels, kp and kd named apart, empty delay lines, the second
389
+ quaternion misread, zero scale as an unfilled term), so it is not evidence
390
+ of accuracy on unseen harnesses. On the falling logs the harness clips at
391
+ the MJCF limits (hip roll 88, waist roll and pitch 50) where training uses
392
+ 139 and 25, reported as `LIMIT_DIFFERENCE_ACTIVE`.
393
+ * `infer` abstains on all 29 development logs (constant command), returns the
394
+ full layout on the three recorded mjlab golden traces (no history, the phase
395
+ pair labeled from observations, SDK joint order), keeps the structure but
396
+ loses most labels under per-frame noise stored in history, and abstains
397
+ under independent per-entry noise.
398
+ * Envelope, unitree_rl_lab G1 policy on unitree_mujoco (`runs/step3`): dead
399
+ zone vx 0.20 (+) and 0.15 (-), vy 0.25, no in-place turning; yaw while
400
+ walking tracks 67% to 73% inside the limit range; the vy kick hysteresis
401
+ above; trained kicks survived on 10 of 10 seeds, punches on 0 of 10. The
402
+ lateral and in-place yaw scenarios are NONE: no tracked command sits 1.25
403
+ times past the dead zone edge inside the limit range (vy edge 0.25, limit
404
+ 0.30). Fragility: friction 2.0 (stand drift, fwd + yaw), softer contacts
405
+ (stand drift) and kp x0.8 (fwd + yaw) miss the bar; armature 0 and a 5 ms
406
+ step under python_pd are numerical (S17a and S17b fire); S17b passes at 5 ms
407
+ under native_implicit. The mjlab G1 policy has only its by-design 0.05 dead
408
+ zone, tracks yaw while walking at 74% to 99% and survives 2 of 10 punch
409
+ runs; its rerun under the new rules is unchanged.
410
+ * S17b at a 5 ms step (unitree_rl_lab policy, unitree_mujoco G1): the complex
411
+ pair at modulus 1.0001 is a real slow mode of the linearized standing
412
+ system, not numerical. It is the same for finite difference steps 1e-4 to
413
+ 1e-9, centered or forward; it is present at 2 ms with the same rate per
414
+ second (0.025/s against 0.023/s, turning 0.025 rad/s), where the per-step
415
+ tolerance hides it; it lives in base y, yaw and ankle roll, next to the
416
+ exact translation and yaw symmetries, and comes and goes with the settle
417
+ time. With the policy in the loop a yaw offset stays at 0.0100 rad for 45 s
418
+ (the mode would predict 0.028). S17b now reports such a pair as drift, as it
419
+ already did slow real modes; the per-step tolerance is unchanged.
420
+ * `results.json` (`tools/results.py`): 62 cases with a known cause (the
421
+ injection corpus, the 29 development logs, the physics and task cases
422
+ above), 55 confident outputs, 0 false confident attributions, abstention
423
+ 6.5%; A detected 27 of 27, C 25 of 25, D 3 of 3. The development logs were
424
+ used to fix the comparator, so this is not a measure on unseen harnesses.
425
+
426
+ They do not show that any of this holds for other frameworks, other robots,
427
+ real harness logs, or the robot itself. Runner results are labeled with the
428
+ controller assumptions they rest on and are evidence L1 at most.
429
+
430
+ </details>
431
+
432
+ ## Help test it
433
+
434
+ Every number above comes from cases built alongside the comparator. If you have a harness
435
+ of your own, a few of its logs, with labels you seal before sending, are the most useful
436
+ contribution: [docs/BLIND_TEST.md](https://github.com/dundysm/gaitkeeper/blob/main/docs/BLIND_TEST.md) describes the format and the
437
+ protocol, and `tools/blind.py` scores only against the committed hashes. Start with a
438
+ [blind test issue](https://github.com/dundysm/gaitkeeper/issues/new?template=blind-test.md).
439
+ Results are published whatever they are.
440
+
441
+ ## Formerly sim2sim
442
+
443
+ The project was called sim2sim. Contracts and traces written under the old
444
+ schema ids, `SIM2SIM_*` environment variables and a cache in
445
+ `~/.cache/sim2sim` are still read.
446
+
447
+ ## License
448
+
449
+ Apache-2.0