lekit-robot 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lekit_robot-0.1.0/.gitignore +27 -0
- lekit_robot-0.1.0/LICENSE +176 -0
- lekit_robot-0.1.0/PKG-INFO +160 -0
- lekit_robot-0.1.0/README.md +144 -0
- lekit_robot-0.1.0/examples/observe.py +22 -0
- lekit_robot-0.1.0/pyproject.toml +34 -0
- lekit_robot-0.1.0/src/lekit_robot/__init__.py +44 -0
- lekit_robot-0.1.0/src/lekit_robot/observation.py +90 -0
- lekit_robot-0.1.0/src/lekit_robot/protocol.py +254 -0
- lekit_robot-0.1.0/src/lekit_robot/py.typed +0 -0
- lekit_robot-0.1.0/src/lekit_robot/remote.py +374 -0
- lekit_robot-0.1.0/src/lekit_robot/zenoh_client.py +488 -0
- lekit_robot-0.1.0/tests/test_dual.py +88 -0
- lekit_robot-0.1.0/tests/test_sdk_remote.py +245 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
uv.lock
|
|
9
|
+
|
|
10
|
+
# Virtual environments
|
|
11
|
+
.venv
|
|
12
|
+
|
|
13
|
+
# Other files
|
|
14
|
+
data
|
|
15
|
+
data/
|
|
16
|
+
logs/
|
|
17
|
+
outputs/
|
|
18
|
+
tmp/
|
|
19
|
+
|
|
20
|
+
.agents/
|
|
21
|
+
skills-lock.json
|
|
22
|
+
.marscode/
|
|
23
|
+
artifacts/
|
|
24
|
+
.cloudxr/
|
|
25
|
+
.lekit/
|
|
26
|
+
.worktrees/
|
|
27
|
+
.codegraph/
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lekit-robot
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Small Python SDK for observing and controlling Lekit Robot Node
|
|
5
|
+
Project-URL: Repository, https://github.com/sorelferris/lekit
|
|
6
|
+
Project-URL: Issues, https://github.com/sorelferris/lekit/issues
|
|
7
|
+
Author: Sorel Ferris
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Python: >=3.12
|
|
11
|
+
Requires-Dist: eclipse-zenoh<2,>=1.9
|
|
12
|
+
Requires-Dist: numpy<3,>=1.26
|
|
13
|
+
Requires-Dist: pillow<13,>=10
|
|
14
|
+
Requires-Dist: pydantic<3,>=2
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# lekit-robot
|
|
18
|
+
|
|
19
|
+
Small Python SDK for a running **Lekit Robot Node**. Discover a robot by name,
|
|
20
|
+
read joint/pose feedback and RGB/depth images, and send absolute motion targets.
|
|
21
|
+
The client does not install LeRobot, Torch, OpenCV, robot drivers, or camera drivers.
|
|
22
|
+
Python 3.12+ is required.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
After publication:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
pip install lekit-robot
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
From this repository before publication:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
pip install ./packages/lekit_robot
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Robot Node must already be running on the robot computer. Clients need network
|
|
39
|
+
access to its Zenoh peer; the browser's HTTP port 8080 is not the SDK endpoint.
|
|
40
|
+
LAN multicast discovery is the default. If discovery is blocked, configure both
|
|
41
|
+
Node (`lekit-robot --zenoh-router tcp/ROUTER_IP:7447`) and client
|
|
42
|
+
(`connect(name="NERO Dual", router="tcp/ROUTER_IP:7447")`) to use an existing Zenoh router.
|
|
43
|
+
This package does not install the Robot Node command-line server.
|
|
44
|
+
|
|
45
|
+
## Observe (does not acquire control)
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from lekit_robot import connect
|
|
49
|
+
|
|
50
|
+
with connect(name="NERO Dual", timeout=5) as robot:
|
|
51
|
+
obs = robot.get_observation(images=True, timeout=5)
|
|
52
|
+
print(obs.robot.status, obs.robot.state)
|
|
53
|
+
camera = obs.camera(name="head_view")
|
|
54
|
+
if camera.color is not None:
|
|
55
|
+
print(camera.color.shape) # H x W x 3, RGB uint8
|
|
56
|
+
print(robot.descriptor.joint_fields)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`images=False` omits images. `robot.observations(images=False, timeout=5)` yields
|
|
60
|
+
latest-only snapshots. Camera samples have independent capture times; an observation
|
|
61
|
+
is not a hardware-synchronized frame set. Check sample status and capture time.
|
|
62
|
+
Depth is a uint16 array in the server's camera units, not automatically metres.
|
|
63
|
+
|
|
64
|
+
## Control
|
|
65
|
+
|
|
66
|
+
Control requires enabled motors, `allow_control=True`, fresh feedback, normal mode,
|
|
67
|
+
and no emergency stop. Close Teleop before acquiring external control. The context
|
|
68
|
+
manager holds and renews an exclusive control lease and releases it on exit.
|
|
69
|
+
Multiple clients may observe; only one controller may own the lease.
|
|
70
|
+
|
|
71
|
+
The following function sends a real motion command **when called**:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from lekit_robot import connect
|
|
75
|
+
|
|
76
|
+
def move_left_joint3(delta_rad):
|
|
77
|
+
with connect(name="NERO Dual") as robot:
|
|
78
|
+
with robot.control():
|
|
79
|
+
obs = robot.get_observation(images=False)
|
|
80
|
+
state = obs.robot.state
|
|
81
|
+
if obs.robot.status != "connected" or not state or not state.get("left.feedback_fresh"):
|
|
82
|
+
raise RuntimeError("Fresh left arm feedback is required")
|
|
83
|
+
joints = [state[f"left.joint_{i}"] for i in range(1, 8)]
|
|
84
|
+
joints[2] += delta_rad
|
|
85
|
+
return robot.set_joints(joints, side="left")
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
| Method | Target |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| `set_joints(values, side=None, timeout=None)` | Absolute joint values in advertised order, or a mapping with full field names |
|
|
91
|
+
| `set_target(values, side=None, mode="point", timeout=None)` | Absolute flange/EEF pose in advertised order, or a full-key mapping |
|
|
92
|
+
| `set_target(x=..., y=..., z=..., roll=..., pitch=..., yaw=..., side="left")` | One arm's complete pose |
|
|
93
|
+
| `set_gripper(width, side="left", timeout=None)` | One gripper's absolute opening |
|
|
94
|
+
| `set_gripper(values, timeout=None)` | All grippers, in advertised order or full-key mapping |
|
|
95
|
+
|
|
96
|
+
For NERO Dual, `left` is can1 and `right` is can0. Joint/rotation units are radians;
|
|
97
|
+
position and gripper width units are metres. Pose fields represent the flange in
|
|
98
|
+
that arm's base frame. For other robots use the plugin-declared field semantics.
|
|
99
|
+
`side` selects only that arm; the other arm receives no target. Without `side`,
|
|
100
|
+
provide the complete advertised target (14 joint values or 12 pose values for NERO).
|
|
101
|
+
A scalar gripper width requires `side` on a dual-arm robot. There is no implicit
|
|
102
|
+
broadcast of one pose or gripper value to both arms.
|
|
103
|
+
|
|
104
|
+
NERO uses firmware-planned point targets. `stream` replaces targets through the
|
|
105
|
+
same backend; it does not guarantee a hard realtime servo or a straight path.
|
|
106
|
+
Unsupported modes, partial targets and out-of-range values are rejected.
|
|
107
|
+
|
|
108
|
+
A receipt acknowledges command submission, **not arrival or successful IK**.
|
|
109
|
+
Continue observing measured state and alarms. `ActionOutcomeUnknownError` means a
|
|
110
|
+
command may already have executed: do not retry it automatically. A control lease
|
|
111
|
+
is ownership arbitration, not a hardware emergency stop or a stop-on-disconnect guarantee.
|
|
112
|
+
Use the Robot Node emergency stop or physical stop as appropriate.
|
|
113
|
+
|
|
114
|
+
## Compatibility
|
|
115
|
+
|
|
116
|
+
The wire protocol remains `lekit/v1`. New clients opt into the gripper manifest
|
|
117
|
+
extension; old clients continue to receive the original manifest shape. An old
|
|
118
|
+
Node can still supply observations and existing targets, but gripper commands need
|
|
119
|
+
an updated Node; unsupported grippers raise `UnsupportedCommandError` locally.
|
|
120
|
+
Per-arm commands also require the updated Node validation. Update client and Node
|
|
121
|
+
together for complete NERO Dual support. Reconnect after replacing the Node or its
|
|
122
|
+
robot configuration; the SDK never silently rebinds an existing control session.
|
|
123
|
+
|
|
124
|
+
Existing applications may keep `from lekit.robot import connect` when the main
|
|
125
|
+
project is installed: those imports re-export this package's implementation.
|
|
126
|
+
|
|
127
|
+
## Build and release
|
|
128
|
+
|
|
129
|
+
From `packages/lekit_robot`:
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
python -m pip install build twine
|
|
133
|
+
python -m build
|
|
134
|
+
python -m twine check dist/*
|
|
135
|
+
python -m twine upload --repository testpypi dist/*
|
|
136
|
+
# After testing the installed wheel in a clean environment:
|
|
137
|
+
python -m twine upload dist/*
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Publishing needs a PyPI account and an API token or configured Trusted Publisher.
|
|
141
|
+
Never store credentials in source files. Version 0.1.0 is the initial release;
|
|
142
|
+
subsequent releases must use a new version number.
|
|
143
|
+
|
|
144
|
+
License: Apache-2.0, matching the repository's existing standalone package convention.
|
|
145
|
+
|
|
146
|
+
A build/test and manual publishing workflow is provided at
|
|
147
|
+
`.github/workflows/lekit-robot-release.yml`. It installs the built wheel in an
|
|
148
|
+
isolated environment before testing. Pushes and pull requests only build/test.
|
|
149
|
+
After the workflow is committed to the default branch, configure a PyPI pending
|
|
150
|
+
Trusted Publisher for a new project:
|
|
151
|
+
|
|
152
|
+
- Project: `lekit-robot`
|
|
153
|
+
- Owner: `sorelferris`
|
|
154
|
+
- Repository: `lekit`
|
|
155
|
+
- Workflow: `lekit-robot-release.yml`
|
|
156
|
+
- Environment: `pypi` (or `testpypi` on TestPyPI)
|
|
157
|
+
|
|
158
|
+
Then run the workflow manually, selecting `testpypi` first, and `pypi` for the
|
|
159
|
+
release. Configure the two registries separately. This avoids storing a long-lived
|
|
160
|
+
PyPI token. See https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# lekit-robot
|
|
2
|
+
|
|
3
|
+
Small Python SDK for a running **Lekit Robot Node**. Discover a robot by name,
|
|
4
|
+
read joint/pose feedback and RGB/depth images, and send absolute motion targets.
|
|
5
|
+
The client does not install LeRobot, Torch, OpenCV, robot drivers, or camera drivers.
|
|
6
|
+
Python 3.12+ is required.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
After publication:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
pip install lekit-robot
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
From this repository before publication:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pip install ./packages/lekit_robot
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Robot Node must already be running on the robot computer. Clients need network
|
|
23
|
+
access to its Zenoh peer; the browser's HTTP port 8080 is not the SDK endpoint.
|
|
24
|
+
LAN multicast discovery is the default. If discovery is blocked, configure both
|
|
25
|
+
Node (`lekit-robot --zenoh-router tcp/ROUTER_IP:7447`) and client
|
|
26
|
+
(`connect(name="NERO Dual", router="tcp/ROUTER_IP:7447")`) to use an existing Zenoh router.
|
|
27
|
+
This package does not install the Robot Node command-line server.
|
|
28
|
+
|
|
29
|
+
## Observe (does not acquire control)
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from lekit_robot import connect
|
|
33
|
+
|
|
34
|
+
with connect(name="NERO Dual", timeout=5) as robot:
|
|
35
|
+
obs = robot.get_observation(images=True, timeout=5)
|
|
36
|
+
print(obs.robot.status, obs.robot.state)
|
|
37
|
+
camera = obs.camera(name="head_view")
|
|
38
|
+
if camera.color is not None:
|
|
39
|
+
print(camera.color.shape) # H x W x 3, RGB uint8
|
|
40
|
+
print(robot.descriptor.joint_fields)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`images=False` omits images. `robot.observations(images=False, timeout=5)` yields
|
|
44
|
+
latest-only snapshots. Camera samples have independent capture times; an observation
|
|
45
|
+
is not a hardware-synchronized frame set. Check sample status and capture time.
|
|
46
|
+
Depth is a uint16 array in the server's camera units, not automatically metres.
|
|
47
|
+
|
|
48
|
+
## Control
|
|
49
|
+
|
|
50
|
+
Control requires enabled motors, `allow_control=True`, fresh feedback, normal mode,
|
|
51
|
+
and no emergency stop. Close Teleop before acquiring external control. The context
|
|
52
|
+
manager holds and renews an exclusive control lease and releases it on exit.
|
|
53
|
+
Multiple clients may observe; only one controller may own the lease.
|
|
54
|
+
|
|
55
|
+
The following function sends a real motion command **when called**:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from lekit_robot import connect
|
|
59
|
+
|
|
60
|
+
def move_left_joint3(delta_rad):
|
|
61
|
+
with connect(name="NERO Dual") as robot:
|
|
62
|
+
with robot.control():
|
|
63
|
+
obs = robot.get_observation(images=False)
|
|
64
|
+
state = obs.robot.state
|
|
65
|
+
if obs.robot.status != "connected" or not state or not state.get("left.feedback_fresh"):
|
|
66
|
+
raise RuntimeError("Fresh left arm feedback is required")
|
|
67
|
+
joints = [state[f"left.joint_{i}"] for i in range(1, 8)]
|
|
68
|
+
joints[2] += delta_rad
|
|
69
|
+
return robot.set_joints(joints, side="left")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
| Method | Target |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `set_joints(values, side=None, timeout=None)` | Absolute joint values in advertised order, or a mapping with full field names |
|
|
75
|
+
| `set_target(values, side=None, mode="point", timeout=None)` | Absolute flange/EEF pose in advertised order, or a full-key mapping |
|
|
76
|
+
| `set_target(x=..., y=..., z=..., roll=..., pitch=..., yaw=..., side="left")` | One arm's complete pose |
|
|
77
|
+
| `set_gripper(width, side="left", timeout=None)` | One gripper's absolute opening |
|
|
78
|
+
| `set_gripper(values, timeout=None)` | All grippers, in advertised order or full-key mapping |
|
|
79
|
+
|
|
80
|
+
For NERO Dual, `left` is can1 and `right` is can0. Joint/rotation units are radians;
|
|
81
|
+
position and gripper width units are metres. Pose fields represent the flange in
|
|
82
|
+
that arm's base frame. For other robots use the plugin-declared field semantics.
|
|
83
|
+
`side` selects only that arm; the other arm receives no target. Without `side`,
|
|
84
|
+
provide the complete advertised target (14 joint values or 12 pose values for NERO).
|
|
85
|
+
A scalar gripper width requires `side` on a dual-arm robot. There is no implicit
|
|
86
|
+
broadcast of one pose or gripper value to both arms.
|
|
87
|
+
|
|
88
|
+
NERO uses firmware-planned point targets. `stream` replaces targets through the
|
|
89
|
+
same backend; it does not guarantee a hard realtime servo or a straight path.
|
|
90
|
+
Unsupported modes, partial targets and out-of-range values are rejected.
|
|
91
|
+
|
|
92
|
+
A receipt acknowledges command submission, **not arrival or successful IK**.
|
|
93
|
+
Continue observing measured state and alarms. `ActionOutcomeUnknownError` means a
|
|
94
|
+
command may already have executed: do not retry it automatically. A control lease
|
|
95
|
+
is ownership arbitration, not a hardware emergency stop or a stop-on-disconnect guarantee.
|
|
96
|
+
Use the Robot Node emergency stop or physical stop as appropriate.
|
|
97
|
+
|
|
98
|
+
## Compatibility
|
|
99
|
+
|
|
100
|
+
The wire protocol remains `lekit/v1`. New clients opt into the gripper manifest
|
|
101
|
+
extension; old clients continue to receive the original manifest shape. An old
|
|
102
|
+
Node can still supply observations and existing targets, but gripper commands need
|
|
103
|
+
an updated Node; unsupported grippers raise `UnsupportedCommandError` locally.
|
|
104
|
+
Per-arm commands also require the updated Node validation. Update client and Node
|
|
105
|
+
together for complete NERO Dual support. Reconnect after replacing the Node or its
|
|
106
|
+
robot configuration; the SDK never silently rebinds an existing control session.
|
|
107
|
+
|
|
108
|
+
Existing applications may keep `from lekit.robot import connect` when the main
|
|
109
|
+
project is installed: those imports re-export this package's implementation.
|
|
110
|
+
|
|
111
|
+
## Build and release
|
|
112
|
+
|
|
113
|
+
From `packages/lekit_robot`:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
python -m pip install build twine
|
|
117
|
+
python -m build
|
|
118
|
+
python -m twine check dist/*
|
|
119
|
+
python -m twine upload --repository testpypi dist/*
|
|
120
|
+
# After testing the installed wheel in a clean environment:
|
|
121
|
+
python -m twine upload dist/*
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Publishing needs a PyPI account and an API token or configured Trusted Publisher.
|
|
125
|
+
Never store credentials in source files. Version 0.1.0 is the initial release;
|
|
126
|
+
subsequent releases must use a new version number.
|
|
127
|
+
|
|
128
|
+
License: Apache-2.0, matching the repository's existing standalone package convention.
|
|
129
|
+
|
|
130
|
+
A build/test and manual publishing workflow is provided at
|
|
131
|
+
`.github/workflows/lekit-robot-release.yml`. It installs the built wheel in an
|
|
132
|
+
isolated environment before testing. Pushes and pull requests only build/test.
|
|
133
|
+
After the workflow is committed to the default branch, configure a PyPI pending
|
|
134
|
+
Trusted Publisher for a new project:
|
|
135
|
+
|
|
136
|
+
- Project: `lekit-robot`
|
|
137
|
+
- Owner: `sorelferris`
|
|
138
|
+
- Repository: `lekit`
|
|
139
|
+
- Workflow: `lekit-robot-release.yml`
|
|
140
|
+
- Environment: `pypi` (or `testpypi` on TestPyPI)
|
|
141
|
+
|
|
142
|
+
Then run the workflow manually, selecting `testpypi` first, and `pypi` for the
|
|
143
|
+
release. Configure the two registries separately. This avoids storing a long-lived
|
|
144
|
+
PyPI token. See https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Read state and images without acquiring control or sending motion."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
|
|
5
|
+
from lekit_robot import connect
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main():
|
|
9
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
10
|
+
parser.add_argument("--name", required=True)
|
|
11
|
+
parser.add_argument("--router")
|
|
12
|
+
parser.add_argument("--no-images", action="store_true")
|
|
13
|
+
args = parser.parse_args()
|
|
14
|
+
with connect(name=args.name, router=args.router, timeout=5) as robot:
|
|
15
|
+
observation = robot.get_observation(images=not args.no_images, timeout=5)
|
|
16
|
+
print(observation.robot.status, observation.robot.state)
|
|
17
|
+
for camera in observation.cameras.values():
|
|
18
|
+
print(camera.name, camera.status, None if camera.color is None else camera.color.shape)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if __name__ == "__main__":
|
|
22
|
+
main()
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "lekit-robot"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Small Python SDK for observing and controlling Lekit Robot Node"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Sorel Ferris" }]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"numpy>=1.26,<3",
|
|
16
|
+
"pydantic>=2,<3",
|
|
17
|
+
"eclipse-zenoh>=1.9,<2",
|
|
18
|
+
"Pillow>=10,<13",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Repository = "https://github.com/sorelferris/lekit"
|
|
23
|
+
Issues = "https://github.com/sorelferris/lekit/issues"
|
|
24
|
+
|
|
25
|
+
[tool.hatch.build.targets.wheel]
|
|
26
|
+
packages = ["src/lekit_robot"]
|
|
27
|
+
core-metadata-version = "2.4"
|
|
28
|
+
|
|
29
|
+
[tool.hatch.build.targets.sdist]
|
|
30
|
+
include = ["/LICENSE", "/README.md", "/pyproject.toml", "/src", "/tests", "/examples"]
|
|
31
|
+
core-metadata-version = "2.4"
|
|
32
|
+
|
|
33
|
+
[tool.pytest.ini_options]
|
|
34
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Public local and remote Robot interfaces."""
|
|
2
|
+
|
|
3
|
+
from .observation import CameraObservation, Observation, ObservationStatus, RobotObservation
|
|
4
|
+
from .remote import (
|
|
5
|
+
ActionMode,
|
|
6
|
+
ActionOutcomeUnknownError,
|
|
7
|
+
ActionReceipt,
|
|
8
|
+
ActionRejectedError,
|
|
9
|
+
AmbiguousRobotNameError,
|
|
10
|
+
ControlBusyError,
|
|
11
|
+
InvalidTargetError,
|
|
12
|
+
RemoteRobot,
|
|
13
|
+
RobotClientError,
|
|
14
|
+
RobotDescriptor,
|
|
15
|
+
RobotDisconnectedError,
|
|
16
|
+
RobotIdentityConflictError,
|
|
17
|
+
RobotNotFoundError,
|
|
18
|
+
TransportUnavailableError,
|
|
19
|
+
UnsupportedCommandError,
|
|
20
|
+
connect,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"ActionMode",
|
|
25
|
+
"ActionOutcomeUnknownError",
|
|
26
|
+
"ActionReceipt",
|
|
27
|
+
"ActionRejectedError",
|
|
28
|
+
"AmbiguousRobotNameError",
|
|
29
|
+
"CameraObservation",
|
|
30
|
+
"ControlBusyError",
|
|
31
|
+
"InvalidTargetError",
|
|
32
|
+
"Observation",
|
|
33
|
+
"ObservationStatus",
|
|
34
|
+
"RemoteRobot",
|
|
35
|
+
"RobotClientError",
|
|
36
|
+
"RobotDescriptor",
|
|
37
|
+
"RobotDisconnectedError",
|
|
38
|
+
"RobotIdentityConflictError",
|
|
39
|
+
"RobotNotFoundError",
|
|
40
|
+
"RobotObservation",
|
|
41
|
+
"TransportUnavailableError",
|
|
42
|
+
"UnsupportedCommandError",
|
|
43
|
+
"connect",
|
|
44
|
+
]
|