litearm-python 1.3.0__tar.gz → 1.4.1__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.1}/PKG-INFO +90 -34
  2. litearm_python-1.3.0/src/litearm_python.egg-info/PKG-INFO → litearm_python-1.4.1/README.md +79 -61
  3. {litearm_python-1.3.0 → litearm_python-1.4.1}/pyproject.toml +9 -6
  4. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/__init__.py +21 -15
  5. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/_protocol.py +29 -30
  6. litearm_python-1.4.1/src/litearm/_robot_model.py +146 -0
  7. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/arm.py +82 -35
  8. litearm_python-1.4.1/src/litearm/assets/litearm/meshes/base_link.STL +0 -0
  9. litearm_python-1.4.1/src/litearm/assets/litearm/meshes/ee_link.STL +0 -0
  10. litearm_python-1.4.1/src/litearm/assets/litearm/meshes/joint1.STL +0 -0
  11. litearm_python-1.4.1/src/litearm/assets/litearm/meshes/joint2.STL +0 -0
  12. litearm_python-1.4.1/src/litearm/assets/litearm/meshes/joint3.STL +0 -0
  13. litearm_python-1.4.1/src/litearm/assets/litearm/meshes/joint4.STL +0 -0
  14. litearm_python-1.4.1/src/litearm/assets/litearm/meshes/joint5.STL +0 -0
  15. litearm_python-1.4.1/src/litearm/assets/litearm/meshes/joint6.STL +0 -0
  16. litearm_python-1.4.1/src/litearm/assets/litearm/meshes/joint7.STL +0 -0
  17. litearm_python-1.4.1/src/litearm/assets/litearm/urdf/litearm.urdf +256 -0
  18. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/cart.py +17 -23
  19. litearm_python-1.4.1/src/litearm/collision.py +67 -0
  20. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/errors.py +3 -4
  21. litearm_python-1.4.1/src/litearm/exact_ik.py +215 -0
  22. litearm_python-1.4.1/src/litearm/kinematics.py +370 -0
  23. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/params.py +2 -1
  24. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/payload.py +5 -2
  25. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/state.py +3 -4
  26. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/testing.py +13 -16
  27. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/transport.py +4 -6
  28. litearm_python-1.3.0/README.md → litearm_python-1.4.1/src/litearm_python.egg-info/PKG-INFO +117 -31
  29. litearm_python-1.4.1/src/litearm_python.egg-info/SOURCES.txt +47 -0
  30. litearm_python-1.4.1/src/litearm_python.egg-info/requires.txt +14 -0
  31. litearm_python-1.4.1/tests/test_collision.py +171 -0
  32. litearm_python-1.4.1/tests/test_exact_ik.py +59 -0
  33. litearm_python-1.4.1/tests/test_firmware_model_consistency.py +71 -0
  34. litearm_python-1.4.1/tests/test_local_kinematics.py +187 -0
  35. litearm_python-1.4.1/tests/test_motion_serial.py +101 -0
  36. litearm_python-1.4.1/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.1}/LICENSE +0 -0
  85. {litearm_python-1.3.0 → litearm_python-1.4.1}/setup.cfg +0 -0
  86. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/__main__.py +0 -0
  87. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/_rot.py +0 -0
  88. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/diagnostics.py +0 -0
  89. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/log.py +0 -0
  90. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/model.py +0 -0
  91. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/py.typed +0 -0
  92. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/tool.py +0 -0
  93. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm/transport_tcp.py +0 -0
  94. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm_python.egg-info/dependency_links.txt +0 -0
  95. {litearm_python-1.3.0 → litearm_python-1.4.1}/src/litearm_python.egg-info/entry_points.txt +0 -0
  96. {litearm_python-1.3.0 → litearm_python-1.4.1}/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.1
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,11 +590,12 @@ 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
 
524
- The examples are **read-only by default**; anything that moves needs `--go`. Run them from
525
- the repository root:
597
+ The examples are **read-only by default**; anything that moves needs `--go`. Examples that move
598
+ leave the arm enabled and holding position when they finish. Run them from the repository root:
526
599
 
527
600
  ```bash
528
601
  source env.sh # exports PYTHONPATH / PYTHON_BIN / LITEARM_PORT
@@ -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,11 +552,12 @@ 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
 
524
- The examples are **read-only by default**; anything that moves needs `--go`. Run them from
525
- the repository root:
559
+ The examples are **read-only by default**; anything that moves needs `--go`. Examples that move
560
+ leave the arm enabled and holding position when they finish. Run them from the repository root:
526
561
 
527
562
  ```bash
528
563
  source env.sh # exports PYTHONPATH / PYTHON_BIN / LITEARM_PORT
@@ -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.1"
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.1"
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",