litearm-python 1.3.0__tar.gz → 1.4.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 (96) hide show
  1. {litearm_python-1.3.0 → litearm_python-1.4.0}/PKG-INFO +88 -32
  2. litearm_python-1.3.0/src/litearm_python.egg-info/PKG-INFO → litearm_python-1.4.0/README.md +77 -59
  3. {litearm_python-1.3.0 → litearm_python-1.4.0}/pyproject.toml +9 -6
  4. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/__init__.py +21 -15
  5. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/_protocol.py +29 -30
  6. litearm_python-1.4.0/src/litearm/_robot_model.py +146 -0
  7. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/arm.py +82 -35
  8. litearm_python-1.4.0/src/litearm/assets/litearm/meshes/base_link.STL +0 -0
  9. litearm_python-1.4.0/src/litearm/assets/litearm/meshes/ee_link.STL +0 -0
  10. litearm_python-1.4.0/src/litearm/assets/litearm/meshes/joint1.STL +0 -0
  11. litearm_python-1.4.0/src/litearm/assets/litearm/meshes/joint2.STL +0 -0
  12. litearm_python-1.4.0/src/litearm/assets/litearm/meshes/joint3.STL +0 -0
  13. litearm_python-1.4.0/src/litearm/assets/litearm/meshes/joint4.STL +0 -0
  14. litearm_python-1.4.0/src/litearm/assets/litearm/meshes/joint5.STL +0 -0
  15. litearm_python-1.4.0/src/litearm/assets/litearm/meshes/joint6.STL +0 -0
  16. litearm_python-1.4.0/src/litearm/assets/litearm/meshes/joint7.STL +0 -0
  17. litearm_python-1.4.0/src/litearm/assets/litearm/urdf/litearm.urdf +256 -0
  18. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/cart.py +17 -23
  19. litearm_python-1.4.0/src/litearm/collision.py +67 -0
  20. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/errors.py +3 -4
  21. litearm_python-1.4.0/src/litearm/exact_ik.py +215 -0
  22. litearm_python-1.4.0/src/litearm/kinematics.py +370 -0
  23. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/params.py +2 -1
  24. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/payload.py +5 -2
  25. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/state.py +3 -4
  26. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/testing.py +13 -16
  27. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/transport.py +4 -6
  28. litearm_python-1.3.0/README.md → litearm_python-1.4.0/src/litearm_python.egg-info/PKG-INFO +115 -29
  29. litearm_python-1.4.0/src/litearm_python.egg-info/SOURCES.txt +47 -0
  30. litearm_python-1.4.0/src/litearm_python.egg-info/requires.txt +14 -0
  31. litearm_python-1.4.0/tests/test_collision.py +171 -0
  32. litearm_python-1.4.0/tests/test_exact_ik.py +59 -0
  33. litearm_python-1.4.0/tests/test_firmware_model_consistency.py +71 -0
  34. litearm_python-1.4.0/tests/test_local_kinematics.py +187 -0
  35. litearm_python-1.4.0/tests/test_motion_serial.py +101 -0
  36. litearm_python-1.4.0/tests/test_smoke.py +121 -0
  37. litearm_python-1.3.0/src/litearm_python.egg-info/SOURCES.txt +0 -72
  38. litearm_python-1.3.0/src/litearm_python.egg-info/requires.txt +0 -4
  39. litearm_python-1.3.0/tests/test_ack_echo.py +0 -110
  40. litearm_python-1.3.0/tests/test_arm_offline.py +0 -190
  41. litearm_python-1.3.0/tests/test_banner.py +0 -109
  42. litearm_python-1.3.0/tests/test_capability.py +0 -62
  43. litearm_python-1.3.0/tests/test_cart_errors.py +0 -110
  44. litearm_python-1.3.0/tests/test_cart_protocol.py +0 -1477
  45. litearm_python-1.3.0/tests/test_cart_queue.py +0 -1480
  46. litearm_python-1.3.0/tests/test_cart_wait.py +0 -594
  47. litearm_python-1.3.0/tests/test_cli.py +0 -73
  48. litearm_python-1.3.0/tests/test_dfu.py +0 -322
  49. litearm_python-1.3.0/tests/test_diagnostics.py +0 -122
  50. litearm_python-1.3.0/tests/test_doc_examples.py +0 -358
  51. litearm_python-1.3.0/tests/test_env_sh.py +0 -55
  52. litearm_python-1.3.0/tests/test_error_codes.py +0 -945
  53. litearm_python-1.3.0/tests/test_error_hierarchy.py +0 -24
  54. litearm_python-1.3.0/tests/test_ff_io.py +0 -126
  55. litearm_python-1.3.0/tests/test_fork_guard.py +0 -246
  56. litearm_python-1.3.0/tests/test_frame_ownership.py +0 -264
  57. litearm_python-1.3.0/tests/test_full_coverage.py +0 -363
  58. litearm_python-1.3.0/tests/test_home.py +0 -65
  59. litearm_python-1.3.0/tests/test_ik_bench.py +0 -73
  60. litearm_python-1.3.0/tests/test_license.py +0 -223
  61. litearm_python-1.3.0/tests/test_lifecycle.py +0 -179
  62. litearm_python-1.3.0/tests/test_live.py +0 -41
  63. litearm_python-1.3.0/tests/test_log.py +0 -161
  64. litearm_python-1.3.0/tests/test_model.py +0 -237
  65. litearm_python-1.3.0/tests/test_msg.py +0 -388
  66. litearm_python-1.3.0/tests/test_offline.py +0 -95
  67. litearm_python-1.3.0/tests/test_package_metadata.py +0 -46
  68. litearm_python-1.3.0/tests/test_params.py +0 -101
  69. litearm_python-1.3.0/tests/test_payload.py +0 -400
  70. litearm_python-1.3.0/tests/test_protocol_crc.py +0 -125
  71. litearm_python-1.3.0/tests/test_protocol_sync.py +0 -367
  72. litearm_python-1.3.0/tests/test_public_api.py +0 -131
  73. litearm_python-1.3.0/tests/test_request_and_get.py +0 -173
  74. litearm_python-1.3.0/tests/test_silent_noops.py +0 -140
  75. litearm_python-1.3.0/tests/test_status_layout.py +0 -99
  76. litearm_python-1.3.0/tests/test_teardown.py +0 -403
  77. litearm_python-1.3.0/tests/test_tool_offset.py +0 -212
  78. litearm_python-1.3.0/tests/test_transport.py +0 -835
  79. litearm_python-1.3.0/tests/test_transport_injection.py +0 -25
  80. litearm_python-1.3.0/tests/test_transport_tcp.py +0 -217
  81. litearm_python-1.3.0/tests/test_transport_threadsafe.py +0 -146
  82. litearm_python-1.3.0/tests/test_zero_g.py +0 -111
  83. litearm_python-1.3.0/tests/test_zero_g_cart_guard.py +0 -194
  84. {litearm_python-1.3.0 → litearm_python-1.4.0}/LICENSE +0 -0
  85. {litearm_python-1.3.0 → litearm_python-1.4.0}/setup.cfg +0 -0
  86. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/__main__.py +0 -0
  87. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/_rot.py +0 -0
  88. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/diagnostics.py +0 -0
  89. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/log.py +0 -0
  90. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/model.py +0 -0
  91. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/py.typed +0 -0
  92. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/tool.py +0 -0
  93. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm/transport_tcp.py +0 -0
  94. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm_python.egg-info/dependency_links.txt +0 -0
  95. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm_python.egg-info/entry_points.txt +0 -0
  96. {litearm_python-1.3.0 → litearm_python-1.4.0}/src/litearm_python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: litearm-python
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: Python SDK for the LiteArm robotic arm
5
5
  Author: NEXFORM ROBOTICS
6
6
  License-Expression: Apache-2.0
@@ -24,29 +24,40 @@ Requires-Python: >=3.9
24
24
  Description-Content-Type: text/markdown
25
25
  License-File: LICENSE
26
26
  Requires-Dist: pyserial>=3.4
27
- Provides-Extra: dev
28
- Requires-Dist: pytest>=7; extra == "dev"
27
+ Provides-Extra: collision
28
+ Requires-Dist: numpy>=1.23; extra == "collision"
29
+ Requires-Dist: pin>=3.0; extra == "collision"
30
+ Provides-Extra: ik
31
+ Requires-Dist: numpy>=1.23; extra == "ik"
32
+ Requires-Dist: scipy>=1.9; extra == "ik"
33
+ Provides-Extra: robotics
34
+ Requires-Dist: numpy>=1.23; extra == "robotics"
35
+ Requires-Dist: scipy>=1.9; extra == "robotics"
36
+ Requires-Dist: pin>=3.0; extra == "robotics"
29
37
  Dynamic: license-file
30
38
 
31
39
  # litearm-python
32
40
 
33
41
  Python SDK for the LiteArm robotic arm: drive the arm from a PC over one USB serial cable,
34
- straight to its firmware — no server or middleware in between. Trajectory planning, kinematics
35
- and dynamics are all carried by the firmware.
42
+ straight to its firmware — no server or middleware in between. The firmware owns real-time
43
+ control and S-curves; the optional SDK model computes local FK/IK/Jacobians and guarded PTPs.
36
44
 
37
45
  > Full interface reference: [docs/DEVELOPER_GUIDE.md](https://github.com/nexform-tech/litearm-python/blob/main/docs/DEVELOPER_GUIDE.md).
38
46
 
39
47
  ## Features
40
48
 
41
49
  - **Pure Python**: Python 3.9+, poses are plain lists / tuples, no numpy needed
42
- - **A single dependency**: `pyserial`, nothing else
50
+ - **Lightweight by default**: the normal serial install depends only on `pyserial`
43
51
  - **Direct over USB**: one cable to the firmware, no server in between
44
- - **The firmware does the planning**: kinematics and dynamics live there; the PC sends points and decides arrival
52
+ - **Optional local kinematics**: Pinocchio uses the packaged URDF for FK/IK/Jacobians
53
+ - **Execution stays in firmware**: STM32 enforces velocity, acceleration, jerk and synchronized S-curves
45
54
  - **Full motion API**: joint moves, Cartesian lines / arcs / waypoints, hand-guiding
46
55
  - **Tool point (TCP) offset**: a host-side xyz + rpy layer, so `move_*` and `ik()` take tool
47
56
  poses while `get_tcp()` keeps returning the flange
48
57
  - **Payload identification**: measure the mass and centre of mass of the end-of-arm load from
49
58
  the arm's own torque, then hand the result to `set_payload()`
59
+ - **Optional self-collision checks**: Pinocchio/hpp-fcl checks the packaged URDF meshes before
60
+ a predictable joint path is sent; the normal serial SDK stays dependency-light
50
61
  - **Safety built in**: fail-closed in child processes, a dedicated emergency stop, and every irreversible command flagged
51
62
 
52
63
  ## Install
@@ -54,7 +65,7 @@ and dynamics are all carried by the firmware.
54
65
  | Item | Requirement |
55
66
  | --- | --- |
56
67
  | Python | 3.9 or later |
57
- | Dependencies | `pyserial >= 3.4` (the only one) |
68
+ | Default dependency | `pyserial >= 3.4` (`robotics` extras are optional) |
58
69
  | Firmware | `Litearm1.5.0` or later |
59
70
  | Connection | USB CDC serial, VID:PID `1d50:606f` |
60
71
 
@@ -65,6 +76,47 @@ pip install litearm-python
65
76
  python3 -c "import litearm; print(litearm.__version__)" # verify
66
77
  ```
67
78
 
79
+ Local kinematics and self-collision checking are an optional, heavier install:
80
+
81
+ ```bash
82
+ pip install "litearm-python[robotics]"
83
+ ```
84
+
85
+ If the shell has sourced ROS, its `PYTHONPATH` and `LD_LIBRARY_PATH` can inject
86
+ a Pinocchio build for another Python ABI. On `pinocchio_pywrap_default` or
87
+ `undefined symbol` errors, run with
88
+ `env -u PYTHONPATH -u LD_LIBRARY_PATH .venv/bin/python your_script.py`.
89
+
90
+ `CollisionModel()` automatically loads the wheel's URDF and nine collision meshes. Its
91
+ `in_collision(q)` method returns a boolean; `colliding_pairs(q)` returns all colliding geometry
92
+ name pairs; `minimum_distance(q)` returns the nearest non-adjacent-link clearance. All require
93
+ exactly seven finite joint angles. Each checker owns its mutable
94
+ Pinocchio data and serializes calls on that instance, so it can be shared across threads.
95
+
96
+ Use it for planning/preflight work, not a real-time loop. For path checking, sample every
97
+ configuration along the path. In particular, `movej_sync` follows the joint-space line and can
98
+ be checked that way; ordinary `movej` drives independent per-axis S-curves, so checking only its
99
+ endpoints does not prove the unknown intermediate path collision-free.
100
+
101
+ ```text
102
+ collision = pa.CollisionModel()
103
+ collision.in_collision([0.0] * 7)
104
+ collision.colliding_pairs(q)
105
+ ```
106
+
107
+ For VR/servo control, the exact differential-IK backend from `lite-vr` is also
108
+ available without changing the firmware pose solver `Arm.ik()`:
109
+
110
+ ```bash
111
+ pip install "litearm-python[ik]"
112
+ ```
113
+
114
+ Call `litearm.exact_ik.exact_task_velocity(J, twist, lower, upper)` with a
115
+ Jacobian and velocity/range box. It either delivers the complete twist or
116
+ returns zero velocity with a structured failure reason. Use
117
+ `bounded_task_velocity(...)` when partial, damped motion is preferable to
118
+ holding position. The Jacobian and twist must use the same reference frame.
119
+
68
120
  Or install from a checkout:
69
121
 
70
122
  ```bash
@@ -249,9 +301,29 @@ state = arm.get_state().value
249
301
  print(state.q, state.dq, state.tau) # joint angles / velocity / torque
250
302
  print(state.enabled, state.faulted) # enabled? faulted?
251
303
  print(arm.get_tcp().value) # flange pose (firmware forward kinematics)
252
- print(arm.ik((0.30, 0.0, 0.35, 3.1416, 0.0, 0.0))) # pose → joint angles
304
+ print(arm.ik((0.30, 0.0, 0.35, 3.1416, 0.0, 0.0))) # firmware remote IK
305
+
306
+ q = state.q
307
+ print(arm.kinematics.fk(q, frame="flange")) # SDK-local FK, no command sent
308
+ print(arm.kinematics.jacobian(q).sigma_min) # SDK-local Jacobian
309
+ q_seed = [0.0, -0.5, 0.0, -1.0, 0.0, 0.5, 0.0]
310
+ target_pose = arm.kinematics.fk(q_seed, frame="flange")
311
+ solution = arm.kinematics.ik(target_pose, q_seed=q_seed, frame="flange")
312
+ # arm.kinematics.move_pose(target_pose, speed=0.2) # preflight, then one 0x07
253
313
  ```
254
314
 
315
+ `arm.kinematics.move_pose()` seeds from fresh state, reads the STM32 runtime soft limits, and
316
+ samples the joint line at no more than 0.02 rad to check limit margin, self-collision/5 mm
317
+ clearance and `sigma_min >= 0.05`. If the start moves during preflight it replans once, then
318
+ fails closed on a second drift. A passing move sends exactly one `movej_sync`; STM32 still owns
319
+ velocity, acceleration and jerk limits. This checks **self-collision only**—not benches, people,
320
+ or external obstacles.
321
+
322
+ The IK residual is numerical convergence, not guaranteed physical TCP accuracy. `move_pose()`
323
+ waits with the existing joint-space `q_tol` / `dq_tol` criteria, so tracking, encoder and calibration
324
+ errors still apply. Evaluate `arm.kinematics.fk(returned_state.q)` when the measured endpoint matters;
325
+ hardware review saw about 0.7-1.1 mm error on 2-10 mm test moves (informative, not a specification).
326
+
255
327
  ### Tool point (TCP) offset
256
328
 
257
329
  The firmware's TCP *is* the flange. To control a tool point instead, declare the offset once —
@@ -518,6 +590,7 @@ See [examples/README.md](https://github.com/nexform-tech/litearm-python/blob/mai
518
590
  - `02_movej.py` — joint motion
519
591
  - `03_move_p.py` — Cartesian point to point
520
592
  - `04_ik_tcp.py` — inverse kinematics and the current pose
593
+ - `10_local_kinematics.py` — SDK-local FK/IK/Jacobian and guarded pose PTP
521
594
  - `06_cartesian.py` — Cartesian lines / arcs / waypoints
522
595
  - `07_vel_jitter_trace.py` — 300 Hz per-tick capture
523
596
 
@@ -532,33 +605,16 @@ python3 examples/01_hello.py
532
605
 
533
606
  ## Development
534
607
 
535
- ```bash
536
- pip install -e ".[dev]"
537
- pytest # full offline run, never touches hardware
538
- LITEARM_LIVE=1 pytest # plus hardware tests, moves a little
539
- ```
540
-
541
- Running the tests does not require installing the package; `tests/conftest.py` sets `sys.path`
542
- itself. Do not set `LITEARM_LIVE` with nobody present, and never call `enter_dfu()` /
543
- `reset_factory()`.
544
-
545
- **On a machine with ROS 2 installed, `pytest` dies during collection and none of this repository
546
- is involved**: pytest auto-loads the plugins under `/opt/ros/...` by entry point, and `launch`
547
- needs `lark`, which is not installed:
548
-
549
- ```
550
- ModuleNotFoundError: No module named 'lark'
551
- ```
552
-
553
- A virtualenv does not stop it — `PYTHONPATH` takes priority over the venv's `site-packages`.
554
- Either of these works:
608
+ This repository does not ship a test suite. Verify a change with a minimal smoke check:
555
609
 
556
610
  ```bash
557
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest
558
- env -u PYTHONPATH pytest
611
+ pip install -e .
612
+ python3 -c "import litearm; print(litearm.__version__)"
613
+ python3 -m build # after pip install build
559
614
  ```
560
615
 
561
- `-p no:launch_testing` is **not** enough: the `launch_ros` entry point gets loaded anyway.
616
+ `litearm.testing.FakeTransport` is still shipped. To write your own offline tests, replace
617
+ `SerialTransport` with it; no hardware is needed.
562
618
 
563
619
  On Windows use `env.ps1` / `env.cmd` and `run_example.ps1` / `run_example.cmd`.
564
620
 
@@ -1,52 +1,25 @@
1
- Metadata-Version: 2.4
2
- Name: litearm-python
3
- Version: 1.3.0
4
- Summary: Python SDK for the LiteArm robotic arm
5
- Author: NEXFORM ROBOTICS
6
- License-Expression: Apache-2.0
7
- Project-URL: Repository, https://github.com/nexform-tech/litearm-python
8
- Project-URL: Issues, https://github.com/nexform-tech/litearm-python/issues
9
- Project-URL: Documentation, https://github.com/nexform-tech/litearm-python/blob/main/docs/DEVELOPER_GUIDE.md
10
- Keywords: litearm,robotic-arm,robot-arm,robotics,serial,stm32,sdk
11
- Classifier: Development Status :: 4 - Beta
12
- Classifier: Intended Audience :: Developers
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3 :: Only
16
- Classifier: Programming Language :: Python :: 3.9
17
- Classifier: Programming Language :: Python :: 3.10
18
- Classifier: Programming Language :: Python :: 3.11
19
- Classifier: Programming Language :: Python :: 3.12
20
- Classifier: Programming Language :: Python :: 3.13
21
- Classifier: Topic :: Scientific/Engineering
22
- Classifier: Typing :: Typed
23
- Requires-Python: >=3.9
24
- Description-Content-Type: text/markdown
25
- License-File: LICENSE
26
- Requires-Dist: pyserial>=3.4
27
- Provides-Extra: dev
28
- Requires-Dist: pytest>=7; extra == "dev"
29
- Dynamic: license-file
30
-
31
1
  # litearm-python
32
2
 
33
3
  Python SDK for the LiteArm robotic arm: drive the arm from a PC over one USB serial cable,
34
- straight to its firmware — no server or middleware in between. Trajectory planning, kinematics
35
- and dynamics are all carried by the firmware.
4
+ straight to its firmware — no server or middleware in between. The firmware owns real-time
5
+ control and S-curves; the optional SDK model computes local FK/IK/Jacobians and guarded PTPs.
36
6
 
37
7
  > Full interface reference: [docs/DEVELOPER_GUIDE.md](https://github.com/nexform-tech/litearm-python/blob/main/docs/DEVELOPER_GUIDE.md).
38
8
 
39
9
  ## Features
40
10
 
41
11
  - **Pure Python**: Python 3.9+, poses are plain lists / tuples, no numpy needed
42
- - **A single dependency**: `pyserial`, nothing else
12
+ - **Lightweight by default**: the normal serial install depends only on `pyserial`
43
13
  - **Direct over USB**: one cable to the firmware, no server in between
44
- - **The firmware does the planning**: kinematics and dynamics live there; the PC sends points and decides arrival
14
+ - **Optional local kinematics**: Pinocchio uses the packaged URDF for FK/IK/Jacobians
15
+ - **Execution stays in firmware**: STM32 enforces velocity, acceleration, jerk and synchronized S-curves
45
16
  - **Full motion API**: joint moves, Cartesian lines / arcs / waypoints, hand-guiding
46
17
  - **Tool point (TCP) offset**: a host-side xyz + rpy layer, so `move_*` and `ik()` take tool
47
18
  poses while `get_tcp()` keeps returning the flange
48
19
  - **Payload identification**: measure the mass and centre of mass of the end-of-arm load from
49
20
  the arm's own torque, then hand the result to `set_payload()`
21
+ - **Optional self-collision checks**: Pinocchio/hpp-fcl checks the packaged URDF meshes before
22
+ a predictable joint path is sent; the normal serial SDK stays dependency-light
50
23
  - **Safety built in**: fail-closed in child processes, a dedicated emergency stop, and every irreversible command flagged
51
24
 
52
25
  ## Install
@@ -54,7 +27,7 @@ and dynamics are all carried by the firmware.
54
27
  | Item | Requirement |
55
28
  | --- | --- |
56
29
  | Python | 3.9 or later |
57
- | Dependencies | `pyserial >= 3.4` (the only one) |
30
+ | Default dependency | `pyserial >= 3.4` (`robotics` extras are optional) |
58
31
  | Firmware | `Litearm1.5.0` or later |
59
32
  | Connection | USB CDC serial, VID:PID `1d50:606f` |
60
33
 
@@ -65,6 +38,47 @@ pip install litearm-python
65
38
  python3 -c "import litearm; print(litearm.__version__)" # verify
66
39
  ```
67
40
 
41
+ Local kinematics and self-collision checking are an optional, heavier install:
42
+
43
+ ```bash
44
+ pip install "litearm-python[robotics]"
45
+ ```
46
+
47
+ If the shell has sourced ROS, its `PYTHONPATH` and `LD_LIBRARY_PATH` can inject
48
+ a Pinocchio build for another Python ABI. On `pinocchio_pywrap_default` or
49
+ `undefined symbol` errors, run with
50
+ `env -u PYTHONPATH -u LD_LIBRARY_PATH .venv/bin/python your_script.py`.
51
+
52
+ `CollisionModel()` automatically loads the wheel's URDF and nine collision meshes. Its
53
+ `in_collision(q)` method returns a boolean; `colliding_pairs(q)` returns all colliding geometry
54
+ name pairs; `minimum_distance(q)` returns the nearest non-adjacent-link clearance. All require
55
+ exactly seven finite joint angles. Each checker owns its mutable
56
+ Pinocchio data and serializes calls on that instance, so it can be shared across threads.
57
+
58
+ Use it for planning/preflight work, not a real-time loop. For path checking, sample every
59
+ configuration along the path. In particular, `movej_sync` follows the joint-space line and can
60
+ be checked that way; ordinary `movej` drives independent per-axis S-curves, so checking only its
61
+ endpoints does not prove the unknown intermediate path collision-free.
62
+
63
+ ```text
64
+ collision = pa.CollisionModel()
65
+ collision.in_collision([0.0] * 7)
66
+ collision.colliding_pairs(q)
67
+ ```
68
+
69
+ For VR/servo control, the exact differential-IK backend from `lite-vr` is also
70
+ available without changing the firmware pose solver `Arm.ik()`:
71
+
72
+ ```bash
73
+ pip install "litearm-python[ik]"
74
+ ```
75
+
76
+ Call `litearm.exact_ik.exact_task_velocity(J, twist, lower, upper)` with a
77
+ Jacobian and velocity/range box. It either delivers the complete twist or
78
+ returns zero velocity with a structured failure reason. Use
79
+ `bounded_task_velocity(...)` when partial, damped motion is preferable to
80
+ holding position. The Jacobian and twist must use the same reference frame.
81
+
68
82
  Or install from a checkout:
69
83
 
70
84
  ```bash
@@ -249,9 +263,29 @@ state = arm.get_state().value
249
263
  print(state.q, state.dq, state.tau) # joint angles / velocity / torque
250
264
  print(state.enabled, state.faulted) # enabled? faulted?
251
265
  print(arm.get_tcp().value) # flange pose (firmware forward kinematics)
252
- print(arm.ik((0.30, 0.0, 0.35, 3.1416, 0.0, 0.0))) # pose → joint angles
266
+ print(arm.ik((0.30, 0.0, 0.35, 3.1416, 0.0, 0.0))) # firmware remote IK
267
+
268
+ q = state.q
269
+ print(arm.kinematics.fk(q, frame="flange")) # SDK-local FK, no command sent
270
+ print(arm.kinematics.jacobian(q).sigma_min) # SDK-local Jacobian
271
+ q_seed = [0.0, -0.5, 0.0, -1.0, 0.0, 0.5, 0.0]
272
+ target_pose = arm.kinematics.fk(q_seed, frame="flange")
273
+ solution = arm.kinematics.ik(target_pose, q_seed=q_seed, frame="flange")
274
+ # arm.kinematics.move_pose(target_pose, speed=0.2) # preflight, then one 0x07
253
275
  ```
254
276
 
277
+ `arm.kinematics.move_pose()` seeds from fresh state, reads the STM32 runtime soft limits, and
278
+ samples the joint line at no more than 0.02 rad to check limit margin, self-collision/5 mm
279
+ clearance and `sigma_min >= 0.05`. If the start moves during preflight it replans once, then
280
+ fails closed on a second drift. A passing move sends exactly one `movej_sync`; STM32 still owns
281
+ velocity, acceleration and jerk limits. This checks **self-collision only**—not benches, people,
282
+ or external obstacles.
283
+
284
+ The IK residual is numerical convergence, not guaranteed physical TCP accuracy. `move_pose()`
285
+ waits with the existing joint-space `q_tol` / `dq_tol` criteria, so tracking, encoder and calibration
286
+ errors still apply. Evaluate `arm.kinematics.fk(returned_state.q)` when the measured endpoint matters;
287
+ hardware review saw about 0.7-1.1 mm error on 2-10 mm test moves (informative, not a specification).
288
+
255
289
  ### Tool point (TCP) offset
256
290
 
257
291
  The firmware's TCP *is* the flange. To control a tool point instead, declare the offset once —
@@ -518,6 +552,7 @@ See [examples/README.md](https://github.com/nexform-tech/litearm-python/blob/mai
518
552
  - `02_movej.py` — joint motion
519
553
  - `03_move_p.py` — Cartesian point to point
520
554
  - `04_ik_tcp.py` — inverse kinematics and the current pose
555
+ - `10_local_kinematics.py` — SDK-local FK/IK/Jacobian and guarded pose PTP
521
556
  - `06_cartesian.py` — Cartesian lines / arcs / waypoints
522
557
  - `07_vel_jitter_trace.py` — 300 Hz per-tick capture
523
558
 
@@ -532,33 +567,16 @@ python3 examples/01_hello.py
532
567
 
533
568
  ## Development
534
569
 
535
- ```bash
536
- pip install -e ".[dev]"
537
- pytest # full offline run, never touches hardware
538
- LITEARM_LIVE=1 pytest # plus hardware tests, moves a little
539
- ```
540
-
541
- Running the tests does not require installing the package; `tests/conftest.py` sets `sys.path`
542
- itself. Do not set `LITEARM_LIVE` with nobody present, and never call `enter_dfu()` /
543
- `reset_factory()`.
544
-
545
- **On a machine with ROS 2 installed, `pytest` dies during collection and none of this repository
546
- is involved**: pytest auto-loads the plugins under `/opt/ros/...` by entry point, and `launch`
547
- needs `lark`, which is not installed:
548
-
549
- ```
550
- ModuleNotFoundError: No module named 'lark'
551
- ```
552
-
553
- A virtualenv does not stop it — `PYTHONPATH` takes priority over the venv's `site-packages`.
554
- Either of these works:
570
+ This repository does not ship a test suite. Verify a change with a minimal smoke check:
555
571
 
556
572
  ```bash
557
- PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest
558
- env -u PYTHONPATH pytest
573
+ pip install -e .
574
+ python3 -c "import litearm; print(litearm.__version__)"
575
+ python3 -m build # after pip install build
559
576
  ```
560
577
 
561
- `-p no:launch_testing` is **not** enough: the `launch_ros` entry point gets loaded anyway.
578
+ `litearm.testing.FakeTransport` is still shipped. To write your own offline tests, replace
579
+ `SerialTransport` with it; no hardware is needed.
562
580
 
563
581
  On Windows use `env.ps1` / `env.cmd` and `run_example.ps1` / `run_example.cmd`.
564
582
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "litearm-python"
7
- version = "1.3.0"
7
+ version = "1.4.0"
8
8
  description = "Python SDK for the LiteArm robotic arm"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -29,7 +29,9 @@ classifiers = [
29
29
  dependencies = ["pyserial>=3.4"]
30
30
 
31
31
  [project.optional-dependencies]
32
- dev = ["pytest>=7"]
32
+ collision = ["numpy>=1.23", "pin>=3.0"]
33
+ ik = ["numpy>=1.23", "scipy>=1.9"]
34
+ robotics = ["numpy>=1.23", "scipy>=1.9", "pin>=3.0"]
33
35
 
34
36
  [project.urls]
35
37
  Repository = "https://github.com/nexform-tech/litearm-python"
@@ -39,11 +41,12 @@ Documentation = "https://github.com/nexform-tech/litearm-python/blob/main/docs/D
39
41
  [project.scripts]
40
42
  litearm-python = "litearm.arm:main"
41
43
 
42
- [tool.pytest.ini_options]
43
- testpaths = ["tests"]
44
-
45
44
  [tool.setuptools.packages.find]
46
45
  where = ["src"]
47
46
 
48
47
  [tool.setuptools.package-data]
49
- litearm = ["py.typed"]
48
+ litearm = [
49
+ "py.typed",
50
+ "assets/litearm/urdf/*.urdf",
51
+ "assets/litearm/meshes/*.STL",
52
+ ]
@@ -1,8 +1,8 @@
1
- """litearm-python —— LiteArm STM32 直连后端 (薄协议 SDK)。
1
+ """litearm-python —— LiteArm STM32 直连 SDK。
2
2
 
3
- 定位: 固件(litearm-stm32, 版本约定 ``Litearm1.5.0``+)已内置 S 曲线/IK/动力学/
4
- 控制律, 本包直连 USB CDC 用高层子集镜像 pylitearm 常用用法, **不改 pylitearm 源码**、
5
- PC 端不做轨迹/运动学。
3
+ 定位: 固件(litearm-stm32, 版本约定 ``Litearm1.5.0``+)内置 S 曲线/IK/动力学/控制律;
4
+ 本包直连 USB CDC,并可选提供基于随包 URDF 的本地 FK/IK/Jacobian 与安全 PTP 预检。
5
+ 固件仍负责最终的速度、加速度、jerk 约束和同步 S 曲线执行。
6
6
 
7
7
  典型用法::
8
8
 
@@ -24,8 +24,9 @@ PC 端不做轨迹/运动学。
24
24
  `diag.kin_bench`) 返回它 —— `value` 是原返回值, `hz` 是该类帧在本会话里的平均到达频率,
25
25
  `timestamp` 是最近一帧的本地时刻。`move_*`/`home` (动作结果) 与纯本地量不包。
26
26
 
27
- **笛卡尔运动** 只有固件规划一条路: `move_l` / `move_c` / `move_path` —— 采样/逐点 IK/播放
28
- 全在固件里, PC 只发点、收 `0x4E` 结果帧, 返回 `CartPlan`。
27
+ **笛卡尔路径** `move_l` / `move_c` / `move_path` 仍由固件规划。另一条互不冲突的入口是
28
+ `arm.kinematics.move_pose()`:SDK 本地求 IK 并检查整条关节直线,然后只发送一条
29
+ `CMD_MOVE_J_SYNC`,由固件执行同步 PTP;它不保证末端走笛卡尔直线。
29
30
 
30
31
  ⚠ 2.0 起**移除了 PC 侧规划**: 原子包 `cartesian/` 与 `Cartesian` / `CartesianPlanner` /
31
32
  `MotionResult` / `arm.cartesian` / `movel` / `movec` 都不再存在, 替代是上面三个入口
@@ -34,9 +35,9 @@ PC 端不做轨迹/运动学。
34
35
  ⚠ `move_p` (`0x02`) 是**关节空间**点到点, 与上面这些**笛卡尔**路径不是一回事: 它只收
35
36
  单个位姿 (多路点是 `move_path`), 末端轨迹不保证 (实测 30mm 的目标末端横摆 17.6mm)。
36
37
 
37
- 能力边界(刻意不做): 任意关节角 fk(q) —— 固件 `CMD_GET_TCP` 只能算**当前反馈 q** 的
38
- 位姿, 没有"给 q 求位姿"的下行命令, 所以拿不到任意构型的 FK (连带影响: 起点奇异预检
39
- σmin 算不了); 阻抗控制 —— 高级场景走 pylitearm+server。
38
+ 接口边界: `Arm.ik()` / `Arm.get_tcp()` 保持为固件远程计算;任意构型的本地
39
+ FK/IK/Jacobian 放在 `arm.kinematics`,微分速度 IK 放在 `litearm.exact_ik`。阻抗控制仍不
40
+ 在本包范围内。安全 PTP 只检查自碰,不检测工作台、人员或外部障碍物。
40
41
 
41
42
  工具点 (TCP) 偏移是**宿主侧**的一层换算: 固件没有工具坐标系命令, `get_tcp()` 恒为法兰,
42
43
  所以 `set_tcp_offset(xyz, rpy)` 只在 SDK 里把 `move_p`/`move_l`/`move_c`/`move_path`/`ik`
@@ -48,20 +49,21 @@ PC 端不做轨迹/运动学。
48
49
  (`0x39` 收任意 `q`, 配合临时 `set_payload`) 现算 ⇒ 仍然**不需要** PC 侧任何动力学模型。
49
50
  产物直接喂 `set_payload()`。
50
51
 
51
- 依赖边界(刻意保持): 只有 `pyserial`。PC 侧不做规划, 只用**纯 Python** 数学(`math` 模块,
52
- 见 `_rot.py` / `payload.py`)归一化位姿形态、判到位姿态、解 4 参数最小二乘, 不引入
53
- numpy/pinocchio —— 重型计算本来就在固件的 IK 与 RNEA 里。
52
+ 依赖边界: 默认安装仍只有 `pyserial`。`arm.kinematics` 与碰撞检测属于可选的
53
+ `robotics` 依赖组(NumPy、SciPy、Pinocchio/hpp-fcl);没有安装时只在调用这些入口时给出
54
+ 明确提示,不影响轻量串口功能。
54
55
 
55
56
  协议覆盖: 固件 `hal/usb_cmd.h` 里每条**已实现**的下行命令都有对应入口
56
57
  (`arm.params.*` 关节级参数 / `arm.log.*` 300Hz 采集 / `arm.diag.kin_bench` 自检);
57
- 覆盖契约见 `_protocol.COMMAND_COVERAGE`, 由 `tests/test_protocol_sync.py` 直接解析
58
- 固件头文件强制。命令不被本机固件支持时抛 `UnsupportedByFirmwareError`。
58
+ 覆盖契约见 `_protocol.COMMAND_COVERAGE`。命令不被本机固件支持时抛
59
+ `UnsupportedByFirmwareError`。
59
60
 
60
61
  零重力拖动示教见 `Arm.zero_g()` —— 返回上下文管理器, 保活由后台线程自动维持。
61
62
  """
62
63
  from litearm.arm import (Arm, FIRMWARE_PREFIX, LicenseInfo, main, MIN_FW, Msg)
63
64
  from litearm._rot import as_pose, mat_to_rpy, rpy_to_mat
64
65
  from litearm.cart import CartPlan
66
+ from litearm.collision import CollisionModel, collision_urdf_path
65
67
  from litearm.diagnostics import KinBenchResult, parse_kin_bench
66
68
  from litearm.errors import (
67
69
  ArmIsInDfuError,
@@ -85,6 +87,8 @@ from litearm.errors import (
85
87
  UnsupportedByFirmwareError,
86
88
  )
87
89
  from litearm.log import LogReader, LogSample, parse_samples
90
+ from litearm.kinematics import (IKSolution, JacobianResult, Kinematics,
91
+ LocalKinematicsError)
88
92
  from litearm.model import (MODEL_MASK_WRITTEN, ModelParams, ModelStatus)
89
93
  from litearm.params import JointParam, JointParams
90
94
  from litearm.payload import Baseline, HoldSample, PayloadResult
@@ -92,7 +96,7 @@ from litearm.state import JointState, RobotState
92
96
  from litearm.tool import TcpOffset
93
97
  from litearm.transport import find_cdc_port
94
98
 
95
- __version__ = "1.3.0"
99
+ __version__ = "1.4.0"
96
100
 
97
101
  __all__ = [
98
102
  "Arm", "Msg", "LicenseInfo", "RobotState", "JointState", "find_cdc_port", "main",
@@ -105,6 +109,8 @@ __all__ = [
105
109
  "NotRemoteable", "NotSupportedOnThisBackend",
106
110
  "TeleopLockedError", "TeleopBusyError",
107
111
  "CartPlan",
112
+ "CollisionModel", "collision_urdf_path",
113
+ "Kinematics", "JacobianResult", "IKSolution", "LocalKinematicsError",
108
114
  "JointParam", "JointParams", "ModelParams", "ModelStatus", "MODEL_MASK_WRITTEN",
109
115
  "LogSample", "LogReader", "parse_samples",
110
116
  "KinBenchResult", "parse_kin_bench",
@@ -156,9 +156,9 @@ RSP_STATUS = 0x40
156
156
  # ② 与下行 `CMD_GET_FIRMWARE 0x41` **撞号** —— 同 `0x49` (CMD_KIN_BENCH / RSP_JOINT_PARAM)
157
157
  # 那类"双 ID": 收发方向不同, 靠方向区分, 不可用单张 ID 表查。
158
158
  #
159
- # ⚠ **为什么保留而不删**: `test_protocol_sync.py::test_every_firmware_rsp_has_sdk_constant`
160
- # 按**名字**遍历固件头的 `RSP_*`, 固件头里那一行还在 ⇒ **删 SDK 常量会让段三验收立刻红**;
161
- # 而且 0x41 属**固件仓**的决定, 本轮是纯 SDK/文档侧 (spec §8)。
159
+ # ⚠ **为什么保留而不删**: 当年按**名字**遍历固件头的 `RSP_*` 做双向比对, 固件头里那一行
160
+ # 还在 ⇒ 删 SDK 常量会让那条检查失败; 而且 0x41 属**固件仓**的决定, 本轮是纯
161
+ # SDK/文档侧 (spec §8)。仓库已无测试套件, 但常量本身仍应与固件头对齐。
162
162
  # ⚠ **别说成"没有别的豁免路径"**: 机制上当然可以再往 `FIRMWARE_ONLY_RSPS` 添一项来豁免它;
163
163
  # **不这么做是设计选择** —— 那张表的语义是"用户裁决 SDK **有意不暴露**" ("不做", 不是
164
164
  # "还没做"), 把一条**没人发**的应答塞进去语义不符 (同理见 `PREEXISTING_GAPS` 的注释)。
@@ -188,7 +188,7 @@ RSP_CART_PLAN = 0x4E
188
188
  RSP_LICENSE = 0x4F
189
189
  #: [授权] **本版无生产者** —— 激活成功回的是 `ACK{0x3F}`(见 `CMD_ACTIVATE`),
190
190
  #: 故固件里**没有任何代码会发出** 0x50; 该号只被占住。
191
- #: ⚠ 保留定义是为了让 `test_protocol_sync` 的按名比对自然通过 —— **不要**给它造生产者,
191
+ #: ⚠ 保留定义是为了让按名比对固件头时自然通过 —— **不要**给它造生产者,
192
192
  #: 也不要塞进 `FIRMWARE_ONLY_RSPS` (那张表的语义是"SDK 有意不暴露", 与"固件没有生产者"不同)。
193
193
  RSP_ACTIVATE = 0x50
194
194
 
@@ -200,7 +200,7 @@ RSP_GRAVITY = 0x57 # [0x57, G(q)[7]] = 29B
200
200
  # ---- [2026-09-14] 动力学模型在线导入 (0x30/0x32/0x33/0x34/0x35/0x37/0x38/0x39) ----
201
201
  # 固件侧三层语义 (bank/staging/生效层) 与完整注释见 litearm-stm32 的
202
202
  # User/litearm/hal/usb_cmd.h; SDK 封装见 litearm/model.py。
203
- # ⚠ 常量名必须与固件头**逐字相同** —— test_protocol_sync 按名字双向比对。
203
+ # ⚠ 常量名必须与固件头**逐字相同** —— 协议同步靠人工按名字双向比对。
204
204
 
205
205
  # ff_mask 位 (固件 litearm.h)
206
206
  FF_MASTER = 0x0001
@@ -224,10 +224,10 @@ KIN_N = 7
224
224
  #: (joint_cfg.h 顶部三条理由, 其中 ② 是 flash 布局随开关变却不 bump
225
225
  #: `FLASH_STORE_VERSION` ⇒ **静默丢现场标定**; 另有防"再打开"的 `#error` 硬守卫)。
226
226
  #: ⇒ 当前固件**不再定义**这个宏, 本常量只服务**仍要支持的 1J 老固件**
227
- #: (`Litearm1.7.0-1J`, 见 `tests/test_ik_bench.py` / `conftest.offline_arm_1j`)。
227
+ #: (`Litearm1.7.0-1J`; 离线可用 `FakeTransport(n=1)` 复现)。
228
228
  #: **不要当成死代码删掉** —— 删了 1J 会话的 IK 种子就会填错轴。
229
- #: 跨仓一致性由 tests/test_protocol_sync.py::test_bench_model_axis_matches_sdk_constant
230
- #: 守: 固件仍有该宏则逐值比对, 固件已移除则断言守卫在 + 本常量仍在。
229
+ #: 跨仓一致性需**人工**核对: 固件仍有该宏时逐值比对; 固件已移除时本常量仍须保留
230
+ #: (仓库已无测试套件来守这条)。
231
231
  BENCH_MODEL_AXIS = 5
232
232
 
233
233
  #: 固件**状态帧频率** (Hz)。`RSP_STATUS` 是被动连续流, 固定 100 Hz (10 ms) ——
@@ -266,19 +266,16 @@ def parse_boot_banner(text: str) -> Optional[str]:
266
266
  return "iwdg-rst" if "iwdg-rst" in hits[-1] else "normal"
267
267
 
268
268
 
269
- #: 「协议无死角」契约: 固件每条**已实现**的下行命令 -> SDK 上的一等方法入口。
270
- #: 由 `tests/test_protocol_sync.py` 强制: 直接解析固件 `hal/usb_cmd.h`, 双向比对
271
- #: 命令集合与 ID, 并逐条断言这里的入口在 `Arm` 上真的可解析到。少一条命令就红。
272
269
  #: **请求 → 它的那条 `RSP_*` 应答**(只列"应答不是 `ACK`/`ERR`"的命令)。
273
- #: ⚠ **名字刻意不叫 `CMD_*`**:`tests/test_protocol_sync.py` 把所有 `CMD_` 前缀的
274
- #: 模块级名字当成**命令码常量**去和固件头对表,叫 `CMD_TO_RSP` 会被判成
275
- #: "SDK 声明了固件没有的命令"(实测踩过)。
270
+ #: ⚠ **名字刻意不叫 `CMD_*`**:历史测试曾把所有 `CMD_` 前缀的模块级名字当成
271
+ #: **命令码常量**去和固件头对表, 叫 `CMD_TO_RSP` 会被判成"SDK 声明了固件没有的命令"
272
+ #: (实测踩过);这个命名禁忌仍值得保留, 免得以后重新加检查时再踩。
276
273
  #:
277
274
  #: 唯一的用途是 `Arm._raw_write` 在**发出前**清掉本命令的应答队列(见那里)——
278
275
  #: `ACK`/`ERR` 两条由命令码自己就能推出来,故**不在这张表里**。
279
276
  #: ⚠ `0x40` (`GET_STATUS`) 也不在:它的应答是 `RSP_STATUS`,走的是**单槽**不是队列。
280
- #: ⚠ 与固件的对应关系逐条抄自本文件上面各 `CMD_*` 的注释;改固件时这里要跟着改
281
- #: (`tests/test_protocol_sync.py` 会盯 `CMD_*`/`RSP_*` 常量本身,这张表**没有**自动判据)。
277
+ #: ⚠ 与固件的对应关系逐条抄自本文件上面各 `CMD_*` 的注释;改固件时这里要跟着改,
278
+ #: 且这张表**没有**自动判据 (仓库已无测试套件)。
282
279
  RSP_OF_CMD = {
283
280
  0x24: 0x49, # GET_JOINT_PARAM -> RSP_JOINT_PARAM
284
281
  0x2B: 0x4B, # GET_FF_VEC -> RSP_FF_VEC
@@ -295,6 +292,9 @@ RSP_OF_CMD = {
295
292
  }
296
293
 
297
294
 
295
+ #: 「协议无死角」契约: 固件每条**已实现**的下行命令 -> SDK 上的一等方法入口。
296
+ #: 仓库已无测试套件, 这张表靠**人工**对照固件 `hal/usb_cmd.h` 维护: 双向核对命令
297
+ #: 集合与 ID, 并确认这里的入口在 `Arm` 上真的可解析到。少一条命令不会有人报红。
298
298
  COMMAND_COVERAGE = {
299
299
  0x01: "Arm.movej",
300
300
  0x07: "Arm.movej_sync",
@@ -364,16 +364,16 @@ UNIMPLEMENTED_CMDS: dict = {}
364
364
  #
365
365
  # 历史: 用户 2026-09-13 一度裁决 SDK **不暴露**笛卡尔运控入口(spec §7.1 选项 A),
366
366
  # 故 `0x3A~0x3E` / `0x4E` 这 6 条曾是"固件有、SDK 无",在这里显式豁免,
367
- # 免得 test_protocol_sync.py 因双向比对而长期红着(哨兵红久了就失去意义)。
367
+ # 免得此后按名比对时被当成"固件有、SDK 无"的缺口。
368
368
  #
369
369
  # [段二] 该裁决已被"固件原生笛卡尔"取代: 5 条命令与那条应答现在都有 SDK 入口与常量
370
370
  # (`COMMAND_COVERAGE` 的 0x3A/0x3B/0x3C/0x3D/0x3E / 本节上方的 `RSP_CART_PLAN`),
371
371
  # 于是两张豁免表**同时清空**。留空是有意的 —— 与 `UNIMPLEMENTED_CMDS` 同一个用法:
372
372
  # 它现在是"当前没有任何固件单边命令"这句话的断言载体, 而不是可以顺手塞东西的地方。
373
373
  #
374
- # ⚠ 与 `test_protocol_sync.py` 的耦合: `test_firmware_only_exemption_is_still_valid`
375
- # 逐个断言"豁免表里的名字在固件头文件里仍然存在、且 SDK **还没有**同名常量"。
376
- # 往这里加条目等于宣布"SDK 有意不做这条命令", 加之前先想清楚是不是真的不做。
374
+ # ⚠ 往这里加条目等于宣布"SDK 有意不做这条命令", 加之前先想清楚是不是真的不做。
375
+ # 仓库已无测试套件; 当年那条逐项断言"豁免表里的名字在固件头文件里仍然存在、且
376
+ # SDK **还没有**同名常量"的检查已移除, 改表时需人工对照固件头。
377
377
  # ⚠ **不要**把"已知缺口"塞进来: 那是 `PREEXISTING_GAPS` 的语义(本应同步而未同步),
378
378
  # 两者的理由不同, 混在一起会让读的人以为缺口是有意为之。
379
379
  # ---------------------------------------------------------------------------
@@ -388,18 +388,17 @@ FIRMWARE_ONLY_RSPS: dict = {}
388
388
  # 【既有的固件/SDK 不同步 —— **只豁免, 不修复**】(**现已清空**)
389
389
  #
390
390
  # 历史: 固件自 `b6cbc33`(DFU 免探针烧录)起有 `CMD_ENTER_DFU = 0x15`, 而 SDK 侧
391
- # `grep -ri dfu src/ tests/` **命中 0**。当时**豁免而非修复**的理由三条:
391
+ # `grep -ri dfu src/` **命中 0**(当时也扫过 tests/)。当时**豁免而非修复**的理由三条:
392
392
  # ① 它不是那一笔的产物(修它等于把另一个特性的决定塞进去);
393
393
  # ② 长期红着会让**真正的**回归看不见(哨兵失效, 与 `UNIMPLEMENTED_CMDS` 同一个理由);
394
394
  # ③ DFU 是固件**维护**命令(进 ROM bootloader), 不是运动 API, 豁免语义成立。
395
395
  #
396
396
  # [段三] 该缺口已被**补上**: `0x15` 现在有常量、有入口 (`Arm.enter_dfu`, 两段式:
397
397
  # ACK 之后还要**等设备真的消失**), 并登记进 `COMMAND_COVERAGE` —— 于是本表**清空**,
398
- # 覆盖契约 = **47/47**。留空是有意的, 与 `UNIMPLEMENTED_CMDS` / `FIRMWARE_ONLY_CMDS`
399
- # 同一个用法: 它现在是"**当前没有任何既有的固件/SDK 不同步**"这句话的断言载体,
400
- # 而不是可以顺手塞东西的地方(哨兵 `test_firmware_only_exemption_is_still_valid`
401
- # 对它逐条断言"固件里仍有这条命令、且 SDK **还没有**同名常量" ⇒ 往空表里塞东西前,
402
- # 先确认那件事真的没做)。
398
+ # 当时的覆盖契约 = **47/47** (仓库现已无测试套件, 这条契约需人工维持)。留空是有意的,
399
+ # 与 `UNIMPLEMENTED_CMDS` / `FIRMWARE_ONLY_CMDS` 同一个用法: 它现在是"**当前没有
400
+ # 任何既有的固件/SDK 不同步**"这句话的断言载体, 而不是可以顺手塞东西的地方
401
+ # (往空表里塞东西前, 先确认固件里仍有这条命令、且 SDK **还没有**同名常量)。
403
402
  # ⚠ **两张表的语义不要混**: `FIRMWARE_ONLY_CMDS`/`FIRMWARE_ONLY_RSPS` 的语义是
404
403
  # "用户裁决 SDK **有意不暴露**"("不做", 不是"还没做"; 笛卡尔 0x3A~0x3E / 0x4E 曾是
405
404
  # 那里的例子, 段二已暴露并补上入口, 见本节上方那段历史说明 —— ⚠ 别按行号找, 它会漂);
@@ -427,10 +426,10 @@ def crc16_ccitt_false(data: bytes) -> int:
427
426
  * `crc_hqx` 实测 **232×** 快(68.1 µs → 0.29 µs,同一台机器同一载荷)。
428
427
 
429
428
  ⚠ **等价性不是"看算法像"认定的,是测出来的**:3260 个载荷(长度 0..259 全覆盖 +
430
- 随机)与真帧逐一比对 **0 不一致**;并由 `tests/test_protocol_crc.py` **长期钉住** ——
431
- 那里有一份**独立的纯 Python 参考实现当判据**,另有 CRC 目录的**标准检查值**
432
- (`"123456789"` → `0x29B1`)。**别把那条用例改成拿本函数跟 `crc_hqx` 对拍** ——
433
- 那是自己验自己,判据会失去判别力。
429
+ 随机)与真帧逐一比对 **0 不一致**;当时用一份**独立的纯 Python 参考实现当判据**,
430
+ 另有 CRC 目录的**标准检查值**(`"123456789"` → `0x29B1`)。**别为了"验证"拿本函数
431
+ 跟 `crc_hqx` 对拍** —— 那是自己验自己,判据会失去判别力;仓库已无测试套件,需要
432
+ 复核时请保留独立参考实现。
434
433
  """
435
434
  return binascii.crc_hqx(data, 0xFFFF)
436
435