lockwire 0.2.8__tar.gz → 0.5.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 (139) hide show
  1. {lockwire-0.2.8 → lockwire-0.5.0}/PKG-INFO +34 -18
  2. {lockwire-0.2.8 → lockwire-0.5.0}/README.md +33 -17
  3. {lockwire-0.2.8 → lockwire-0.5.0}/pyproject.toml +1 -1
  4. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/__init__.py +9 -5
  5. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/api.py +254 -9
  6. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/api_payload.py +465 -24
  7. lockwire-0.5.0/src/lockwire/battery.py +194 -0
  8. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/blame.py +1 -1
  9. lockwire-0.5.0/src/lockwire/catalog.py +704 -0
  10. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/catalog_robots.yaml +52 -0
  11. lockwire-0.5.0/src/lockwire/catalog_seed.yaml +6568 -0
  12. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/checks.py +2190 -46
  13. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/cli.py +956 -134
  14. lockwire-0.5.0/src/lockwire/controls.py +393 -0
  15. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/copy.py +3 -1
  16. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/describe.py +27 -2
  17. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/drift.py +1 -1
  18. lockwire-0.5.0/src/lockwire/edit.py +3911 -0
  19. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/emit_ts.py +2 -2
  20. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/arm/contract.yaml +4 -0
  21. lockwire-0.5.0/src/lockwire/examples/arm-power/README.md +21 -0
  22. lockwire-0.5.0/src/lockwire/examples/arm-power/contract.yaml +336 -0
  23. lockwire-0.5.0/src/lockwire/examples/arm-power/plan.yaml +22 -0
  24. lockwire-0.5.0/src/lockwire/examples/arm-power/starter.json +7 -0
  25. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/drone/contract.yaml +23 -0
  26. lockwire-0.5.0/src/lockwire/examples/hexapod-param/contract.yaml +1373 -0
  27. lockwire-0.5.0/src/lockwire/examples/hexapod-param/starter.json +7 -0
  28. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/rover/contract.yaml +15 -0
  29. lockwire-0.5.0/src/lockwire/examples/rover-param/contract.yaml +257 -0
  30. lockwire-0.5.0/src/lockwire/examples/rover-param/starter.json +7 -0
  31. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/servo-bench.yaml +19 -0
  32. lockwire-0.5.0/src/lockwire/export_model.py +528 -0
  33. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/factdiff.py +10 -4
  34. lockwire-0.5.0/src/lockwire/findings_export.py +52 -0
  35. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/forces.py +133 -3
  36. lockwire-0.5.0/src/lockwire/harness.py +175 -0
  37. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/hook_check.py +2 -2
  38. lockwire-0.5.0/src/lockwire/kicad.py +125 -0
  39. lockwire-0.5.0/src/lockwire/material_compare.py +59 -0
  40. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/mcp_server.py +466 -1
  41. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/mesh_simple.py +12 -15
  42. lockwire-0.5.0/src/lockwire/meshread.py +84 -0
  43. lockwire-0.5.0/src/lockwire/mjcf.py +312 -0
  44. lockwire-0.5.0/src/lockwire/motor_card.py +111 -0
  45. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/page.py +768 -30
  46. lockwire-0.5.0/src/lockwire/parts_list.py +354 -0
  47. lockwire-0.5.0/src/lockwire/pinouts/arduino-nano.yaml +331 -0
  48. lockwire-0.5.0/src/lockwire/pinouts/arduino-uno-r3.yaml +371 -0
  49. lockwire-0.5.0/src/lockwire/pinouts/basicmicro-roboclaw-2x15a.yaml +95 -0
  50. lockwire-0.5.0/src/lockwire/pinouts/esp32-devkitc-wroom-32.yaml +420 -0
  51. lockwire-0.5.0/src/lockwire/pinouts/holybro-pixhawk-6c.yaml +734 -0
  52. lockwire-0.5.0/src/lockwire/pinouts/nvidia-jetson-orin-nano-devkit.yaml +354 -0
  53. lockwire-0.5.0/src/lockwire/pinouts/pololu-tb6612fng-carrier.yaml +111 -0
  54. lockwire-0.5.0/src/lockwire/pinouts/raspberry-pi-4b.yaml +48 -0
  55. lockwire-0.5.0/src/lockwire/pinouts/raspberry-pi-5.yaml +12 -0
  56. lockwire-0.5.0/src/lockwire/pinouts/robotis-opencr-1-0.yaml +177 -0
  57. lockwire-0.5.0/src/lockwire/pinouts/robotis-u2d2-power-hub.yaml +53 -0
  58. lockwire-0.5.0/src/lockwire/pinouts/robotis-u2d2.yaml +50 -0
  59. lockwire-0.5.0/src/lockwire/pinouts/waveshare-bus-servo-adapter-a.yaml +21 -0
  60. lockwire-0.5.0/src/lockwire/pins.py +342 -0
  61. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/plan.py +111 -2
  62. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/plan_payload.py +20 -0
  63. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/plugins.py +6 -1
  64. lockwire-0.5.0/src/lockwire/power_budget.py +85 -0
  65. lockwire-0.5.0/src/lockwire/presets.py +52 -0
  66. lockwire-0.5.0/src/lockwire/relevance.py +231 -0
  67. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/report.py +73 -9
  68. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/report_html.py +265 -9
  69. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/scene_import.py +1 -1
  70. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/scene_urdf.py +89 -21
  71. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/scene_view.py +170 -45
  72. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/schema.py +948 -27
  73. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/sdf.py +40 -1
  74. lockwire-0.5.0/src/lockwire/sensitivity.py +101 -0
  75. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/serve.py +352 -19
  76. lockwire-0.5.0/src/lockwire/slicer.py +115 -0
  77. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/start_operation.py +34 -11
  78. lockwire-0.5.0/src/lockwire/statics.py +730 -0
  79. lockwire-0.5.0/src/lockwire/stress.py +262 -0
  80. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/units.py +4 -0
  81. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/urdf.py +105 -11
  82. lockwire-0.5.0/src/lockwire/variants.py +49 -0
  83. lockwire-0.5.0/src/lockwire/webots.py +265 -0
  84. lockwire-0.2.8/src/lockwire/catalog.py +0 -288
  85. lockwire-0.2.8/src/lockwire/catalog_seed.yaml +0 -998
  86. lockwire-0.2.8/src/lockwire/edit.py +0 -2070
  87. lockwire-0.2.8/src/lockwire/mjcf.py +0 -153
  88. lockwire-0.2.8/src/lockwire/parts_list.py +0 -174
  89. lockwire-0.2.8/src/lockwire/statics.py +0 -293
  90. {lockwire-0.2.8 → lockwire-0.5.0}/LICENSE +0 -0
  91. {lockwire-0.2.8 → lockwire-0.5.0}/NOTICE +0 -0
  92. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/__main__.py +0 -0
  93. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/_filelock.py +0 -0
  94. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/advice.py +0 -0
  95. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/agent_setup.py +0 -0
  96. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/bench.py +0 -0
  97. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/check_sim.py +0 -0
  98. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/cli_line.py +0 -0
  99. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/confine.py +0 -0
  100. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/constraints.py +0 -0
  101. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/arm/LICENSE +0 -0
  102. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/arm/NOTICE +0 -0
  103. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/arm/plan.yaml +0 -0
  104. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/arm/scene.glb +0 -0
  105. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/arm/starter.json +0 -0
  106. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/drone/plan.yaml +0 -0
  107. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/drone/scene.glb +0 -0
  108. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/drone/starter.json +0 -0
  109. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/humanoid/NOTICE +0 -0
  110. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/humanoid/contract.yaml +0 -0
  111. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/humanoid/plan.yaml +0 -0
  112. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/humanoid/scene.glb +0 -0
  113. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/humanoid/starter.json +0 -0
  114. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/quadruped/NOTICE +0 -0
  115. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/quadruped/contract.yaml +0 -0
  116. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/quadruped/plan.yaml +0 -0
  117. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/quadruped/scene.glb +0 -0
  118. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/quadruped/starter.json +0 -0
  119. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/rover/NOTICE +0 -0
  120. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/rover/plan.yaml +0 -0
  121. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/rover/scene.glb +0 -0
  122. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/examples/rover/starter.json +0 -0
  123. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/export_mhs.py +0 -0
  124. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/fieldpath.py +0 -0
  125. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/gitref.py +0 -0
  126. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/hw.py +0 -0
  127. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/mechanism.py +0 -0
  128. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/mesh_dae.py +0 -0
  129. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/report_json.py +0 -0
  130. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/review_draft.py +0 -0
  131. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/scan.py +0 -0
  132. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/scene.py +0 -0
  133. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/servo_bus.py +0 -0
  134. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/servo_bus_dxl.py +0 -0
  135. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/swap.py +0 -0
  136. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/thrust.py +0 -0
  137. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/thrust_tables.yaml +0 -0
  138. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/vcs.py +0 -0
  139. {lockwire-0.2.8 → lockwire-0.5.0}/src/lockwire/whatif.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lockwire
3
- Version: 0.2.8
3
+ Version: 0.5.0
4
4
  Summary: The physical-assumption contract for robots: checks that a robot's declared parts (power, weight, bus, torque) add up
5
5
  Keywords: robotics,urdf,ros,preflight,lockfile,ci,hardware,drone
6
6
  Author: Shivansh
@@ -47,31 +47,45 @@ Description-Content-Type: text/markdown
47
47
 
48
48
  **From idea to robot: catch the error in your robot model before the real robot does.**
49
49
 
50
- ## Try it on your robot
50
+ ## Check your robot
51
51
 
52
- Needs Python 3.12 or newer and [uv](https://docs.astral.sh/uv/). Point it at your URDF, xacro or SDF (nothing is written):
52
+ Needs Python 3.12 or newer and [uv](https://docs.astral.sh/uv/). Point it at your own URDF, xacro or
53
+ SDF (nothing is written):
53
54
 
54
55
  ```bash
55
56
  uvx lockwire check robot.urdf
56
57
  ```
57
58
 
58
- What you see, on the public TurtleBot3 Waffle Pi URDF:
59
+ No robot file yet? This writes a small example arm, with its power and wiring, into the current folder
60
+ and checks it:
61
+
62
+ ```bash
63
+ uvx lockwire start --example arm-power
64
+ uvx lockwire check
65
+ ```
59
66
 
60
67
  ```console
61
- $ uvx lockwire check turtlebot3_waffle_pi.urdf
62
- VIOLATION datasheet/turtlebot3-waffle-pi/mass_total — observed URDF sum of link masses: 1.554, expected ROBOTIS TurtleBot3 Waffle Pi
63
- datasheet: 1.8 kg; the sheet's figure includes the battery, computer and sensors
64
- (Δ -13.7%)
65
- source: https://emanual.robotis.com/docs/en/platform/turtlebot3/features/
68
+ VIOLATION topology/rails/rail.5v/brownout — observed rail.5v sags to 4.65 V with every servo stalled (2.73 A), expected >=
69
+ 4.75 V, the declared minimum input of dev.jetson
70
+ action: shorten or thicken the wire, cut the pack resistance, or move the
71
+ servos to their own rail
72
+ VIOLATION topology/wires/w.pack/fuse — observed 9.00 A fuse on 22 AWG wire w.pack, expected fuse <= 7.00 A wire
73
+ ampacity
66
74
  ...
67
- NO-GO — 1 violation(s), 3 warning(s)
68
- ...
69
- Lock it so CI catches drift: uvx lockwire start turtlebot3_waffle_pi.urdf
75
+ action: fit a fuse at or below 7.00 A or upsize wire 'w.pack'
76
+ ...
77
+ NO-GO — 2 violation(s), 2 warning(s)
70
78
  ```
71
79
 
72
- The model's links add up to 13.7% less than the maker's own published weight. Lockwire found
73
- that without being told, named the page it came from, and printed the next command. Errors like
74
- this are in public robot models today: [the fixes sent upstream](docs/ledger.md).
80
+ Command line: macOS, Linux and Windows. Desktop app: macOS (Apple silicon) and Linux. Windows app coming soon.
81
+
82
+ `check` exits 1 on a NO-GO. Two real errors in a robot you have not built yet: with both servos stalled
83
+ the 5 V rail sags below the Jetson's minimum input and resets it, and a 9 A fuse sits on wire that
84
+ carries 7 A. Each line names the part and the page its limit came from, and says what to change
85
+ (`lockwire check --all` also shows the two warnings: a servo data wire on a boot pin, and a 28 AWG
86
+ servo feed drawing about 5 A). Lockwire found these without being told. Errors like this are in public
87
+ robot models today, and maintainers at Seeed and DFKI (MiR100) have merged the fixes:
88
+ [the fixes sent upstream](docs/ledger.md).
75
89
 
76
90
  ## Lock it
77
91
 
@@ -132,8 +146,8 @@ VIOLATION budgets/bud.power.servo-5v — observed 32.10 W, expected <= 15.00 W (
132
146
  NO-GO — 2 violation(s), 0 warning(s)
133
147
  ```
134
148
 
135
- The five robots (`--example drone`, `rover`, `arm`, `quadruped`, `humanoid`) are clean
136
- starting points; try your own robot for the catch.
149
+ The examples that pass the check (`--example drone`, `rover`, `arm`, `quadruped`, `humanoid`) are good
150
+ starting points; `arm-power` and `servo-bench` show a catch, and so will your own robot.
137
151
 
138
152
  ### Features
139
153
 
@@ -154,10 +168,12 @@ The free desktop app does the same visually: [latest release](https://github.com
154
168
 
155
169
  - **macOS (Apple silicon):** unzip, open Lockwire. The app is not notarized, so the first open warns: open System Settings, Privacy & Security, and click "Open Anyway".
156
170
  - **Linux:** `chmod +x Lockwire-*.AppImage`, then run it. Ubuntu 22.04 needs `sudo apt install libfuse2`; 24.04 needs `libfuse2t64`.
157
- - **Windows:** not yet.
171
+ - **Windows:** coming soon.
158
172
 
159
173
  Want it installed instead of run through uvx? `pip install lockwire`, then drop the `uvx`.
160
174
 
161
175
  ## Development and licence
162
176
 
163
177
  See [CONTRIBUTING.md](CONTRIBUTING.md). Apache-2.0, all of it: see [LICENSE](LICENSE).
178
+
179
+ <!-- mcp-name: io.github.lockwirerobotics/lockwire -->
@@ -7,31 +7,45 @@
7
7
 
8
8
  **From idea to robot: catch the error in your robot model before the real robot does.**
9
9
 
10
- ## Try it on your robot
10
+ ## Check your robot
11
11
 
12
- Needs Python 3.12 or newer and [uv](https://docs.astral.sh/uv/). Point it at your URDF, xacro or SDF (nothing is written):
12
+ Needs Python 3.12 or newer and [uv](https://docs.astral.sh/uv/). Point it at your own URDF, xacro or
13
+ SDF (nothing is written):
13
14
 
14
15
  ```bash
15
16
  uvx lockwire check robot.urdf
16
17
  ```
17
18
 
18
- What you see, on the public TurtleBot3 Waffle Pi URDF:
19
+ No robot file yet? This writes a small example arm, with its power and wiring, into the current folder
20
+ and checks it:
21
+
22
+ ```bash
23
+ uvx lockwire start --example arm-power
24
+ uvx lockwire check
25
+ ```
19
26
 
20
27
  ```console
21
- $ uvx lockwire check turtlebot3_waffle_pi.urdf
22
- VIOLATION datasheet/turtlebot3-waffle-pi/mass_total — observed URDF sum of link masses: 1.554, expected ROBOTIS TurtleBot3 Waffle Pi
23
- datasheet: 1.8 kg; the sheet's figure includes the battery, computer and sensors
24
- (Δ -13.7%)
25
- source: https://emanual.robotis.com/docs/en/platform/turtlebot3/features/
28
+ VIOLATION topology/rails/rail.5v/brownout — observed rail.5v sags to 4.65 V with every servo stalled (2.73 A), expected >=
29
+ 4.75 V, the declared minimum input of dev.jetson
30
+ action: shorten or thicken the wire, cut the pack resistance, or move the
31
+ servos to their own rail
32
+ VIOLATION topology/wires/w.pack/fuse — observed 9.00 A fuse on 22 AWG wire w.pack, expected fuse <= 7.00 A wire
33
+ ampacity
26
34
  ...
27
- NO-GO — 1 violation(s), 3 warning(s)
28
- ...
29
- Lock it so CI catches drift: uvx lockwire start turtlebot3_waffle_pi.urdf
35
+ action: fit a fuse at or below 7.00 A or upsize wire 'w.pack'
36
+ ...
37
+ NO-GO — 2 violation(s), 2 warning(s)
30
38
  ```
31
39
 
32
- The model's links add up to 13.7% less than the maker's own published weight. Lockwire found
33
- that without being told, named the page it came from, and printed the next command. Errors like
34
- this are in public robot models today: [the fixes sent upstream](docs/ledger.md).
40
+ Command line: macOS, Linux and Windows. Desktop app: macOS (Apple silicon) and Linux. Windows app coming soon.
41
+
42
+ `check` exits 1 on a NO-GO. Two real errors in a robot you have not built yet: with both servos stalled
43
+ the 5 V rail sags below the Jetson's minimum input and resets it, and a 9 A fuse sits on wire that
44
+ carries 7 A. Each line names the part and the page its limit came from, and says what to change
45
+ (`lockwire check --all` also shows the two warnings: a servo data wire on a boot pin, and a 28 AWG
46
+ servo feed drawing about 5 A). Lockwire found these without being told. Errors like this are in public
47
+ robot models today, and maintainers at Seeed and DFKI (MiR100) have merged the fixes:
48
+ [the fixes sent upstream](docs/ledger.md).
35
49
 
36
50
  ## Lock it
37
51
 
@@ -92,8 +106,8 @@ VIOLATION budgets/bud.power.servo-5v — observed 32.10 W, expected <= 15.00 W (
92
106
  NO-GO — 2 violation(s), 0 warning(s)
93
107
  ```
94
108
 
95
- The five robots (`--example drone`, `rover`, `arm`, `quadruped`, `humanoid`) are clean
96
- starting points; try your own robot for the catch.
109
+ The examples that pass the check (`--example drone`, `rover`, `arm`, `quadruped`, `humanoid`) are good
110
+ starting points; `arm-power` and `servo-bench` show a catch, and so will your own robot.
97
111
 
98
112
  ### Features
99
113
 
@@ -114,10 +128,12 @@ The free desktop app does the same visually: [latest release](https://github.com
114
128
 
115
129
  - **macOS (Apple silicon):** unzip, open Lockwire. The app is not notarized, so the first open warns: open System Settings, Privacy & Security, and click "Open Anyway".
116
130
  - **Linux:** `chmod +x Lockwire-*.AppImage`, then run it. Ubuntu 22.04 needs `sudo apt install libfuse2`; 24.04 needs `libfuse2t64`.
117
- - **Windows:** not yet.
131
+ - **Windows:** coming soon.
118
132
 
119
133
  Want it installed instead of run through uvx? `pip install lockwire`, then drop the `uvx`.
120
134
 
121
135
  ## Development and licence
122
136
 
123
137
  See [CONTRIBUTING.md](CONTRIBUTING.md). Apache-2.0, all of it: see [LICENSE](LICENSE).
138
+
139
+ <!-- mcp-name: io.github.lockwirerobotics/lockwire -->
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "lockwire"
3
- version = "0.2.8"
3
+ version = "0.5.0"
4
4
  description = "The physical-assumption contract for robots: checks that a robot's declared parts (power, weight, bus, torque) add up"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -1,6 +1,6 @@
1
1
  """Lockwire — the physical-assumption contract for robots, enforced in CI and at preflight."""
2
2
 
3
- __version__ = "0.2.8"
3
+ __version__ = "0.5.0"
4
4
 
5
5
 
6
6
  def main() -> None:
@@ -19,13 +19,15 @@ def main() -> None:
19
19
  from rich.console import Console
20
20
  from rich.markup import escape
21
21
 
22
- Console(stderr=True).print(f"[red]private parts file broken:[/] {escape(str(error))}")
22
+ Console(stderr=True, emoji=False).print(
23
+ f"[red]private parts file broken:[/] {escape(str(error))}"
24
+ )
23
25
  sys.exit(2)
24
26
  except ContractError as error: # the user's lockfile, not a bug: plain lines, no traceback
25
27
  from rich.console import Console
26
28
  from rich.markup import escape
27
29
 
28
- Console(stderr=True).print(escape(str(error)), soft_wrap=True, highlight=False)
30
+ Console(stderr=True, emoji=False).print(escape(str(error)), soft_wrap=True, highlight=False)
29
31
  sys.exit(2)
30
32
  except OSError as error: # a file-system problem, not a lockwire bug: one plain line
31
33
  from rich.console import Console
@@ -33,13 +35,15 @@ def main() -> None:
33
35
 
34
36
  from lockwire.cli import plain_os_error
35
37
 
36
- Console(stderr=True).print(escape(plain_os_error(error)), soft_wrap=True, highlight=False)
38
+ Console(stderr=True, emoji=False).print(
39
+ escape(plain_os_error(error)), soft_wrap=True, highlight=False
40
+ )
37
41
  sys.exit(2)
38
42
  except Exception as error: # a crash is a bug, never a verdict: REFUSED (2), not NO-GO (1)
39
43
  from rich.console import Console
40
44
  from rich.markup import escape
41
45
 
42
- Console(stderr=True).print(
46
+ Console(stderr=True, emoji=False).print(
43
47
  f"[red]lockwire stopped: {type(error).__name__}: {escape(str(error))} "
44
48
  "— this is a bug in lockwire, not a verdict[/]"
45
49
  )
@@ -39,7 +39,8 @@ from typing import Any
39
39
  from ruamel.yaml import YAMLError
40
40
 
41
41
  from lockwire import blame as blame_history
42
- from lockwire import gitref
42
+ from lockwire import gitref, units
43
+ from lockwire.catalog import load_catalog
43
44
  from lockwire.checks import check_urdf_drift, run_record_checks
44
45
  from lockwire.describe import describe_all
45
46
  from lockwire.edit import (
@@ -143,7 +144,7 @@ def api_schema(out: Path | str) -> None:
143
144
 
144
145
 
145
146
  def api_types(out: Path | str) -> None:
146
- """Write the payload union's TypeScript types — ``emit_ts.write`` (e1-d3).
147
+ """Write the payload union's TypeScript types — ``emit_ts.write``.
147
148
 
148
149
  ``emit_ts`` is imported here rather than at module scope for the same
149
150
  reason ``api_schema`` imports ``api_payload`` locally:
@@ -156,12 +157,12 @@ def api_types(out: Path | str) -> None:
156
157
 
157
158
 
158
159
  def declare_form(contract: Path | str | Contract) -> dict[str, Any]:
159
- """The Declare form's payload (E4-df): every quantity ``declare`` could
160
+ """The Declare form's payload: every quantity ``declare`` could
160
161
  write in `contract` — present or not — plus a pre-filled witness box.
161
162
  ``page.build_declare_form`` — read-only, nothing here writes.
162
163
 
163
164
  Not in ``FUNCTIONS``: there is no ``lockwire declare-form`` command, only
164
- the three face boxes (e4-b/c/d) reading this document (same "not a
165
+ the three face boxes reading this document (same "not a
165
166
  seventh operation" reasoning as ``health_document`` above).
166
167
  """
167
168
  loaded = contract if isinstance(contract, Contract) else load(contract)
@@ -198,7 +199,7 @@ def page(
198
199
  cli_line: str | None = None,
199
200
  ) -> dict[str, Any]:
200
201
  """The page dict ``page.build_payload`` computes, wrapped unchanged —
201
- the root gap e1-pg closes: ``PagePayload`` (``api_payload.py``) was
202
+ the root gap this closes: ``PagePayload`` (``api_payload.py``) was
202
203
  defined with nothing behind it. This does not recompute anything
203
204
  ``build_payload`` does not already compute; it only loads the contract the
204
205
  way every other door in this file does.
@@ -242,6 +243,27 @@ def page(
242
243
  return document
243
244
 
244
245
 
246
+ def contract_at(contract: Path | str, ref: str) -> dict[str, Any]:
247
+ """The lockfile text and its page as of git ``ref``; read-only (``git show``,
248
+ parsed from memory, nothing written under the repo)."""
249
+ if ref.startswith("-"):
250
+ raise ValueError("a ref cannot start with '-'")
251
+ contract_path = Path(contract)
252
+ repo = gitref.repo_root(contract_path if contract_path.exists() else Path.cwd())
253
+ if repo is None:
254
+ raise ValueError("not a git repository, nothing to read an older revision from")
255
+ sha = gitref.rev_parse(ref, repo=repo)
256
+ if sha is None:
257
+ raise ValueError(f"no such ref {ref!r}")
258
+ relpath = gitref.relpath_in_repo(contract_path, repo)
259
+ if relpath is None:
260
+ raise ValueError(f"{contract_path} is outside the repository at {repo}")
261
+ text = gitref.show(sha, relpath, repo=repo)
262
+ if text is None:
263
+ raise FileNotFoundError(f"{contract_path.name} did not exist at {ref}")
264
+ return {"ref": ref, "commit": sha, "lockfile": text, "page": page(load_contract_text(text))}
265
+
266
+
245
267
  #: The free library operations. Every name here has a CLI command of the same
246
268
  #: name. ``api_pro.FUNCTIONS`` is the complete inventory with the paid ones.
247
269
  FUNCTIONS = (
@@ -297,6 +319,157 @@ __all__ = [
297
319
  ]
298
320
 
299
321
 
322
+ BOM_COLUMNS = (
323
+ "item", "quantity", "part", "maker", "kind",
324
+ "unit_mass_kg", "total_mass_kg", "voltage", "source", "datasheet", "notes",
325
+ ) # fmt: skip
326
+
327
+
328
+ def _g(x: float) -> str:
329
+ return f"{x:.6g}"
330
+
331
+
332
+ def _same_mass_devices(contract: Contract) -> list[str]:
333
+ """Device ids that declare exactly the battery's mass (a coincidence until a link proves it)."""
334
+ bat = contract.topology.battery if contract.topology else None
335
+ m = bat.mass.base() if bat and bat.mass else None
336
+ return [
337
+ d.id
338
+ for d in contract.devices
339
+ if m is not None and d.physical and d.physical.mass and d.physical.mass.base() == m
340
+ ]
341
+
342
+
343
+ def _pack_device(contract: Contract) -> str | None:
344
+ """The device that is the battery pack, proven only by a declared link.
345
+
346
+ The link: a rail the battery feeds directly (upstream "battery" or none, as the rail rollup
347
+ reads it) names the device as its source_device, and that device declares the pack's mass.
348
+ The mass guard keeps a regulator named on a battery-fed rail from being taken for the pack.
349
+ """
350
+ rails = contract.topology.rails if contract.topology else []
351
+ same = _same_mass_devices(contract)
352
+ return next(
353
+ (r.source_device for r in rails if r.upstream in (None, "battery") and r.source_device in same),
354
+ None,
355
+ )
356
+
357
+
358
+ def bom_rows(contract: Contract) -> list[dict[str, Any]]:
359
+ """Parts list: one row per distinct declared part (same model, mass, source), plus the pack.
360
+
361
+ Empty string means the lockfile does not hold it. A part with no declared mass takes the
362
+ catalog's mass when exactly one catalog part has the same last id word and the same family,
363
+ and the source cell says so. ``maker`` is the matched catalog part's maker, empty when the
364
+ catalog has none (the first word of a part name is not always one: "Pixhawk 6C", "Generic ...").
365
+ """
366
+ parts = None
367
+ groups: dict[tuple, list] = {}
368
+ for dev in contract.devices:
369
+ mass = dev.physical.mass.base() if dev.physical and dev.physical.mass else None
370
+ model = contract.device_model(dev.model)
371
+ prov = dev.provenance or (model.provenance if model else None)
372
+ key = (dev.model, mass, prov.source if prov else "")
373
+ groups.setdefault(key, [model]).append(dev)
374
+ rows = []
375
+ for (model_id, mass, source), (model, *devs) in groups.items():
376
+ fam = contract.family(model.family) if model else None
377
+ vr = model.input_voltage_range if model else None
378
+ url = next((w for w in source.replace(";", " ").split() if w.startswith("http")), "")
379
+ unverified = ""
380
+ maker = ""
381
+ if model:
382
+ parts = parts if parts is not None else load_catalog().parts
383
+ tail = model_id.rsplit(".", 1)[-1].lower()
384
+ hit = [
385
+ p for p in parts
386
+ if p.id.rsplit(".", 1)[-1].lower() == tail and p.family == model.family
387
+ ] # fmt: skip
388
+ if len(hit) == 1:
389
+ maker = hit[0].maker or ""
390
+ if mass is None and len(hit) == 1 and "mass" in hit[0].numbers:
391
+ n = hit[0].numbers["mass"]
392
+ mass = units.to_base(n.value, n.unit)
393
+ source = f"{source}; " if source else ""
394
+ source += f"catalog: {hit[0].id} ({hit[0].label})"
395
+ unverified = "1" if hit[0].label == "unverified" else ""
396
+ rows.append(
397
+ {
398
+ "part": model_id,
399
+ "quantity": str(len(devs)),
400
+ "maker": maker,
401
+ "kind": (fam.name if fam else model.family if model else ""),
402
+ "unit_mass_kg": "" if mass is None else _g(mass),
403
+ "total_mass_kg": "" if mass is None else _g(mass * len(devs)),
404
+ "voltage": f"{vr.min.value:g}-{vr.max.value:g} {vr.max.unit}" if vr else "",
405
+ "source": source,
406
+ "datasheet": url,
407
+ "_unverified": unverified, # internal flag, not a CSV column
408
+ }
409
+ )
410
+ bat = contract.topology.battery if contract.topology else None
411
+ m = bat.mass.base() if bat and bat.mass else None
412
+ if bat and not _pack_device(contract):
413
+ rows.append(
414
+ {
415
+ "part": "battery",
416
+ "quantity": "1",
417
+ "maker": "",
418
+ "kind": bat.chemistry or "battery",
419
+ "unit_mass_kg": "" if m is None else _g(m),
420
+ "total_mass_kg": "" if m is None else _g(m),
421
+ "voltage": str(bat.voltage) if bat.voltage else "",
422
+ "source": "",
423
+ "datasheet": "",
424
+ }
425
+ )
426
+ twice = {
427
+ r["part"]
428
+ for r in rows
429
+ if r["part"] != "battery" and sum(x["part"] == r["part"] for x in rows) > 1
430
+ }
431
+ for r in rows:
432
+ r["notes"] = [
433
+ n
434
+ for n, hit in (
435
+ (
436
+ "no cited mass",
437
+ not r["unit_mass_kg"] or (not r["source"] and r["part"] != "battery"),
438
+ ), # a battery has no source field
439
+ ("mass from an unverified catalog entry", bool(r.get("_unverified"))),
440
+ ("listed twice: merge into one row with qty 2", r["part"] in twice),
441
+ )
442
+ if hit
443
+ ]
444
+ return [{"item": str(n), **r} for n, r in enumerate(rows, 1)]
445
+
446
+
447
+ def bom_mass_note(contract: Contract, rows: list[dict[str, Any]]) -> str | None:
448
+ """One sentence: listed part mass against the robot model's link-mass sum; None if either is unknown."""
449
+ listed = sum(float(r["total_mass_kg"]) for r in rows if r["total_mass_kg"])
450
+ links = contract.model.links if contract.model else []
451
+ robot = sum(link.mass.base() for link in links if link.mass)
452
+ twice = _same_mass_devices(contract) if not _pack_device(contract) else []
453
+ pair = (
454
+ f"The battery and {', '.join(twice)} declare the same mass; if they are the same pack, the parts"
455
+ f" total counts it twice: link them with source_device: {twice[0]} on the battery's rail to count it once."
456
+ if twice and any(r["part"] == "battery" for r in rows)
457
+ else None
458
+ )
459
+ if not listed or not robot:
460
+ return pair
461
+ gap = robot - listed
462
+ tail = (
463
+ f"{gap:.2f} kg is not in the parts list (frame, wires, fasteners)."
464
+ if gap >= 0
465
+ else f"The parts list is {-gap:.2f} kg over the model; check for masses counted twice."
466
+ )
467
+ note = f"Parts listed weigh {listed:.2f} kg; the robot model weighs {robot:.2f} kg. {tail}"
468
+ if any(r.get("_unverified") for r in rows):
469
+ note += " Some part masses are unverified catalog figures."
470
+ return f"{note} {pair}" if pair else note
471
+
472
+
300
473
  def verdict_document(
301
474
  contract: Contract, findings: list[Finding], artifact_type: str
302
475
  ) -> dict[str, Any]:
@@ -338,9 +511,27 @@ def verdict_document(
338
511
  # figure on the panel has a CLI twin. The CG is reused, never recomputed
339
512
  # `information` is exactly what compute_system_cg returned.
340
513
  document["forces"] = force_document(contract, getattr(findings, "information", []))
514
+ _tag_mass_rows(contract, document["forces"]["masses"])
341
515
  return document
342
516
 
343
517
 
518
+ def _tag_mass_rows(contract: Contract, rows: list[dict[str, Any]]) -> None:
519
+ """Say each mass's maturity (and a link's material) so the panel can show its band."""
520
+ links = {link.name: link for link in contract.model.links} if contract.model else {}
521
+ devices = {device.id: device for device in contract.devices if device.physical}
522
+ for row in rows:
523
+ parts = (row.get("id") or "").split("/")
524
+ if parts[:2] == ["model", "links"] and parts[2] in links:
525
+ link = links[parts[2]]
526
+ row["mass_kind"] = link.effective_mass_kind
527
+ if link.mass_note:
528
+ row["mass_note"] = link.mass_note
529
+ if link.material:
530
+ row["material"] = link.material.name
531
+ elif parts[:1] == ["devices"] and parts[1] in devices:
532
+ row["mass_kind"] = devices[parts[1]].physical.effective_mass_kind # type: ignore[union-attr]
533
+
534
+
344
535
  def load(contract: Path | str) -> Contract:
345
536
  """Load and validate a contract file — ``schema.load_contract``, nothing more."""
346
537
  return load_contract(Path(contract))
@@ -437,11 +628,11 @@ def _actuator_claim_document(
437
628
  else ()
438
629
  )
439
630
  sources = {
440
- (row.provenance.source, row.provenance.witness)
631
+ (row.provenance.source, row.provenance.witness or "")
441
632
  for row in (admitted.signals if admitted is not None else ())
442
633
  if row.provenance is not None
443
634
  and row.provenance.source.strip()
444
- and row.provenance.witness.strip()
635
+ and (row.provenance.witness is None or row.provenance.witness.strip())
445
636
  }
446
637
  evidence_class = "unverified"
447
638
  if admitted is not None and decision.scored and evidence is not None:
@@ -1195,8 +1386,10 @@ def upgrade(
1195
1386
  raise ValueError("legacy contract changed since its revision was selected")
1196
1387
  upgraded = upgrade_contract_text(raw.decode("utf-8")).encode("utf-8")
1197
1388
  legacy = load_contract_bytes(raw, upgrading=True, name=contract_path.name)
1198
- if legacy.schema_version not in {"0.2", "0.3", "0.4", "0.5"}:
1199
- raise ValueError("upgrade requires an explicit legacy schema_version 0.2, 0.3, 0.4 or 0.5")
1389
+ if legacy.schema_version not in {"0.2", "0.3", "0.4", "0.5", "0.6"}:
1390
+ raise ValueError(
1391
+ "upgrade requires an explicit legacy schema_version 0.2, 0.3, 0.4, 0.5 or 0.6"
1392
+ )
1200
1393
  load_contract_bytes(upgraded)
1201
1394
  if contract_path.read_bytes() != raw:
1202
1395
  raise ValueError("legacy contract changed during upgrade")
@@ -1260,6 +1453,56 @@ def _selected_external_meshes(
1260
1453
  return declared_assets
1261
1454
 
1262
1455
 
1456
+ def _with_declared_shapes(contract: Contract, scene: Any) -> Any:
1457
+ """A mesh scene keeps its parts; each link's declared shapes are drawn with them (in addition,
1458
+ as parts claiming that link). Same world poses the shapes-only path draws."""
1459
+ from dataclasses import replace # noqa: PLC0415
1460
+
1461
+ from lockwire.page import _robot_model # noqa: PLC0415 - deferred, as the other lazy imports
1462
+ from lockwire.scene import ScenePart # noqa: PLC0415
1463
+ from lockwire.scene_urdf import _box_mesh, _cylinder_mesh, _rotate, _sphere_mesh # noqa: PLC0415
1464
+
1465
+ def mesh(row: dict[str, Any]) -> Any:
1466
+ if row["kind"] == "box":
1467
+ return _box_mesh(*row["size"])
1468
+ if row["kind"] == "cylinder":
1469
+ return _cylinder_mesh(row["radius"], row["length"])
1470
+ return _sphere_mesh(row["radius"])
1471
+
1472
+ def to_scene_up(flat: tuple[float, ...]) -> tuple[float, ...]: # z-up world -> glb y-up
1473
+ return tuple(v for x, y, z in zip(*[iter(flat)] * 3, strict=True) for v in (x, z, -y))
1474
+
1475
+ parts = []
1476
+ for link in _robot_model(contract)["links"]:
1477
+ for i, row in enumerate(link["solids"]):
1478
+ rot = tuple(tuple(row["rotation"][r * 3 : r * 3 + 3]) for r in range(3))
1479
+ positions, normals, indices = mesh(row)
1480
+ world = _rotate(rot, positions, tuple(row["position"]))
1481
+ norms = _rotate(rot, normals)
1482
+ if scene.up == "y":
1483
+ world, norms = to_scene_up(world), to_scene_up(norms)
1484
+ parts.append(
1485
+ ScenePart(
1486
+ f"{link['name']}_shape{i}",
1487
+ link["name"],
1488
+ (link["name"],),
1489
+ world,
1490
+ norms,
1491
+ indices,
1492
+ (0.62, 0.64, 0.7, 1.0),
1493
+ (0.0, 0.0, 0.0),
1494
+ )
1495
+ )
1496
+ if not parts:
1497
+ return scene
1498
+ return replace(
1499
+ scene,
1500
+ parts=(*scene.parts, *parts),
1501
+ triangles=scene.triangles + sum(len(p.indices) // 3 for p in parts),
1502
+ vertices=scene.vertices + sum(len(p.positions) // 3 for p in parts),
1503
+ )
1504
+
1505
+
1263
1506
  def load_scene(
1264
1507
  contract_path: Path | str, scene: Path | str | None, package_root: Iterable[Path | str] = ()
1265
1508
  ) -> tuple[Any, str | None]:
@@ -1286,6 +1529,8 @@ def load_scene(
1286
1529
  from lockwire.scene_view import scene_asset_identity
1287
1530
 
1288
1531
  scene_asset_identity(loaded_contract, loaded_scene, Path(contract_path))
1532
+ if scene_path.suffix.lower() in (".glb", ".gltf"):
1533
+ loaded_scene = _with_declared_shapes(loaded_contract, loaded_scene)
1289
1534
  if discovered:
1290
1535
  return loaded_scene, f"{scene_path.name} (found beside the contract)"
1291
1536
  return loaded_scene, f"{scene_path.name} (given)"