openarm-control 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.
- openarm_control-0.1.0/LICENSE.txt +202 -0
- openarm_control-0.1.0/PKG-INFO +81 -0
- openarm_control-0.1.0/README.md +62 -0
- openarm_control-0.1.0/pyproject.toml +54 -0
- openarm_control-0.1.0/setup.cfg +4 -0
- openarm_control-0.1.0/src/openarm_control/__init__.py +41 -0
- openarm_control-0.1.0/src/openarm_control/config.py +195 -0
- openarm_control-0.1.0/src/openarm_control/kinematics.py +357 -0
- openarm_control-0.1.0/src/openarm_control/poses.py +61 -0
- openarm_control-0.1.0/src/openarm_control.egg-info/PKG-INFO +81 -0
- openarm_control-0.1.0/src/openarm_control.egg-info/SOURCES.txt +12 -0
- openarm_control-0.1.0/src/openarm_control.egg-info/dependency_links.txt +1 -0
- openarm_control-0.1.0/src/openarm_control.egg-info/requires.txt +5 -0
- openarm_control-0.1.0/src/openarm_control.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openarm_control
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Kinematics and control utilities for OpenArm
|
|
5
|
+
Author: Enactic, Inc.
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Changelog, https://github.com/enactic/openarm_control/releases
|
|
8
|
+
Project-URL: Issues, https://github.com/enactic/openarm_control/issues
|
|
9
|
+
Project-URL: Repository, https://github.com/enactic/openarm_control.git
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE.txt
|
|
13
|
+
Requires-Dist: daqp==0.7.2
|
|
14
|
+
Requires-Dist: mink>=1.1.0
|
|
15
|
+
Requires-Dist: mujoco>=3.6.0
|
|
16
|
+
Requires-Dist: numpy
|
|
17
|
+
Requires-Dist: openarm-mujoco
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# OpenArm Control
|
|
21
|
+
|
|
22
|
+
Reusable kinematics and control utilities for OpenArm, backed by MuJoCo and [mink](https://github.com/kevinzakka/mink).
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
uv sync
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### `Kinematics`
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from openarm_control import Kinematics, IKParams, ArmSetup
|
|
36
|
+
|
|
37
|
+
# FK only
|
|
38
|
+
kin = Kinematics(setup)
|
|
39
|
+
pose = kin.fk("right", joints) # float32[7]
|
|
40
|
+
pose_r, pose_l = kin.fk_bimanual(r, l) # single mj_forward
|
|
41
|
+
|
|
42
|
+
# IK
|
|
43
|
+
kin = Kinematics(setup, IKParams(damping=0.25, posture_cost=0.01))
|
|
44
|
+
kin.set_target("right", pose_r)
|
|
45
|
+
kin.set_target("left", pose_l)
|
|
46
|
+
result = kin.solve(dt=0.1, n_iters=5) # float32[16] right[8]+left[8]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### `IKParams`
|
|
50
|
+
|
|
51
|
+
Solver configuration passed to `Kinematics`. All fields have defaults.
|
|
52
|
+
|
|
53
|
+
| Field | Default | Description |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `position_cost` | `1.0` | Position task weight |
|
|
56
|
+
| `orientation_cost` | `1.0` | Orientation task weight |
|
|
57
|
+
| `lm_damping` | `0.01` | Per-task Levenberg-Marquardt damping |
|
|
58
|
+
| `damping` | `0.25` | Global Tikhonov regularization |
|
|
59
|
+
| `solver` | `"daqp"` | QP backend |
|
|
60
|
+
| `posture_cost` | `0.01` | Neutral posture task weight (0 = disabled) |
|
|
61
|
+
| `diag_reg` | `0.0` | QP diagonal regularization |
|
|
62
|
+
| `dt` | `0.1` | Integration timestep per iteration |
|
|
63
|
+
| `max_iters` | `5` | IK iterations per solve |
|
|
64
|
+
| `velocity_limits` | `None` | Per-joint velocity limits (applied in rad/s from `config.py`); `None` = disabled |
|
|
65
|
+
|
|
66
|
+
Build from CLI args with `register_ik_args` + `ik_params_from_args`:
|
|
67
|
+
|
|
68
|
+
## Related links
|
|
69
|
+
|
|
70
|
+
- 💬 Join the community on [Discord](https://discord.gg/FsZaZ4z3We)
|
|
71
|
+
- 📬 Contact us through <openarm@enactic.ai>
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
Licensed under the Apache License 2.0. See [LICENSE.txt](LICENSE.txt) for details.
|
|
76
|
+
|
|
77
|
+
Copyright 2026 Enactic, Inc.
|
|
78
|
+
|
|
79
|
+
## Code of Conduct
|
|
80
|
+
|
|
81
|
+
All participation in the OpenArm project is governed by our [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# OpenArm Control
|
|
2
|
+
|
|
3
|
+
Reusable kinematics and control utilities for OpenArm, backed by MuJoCo and [mink](https://github.com/kevinzakka/mink).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv sync
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### `Kinematics`
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from openarm_control import Kinematics, IKParams, ArmSetup
|
|
17
|
+
|
|
18
|
+
# FK only
|
|
19
|
+
kin = Kinematics(setup)
|
|
20
|
+
pose = kin.fk("right", joints) # float32[7]
|
|
21
|
+
pose_r, pose_l = kin.fk_bimanual(r, l) # single mj_forward
|
|
22
|
+
|
|
23
|
+
# IK
|
|
24
|
+
kin = Kinematics(setup, IKParams(damping=0.25, posture_cost=0.01))
|
|
25
|
+
kin.set_target("right", pose_r)
|
|
26
|
+
kin.set_target("left", pose_l)
|
|
27
|
+
result = kin.solve(dt=0.1, n_iters=5) # float32[16] right[8]+left[8]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### `IKParams`
|
|
31
|
+
|
|
32
|
+
Solver configuration passed to `Kinematics`. All fields have defaults.
|
|
33
|
+
|
|
34
|
+
| Field | Default | Description |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| `position_cost` | `1.0` | Position task weight |
|
|
37
|
+
| `orientation_cost` | `1.0` | Orientation task weight |
|
|
38
|
+
| `lm_damping` | `0.01` | Per-task Levenberg-Marquardt damping |
|
|
39
|
+
| `damping` | `0.25` | Global Tikhonov regularization |
|
|
40
|
+
| `solver` | `"daqp"` | QP backend |
|
|
41
|
+
| `posture_cost` | `0.01` | Neutral posture task weight (0 = disabled) |
|
|
42
|
+
| `diag_reg` | `0.0` | QP diagonal regularization |
|
|
43
|
+
| `dt` | `0.1` | Integration timestep per iteration |
|
|
44
|
+
| `max_iters` | `5` | IK iterations per solve |
|
|
45
|
+
| `velocity_limits` | `None` | Per-joint velocity limits (applied in rad/s from `config.py`); `None` = disabled |
|
|
46
|
+
|
|
47
|
+
Build from CLI args with `register_ik_args` + `ik_params_from_args`:
|
|
48
|
+
|
|
49
|
+
## Related links
|
|
50
|
+
|
|
51
|
+
- 💬 Join the community on [Discord](https://discord.gg/FsZaZ4z3We)
|
|
52
|
+
- 📬 Contact us through <openarm@enactic.ai>
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
Licensed under the Apache License 2.0. See [LICENSE.txt](LICENSE.txt) for details.
|
|
57
|
+
|
|
58
|
+
Copyright 2026 Enactic, Inc.
|
|
59
|
+
|
|
60
|
+
## Code of Conduct
|
|
61
|
+
|
|
62
|
+
All participation in the OpenArm project is governed by our [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Copyright 2026 Enactic, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
[build-system]
|
|
16
|
+
requires = ["setuptools>=64", "wheel"]
|
|
17
|
+
build-backend = "setuptools.build_meta"
|
|
18
|
+
|
|
19
|
+
[project]
|
|
20
|
+
name = "openarm_control"
|
|
21
|
+
version = "0.1.0"
|
|
22
|
+
description = "Kinematics and control utilities for OpenArm"
|
|
23
|
+
authors = [{name = "Enactic, Inc."}]
|
|
24
|
+
license = {text = "Apache-2.0"}
|
|
25
|
+
readme = "README.md"
|
|
26
|
+
requires-python = ">=3.10"
|
|
27
|
+
|
|
28
|
+
dependencies = [
|
|
29
|
+
"daqp==0.7.2",
|
|
30
|
+
"mink>=1.1.0",
|
|
31
|
+
"mujoco>=3.6.0",
|
|
32
|
+
"numpy",
|
|
33
|
+
"openarm-mujoco",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Changelog = "https://github.com/enactic/openarm_control/releases"
|
|
38
|
+
Issues = "https://github.com/enactic/openarm_control/issues"
|
|
39
|
+
Repository = "https://github.com/enactic/openarm_control.git"
|
|
40
|
+
|
|
41
|
+
[tool.setuptools]
|
|
42
|
+
package-dir = {"" = "src"}
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.packages.find]
|
|
45
|
+
where = ["src"]
|
|
46
|
+
|
|
47
|
+
[tool.ruff.lint]
|
|
48
|
+
extend-select = [
|
|
49
|
+
"D", # pydocstyle
|
|
50
|
+
"UP",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[tool.ruff.lint.per-file-ignores]
|
|
54
|
+
"!src/**.py" = ["D"]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Copyright 2026 Enactic, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Kinematics and control utilities for OpenArm."""
|
|
16
|
+
|
|
17
|
+
from .config import ArmSetup, register_common_args, setup_from_args
|
|
18
|
+
from .kinematics import (
|
|
19
|
+
IKParams,
|
|
20
|
+
Kinematics,
|
|
21
|
+
register_ik_args,
|
|
22
|
+
ik_params_from_args,
|
|
23
|
+
)
|
|
24
|
+
from .poses import read_ee_pose, pose_to_se3, se3_to_pose
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
# context
|
|
28
|
+
"ArmSetup",
|
|
29
|
+
# high-level interface
|
|
30
|
+
"Kinematics",
|
|
31
|
+
"IKParams",
|
|
32
|
+
# CLI helpers
|
|
33
|
+
"register_common_args",
|
|
34
|
+
"register_ik_args",
|
|
35
|
+
"setup_from_args",
|
|
36
|
+
"ik_params_from_args",
|
|
37
|
+
# pose utilities
|
|
38
|
+
"read_ee_pose",
|
|
39
|
+
"pose_to_se3",
|
|
40
|
+
"se3_to_pose",
|
|
41
|
+
]
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Copyright 2026 Enactic, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Shared MuJoCo context for OpenArm FK, IK, and controller nodes."""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
|
|
21
|
+
import mujoco
|
|
22
|
+
import numpy as np
|
|
23
|
+
import openarm_mujoco.v2 as openarm_mujoco
|
|
24
|
+
from openarm_mujoco.v2 import JointResolver
|
|
25
|
+
|
|
26
|
+
_DEFAULT_XML = openarm_mujoco.openarm_cell_xml()
|
|
27
|
+
|
|
28
|
+
_DEFAULT_FRAME_RIGHT = "right_ee_control_point"
|
|
29
|
+
_DEFAULT_FRAME_TYPE_RIGHT = "site"
|
|
30
|
+
_DEFAULT_FRAME_LEFT = "left_ee_control_point"
|
|
31
|
+
_DEFAULT_FRAME_TYPE_LEFT = "site"
|
|
32
|
+
|
|
33
|
+
_FRAME_OBJ = {
|
|
34
|
+
"body": mujoco.mjtObj.mjOBJ_BODY,
|
|
35
|
+
"site": mujoco.mjtObj.mjOBJ_SITE,
|
|
36
|
+
"geom": mujoco.mjtObj.mjOBJ_GEOM,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# Per-arm-joint velocity caps in rad/s. Enabled via --limit-velocity.
|
|
40
|
+
ARM_JOINT_VELOCITY_LIMITS_RAD_S: list[float] = [
|
|
41
|
+
1.57, # joint1 DM 8009
|
|
42
|
+
1.57, # joint2 DM 8009
|
|
43
|
+
3.14, # joint3 DM 4340
|
|
44
|
+
3.14, # joint4 DM 4340
|
|
45
|
+
12.6, # joint5 DM 4310
|
|
46
|
+
12.6, # joint6 DM 4310
|
|
47
|
+
12.6, # joint7 DM 4310
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class ArmSetup:
|
|
52
|
+
"""MuJoCo context shared across FK, IK, and controller nodes.
|
|
53
|
+
|
|
54
|
+
Bundles the model, data, joint resolver, active arm sides, and per-arm
|
|
55
|
+
EE frame IDs/types. Instantiate once per process; pass into any solver
|
|
56
|
+
or controller that needs model access.
|
|
57
|
+
|
|
58
|
+
Pose convention throughout: float32[7] = [px, py, pz, qw, qx, qy, qz]
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
def __init__(
|
|
62
|
+
self,
|
|
63
|
+
model: mujoco.MjModel,
|
|
64
|
+
data: mujoco.MjData,
|
|
65
|
+
joint_resolver: JointResolver,
|
|
66
|
+
sides: list[str],
|
|
67
|
+
frame_ids: dict[str, int],
|
|
68
|
+
frame_types: dict[str, str],
|
|
69
|
+
) -> None:
|
|
70
|
+
"""Initialize."""
|
|
71
|
+
self.model = model
|
|
72
|
+
self.data = data
|
|
73
|
+
self.joint_resolver = joint_resolver
|
|
74
|
+
self.sides = sides
|
|
75
|
+
self.frame_ids = frame_ids # side → MuJoCo object ID
|
|
76
|
+
self.frame_types = frame_types # side → "body" | "site" | "geom"
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def from_args(
|
|
80
|
+
cls,
|
|
81
|
+
xml: str,
|
|
82
|
+
mode: str,
|
|
83
|
+
frame_right: str,
|
|
84
|
+
frame_type_right: str,
|
|
85
|
+
frame_left: str,
|
|
86
|
+
frame_type_left: str,
|
|
87
|
+
keyframe: str | None = "home",
|
|
88
|
+
) -> ArmSetup:
|
|
89
|
+
"""Build from XML."""
|
|
90
|
+
model = mujoco.MjModel.from_xml_path(xml)
|
|
91
|
+
data = mujoco.MjData(model)
|
|
92
|
+
|
|
93
|
+
if keyframe:
|
|
94
|
+
key_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_KEY, keyframe)
|
|
95
|
+
if key_id >= 0:
|
|
96
|
+
mujoco.mj_resetDataKeyframe(model, data, key_id)
|
|
97
|
+
else:
|
|
98
|
+
print(f"Warning: keyframe '{keyframe}' not found, using defaults.")
|
|
99
|
+
|
|
100
|
+
mujoco.mj_forward(model, data)
|
|
101
|
+
|
|
102
|
+
sides: list[str] = []
|
|
103
|
+
if mode in ("right", "bimanual"):
|
|
104
|
+
sides.append("right")
|
|
105
|
+
if mode in ("left", "bimanual"):
|
|
106
|
+
sides.append("left")
|
|
107
|
+
|
|
108
|
+
frame_ids: dict[str, int] = {}
|
|
109
|
+
frame_types: dict[str, str] = {}
|
|
110
|
+
for side in sides:
|
|
111
|
+
name = frame_right if side == "right" else frame_left
|
|
112
|
+
ftype = frame_type_right if side == "right" else frame_type_left
|
|
113
|
+
frame_ids[side] = _resolve_frame_id(model, name, ftype)
|
|
114
|
+
frame_types[side] = ftype
|
|
115
|
+
|
|
116
|
+
return cls(
|
|
117
|
+
model=model,
|
|
118
|
+
data=data,
|
|
119
|
+
joint_resolver=JointResolver(model),
|
|
120
|
+
sides=sides,
|
|
121
|
+
frame_ids=frame_ids,
|
|
122
|
+
frame_types=frame_types,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
def read_ee_pose(self, side: str) -> np.ndarray:
|
|
126
|
+
"""Return float32[7] = [px, py, pz, qw, qx, qy, qz] for the given arm."""
|
|
127
|
+
from openarm_control.poses import read_ee_pose
|
|
128
|
+
|
|
129
|
+
return read_ee_pose(self.data, self.frame_ids[side], self.frame_types[side])
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _resolve_frame_id(model: mujoco.MjModel, name: str, ftype: str) -> int:
|
|
133
|
+
obj = _FRAME_OBJ.get(ftype)
|
|
134
|
+
if obj is None:
|
|
135
|
+
raise ValueError(f"Unknown frame_type '{ftype}'. Expected body/site/geom.")
|
|
136
|
+
fid = mujoco.mj_name2id(model, obj, name)
|
|
137
|
+
if fid < 0:
|
|
138
|
+
raise ValueError(f"{ftype.capitalize()} '{name}' not found in model.")
|
|
139
|
+
return fid
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def register_common_args(parser: argparse.ArgumentParser) -> None:
|
|
143
|
+
"""Register shared CLI flags used by all arm nodes: --xml, --keyframe, --mode, --frame-*."""
|
|
144
|
+
parser.add_argument(
|
|
145
|
+
"--xml",
|
|
146
|
+
default=_DEFAULT_XML,
|
|
147
|
+
help=f"MJCF scene file (default: {_DEFAULT_XML})",
|
|
148
|
+
)
|
|
149
|
+
parser.add_argument(
|
|
150
|
+
"--keyframe",
|
|
151
|
+
"-k",
|
|
152
|
+
default="home",
|
|
153
|
+
help="Initial keyframe name (default: home)",
|
|
154
|
+
)
|
|
155
|
+
parser.add_argument(
|
|
156
|
+
"--mode",
|
|
157
|
+
choices=["right", "left", "bimanual"],
|
|
158
|
+
default="bimanual",
|
|
159
|
+
help="Which arm(s) to compute (default: bimanual)",
|
|
160
|
+
)
|
|
161
|
+
parser.add_argument(
|
|
162
|
+
"--frame-right",
|
|
163
|
+
default=_DEFAULT_FRAME_RIGHT,
|
|
164
|
+
help=f"EE frame name for right arm (default: {_DEFAULT_FRAME_RIGHT})",
|
|
165
|
+
)
|
|
166
|
+
parser.add_argument(
|
|
167
|
+
"--frame-type-right",
|
|
168
|
+
choices=["body", "site", "geom"],
|
|
169
|
+
default=_DEFAULT_FRAME_TYPE_RIGHT,
|
|
170
|
+
help="EE frame type for right arm (default: site)",
|
|
171
|
+
)
|
|
172
|
+
parser.add_argument(
|
|
173
|
+
"--frame-left",
|
|
174
|
+
default=_DEFAULT_FRAME_LEFT,
|
|
175
|
+
help=f"EE frame name for left arm (default: {_DEFAULT_FRAME_LEFT})",
|
|
176
|
+
)
|
|
177
|
+
parser.add_argument(
|
|
178
|
+
"--frame-type-left",
|
|
179
|
+
choices=["body", "site", "geom"],
|
|
180
|
+
default=_DEFAULT_FRAME_TYPE_LEFT,
|
|
181
|
+
help="EE frame type for left arm (default: site)",
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def setup_from_args(args: argparse.Namespace) -> ArmSetup:
|
|
186
|
+
"""Build ArmSetup from a namespace that contains the common CLI flags."""
|
|
187
|
+
return ArmSetup.from_args(
|
|
188
|
+
xml=args.xml,
|
|
189
|
+
mode=args.mode,
|
|
190
|
+
frame_right=args.frame_right,
|
|
191
|
+
frame_type_right=args.frame_type_right,
|
|
192
|
+
frame_left=args.frame_left,
|
|
193
|
+
frame_type_left=args.frame_type_left,
|
|
194
|
+
keyframe=args.keyframe,
|
|
195
|
+
)
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
# Copyright 2026 Enactic, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""High-level FK + IK interface for OpenArm.
|
|
16
|
+
|
|
17
|
+
Usage:
|
|
18
|
+
# FK only
|
|
19
|
+
kin = Kinematics(setup)
|
|
20
|
+
pose = kin.fk("right", joints) # float32[7]
|
|
21
|
+
pose_r, pose_l = kin.fk_bimanual(r, l) # single mj_forward
|
|
22
|
+
|
|
23
|
+
# FK + IK
|
|
24
|
+
kin = Kinematics(setup, IKParams())
|
|
25
|
+
kin.set_target("right", pose)
|
|
26
|
+
kin.set_target("left", pose)
|
|
27
|
+
result = kin.solve(dt=0.1, n_iters=5) # float32[16] or None
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
from __future__ import annotations
|
|
31
|
+
|
|
32
|
+
import argparse
|
|
33
|
+
from dataclasses import dataclass
|
|
34
|
+
|
|
35
|
+
import mink
|
|
36
|
+
import mink.exceptions
|
|
37
|
+
import mujoco
|
|
38
|
+
import numpy as np
|
|
39
|
+
|
|
40
|
+
from openarm_control.config import ARM_JOINT_VELOCITY_LIMITS_RAD_S, ArmSetup
|
|
41
|
+
from openarm_control.poses import pose_to_se3
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@dataclass
|
|
45
|
+
class IKParams:
|
|
46
|
+
"""Configuration for the mink QP-based IK solver."""
|
|
47
|
+
|
|
48
|
+
position_cost: float = 1.0
|
|
49
|
+
orientation_cost: float = 1.0
|
|
50
|
+
lm_damping: float = 0.01
|
|
51
|
+
damping: float = 0.25
|
|
52
|
+
solver: str = "daqp"
|
|
53
|
+
posture_cost: float = 0.01
|
|
54
|
+
diag_reg: float = 0.0
|
|
55
|
+
dt: float = 0.1
|
|
56
|
+
max_iters: int = 5
|
|
57
|
+
velocity_limits: dict[str, float] | None = None
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class Kinematics:
|
|
61
|
+
"""Unified FK + IK for OpenArm, backed by MuJoCo + mink.
|
|
62
|
+
|
|
63
|
+
FK is always available. IK is enabled by passing ``IKParams``.
|
|
64
|
+
Both share the same ``ArmSetup`` context (model, resolver, frame IDs).
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
def __init__(self, setup: ArmSetup, ik_params: IKParams | None = None) -> None:
|
|
68
|
+
"""Initialize."""
|
|
69
|
+
self.setup = setup
|
|
70
|
+
self._ik: _IKSolver | None = (
|
|
71
|
+
_IKSolver(setup, ik_params) if ik_params is not None else None
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# ── FK ───────────────────────────────────────────────────────────────────
|
|
75
|
+
|
|
76
|
+
def fk(self, side: str, joints: np.ndarray) -> np.ndarray:
|
|
77
|
+
"""Set qpos for one arm, run mj_forward, return float32[7] EE pose."""
|
|
78
|
+
self.setup.joint_resolver.set_qpos(self.setup.data.qpos, joints, side)
|
|
79
|
+
mujoco.mj_forward(self.setup.model, self.setup.data)
|
|
80
|
+
return self.setup.read_ee_pose(side)
|
|
81
|
+
|
|
82
|
+
def fk_bimanual(
|
|
83
|
+
self, right: np.ndarray, left: np.ndarray
|
|
84
|
+
) -> tuple[np.ndarray, np.ndarray]:
|
|
85
|
+
"""Set both arms and run a single mj_forward. Returns (pose_right, pose_left)."""
|
|
86
|
+
self.setup.joint_resolver.set_qpos(self.setup.data.qpos, right, "right")
|
|
87
|
+
self.setup.joint_resolver.set_qpos(self.setup.data.qpos, left, "left")
|
|
88
|
+
mujoco.mj_forward(self.setup.model, self.setup.data)
|
|
89
|
+
return self.setup.read_ee_pose("right"), self.setup.read_ee_pose("left")
|
|
90
|
+
|
|
91
|
+
# ── IK ───────────────────────────────────────────────────────────────────
|
|
92
|
+
|
|
93
|
+
def set_target(self, side: str, pose: np.ndarray) -> None:
|
|
94
|
+
"""Set EE target for one arm. pose: float32[7] = [px, py, pz, qw, qx, qy, qz]."""
|
|
95
|
+
self._require_ik().set_target(side, pose)
|
|
96
|
+
|
|
97
|
+
def sync(self, values16: np.ndarray) -> None:
|
|
98
|
+
"""Sync IK internal config from float32[16] driver state (right[8]+left[8])."""
|
|
99
|
+
self._require_ik().sync(values16)
|
|
100
|
+
|
|
101
|
+
def ready(self) -> bool:
|
|
102
|
+
"""Return True once all active arms have received at least one target this cycle."""
|
|
103
|
+
return self._require_ik().ready()
|
|
104
|
+
|
|
105
|
+
def solve(self) -> np.ndarray | None:
|
|
106
|
+
"""Run IK. Returns float32[16] (right[8]+left[8]) or None on failure."""
|
|
107
|
+
return self._require_ik().solve()
|
|
108
|
+
|
|
109
|
+
def set_gripper(self, side: str, value: float) -> None:
|
|
110
|
+
"""Pass through a gripper value; IK does not solve for it."""
|
|
111
|
+
idx = 0 if side == "right" else 1
|
|
112
|
+
self._require_ik()._gripper[idx] = value
|
|
113
|
+
|
|
114
|
+
def _require_ik(self) -> _IKSolver:
|
|
115
|
+
if self._ik is None:
|
|
116
|
+
raise RuntimeError("Kinematics was not initialized with IKParams.")
|
|
117
|
+
return self._ik
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# ── internal IK implementation ────────────────────────────────────────────────
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class _IKSolver:
|
|
124
|
+
"""mink QP-based differential IK. Managed by Kinematics; not public API."""
|
|
125
|
+
|
|
126
|
+
def __init__(self, setup: ArmSetup, params: IKParams) -> None:
|
|
127
|
+
self._sides = setup.sides
|
|
128
|
+
self._solver_name = params.solver
|
|
129
|
+
self._posture_cost = params.posture_cost
|
|
130
|
+
self._joint_resolver = setup.joint_resolver
|
|
131
|
+
self._dt = params.dt
|
|
132
|
+
self._max_iters = params.max_iters
|
|
133
|
+
|
|
134
|
+
self._config = mink.Configuration(setup.model)
|
|
135
|
+
self._config.update(q=setup.data.qpos.copy())
|
|
136
|
+
mid_qpos = self._config.data.qpos.copy()
|
|
137
|
+
|
|
138
|
+
task_kwargs = dict(
|
|
139
|
+
position_cost=params.position_cost,
|
|
140
|
+
orientation_cost=params.orientation_cost,
|
|
141
|
+
lm_damping=params.lm_damping,
|
|
142
|
+
)
|
|
143
|
+
self._tasks: dict[str, mink.FrameTask] = {
|
|
144
|
+
side: mink.FrameTask(
|
|
145
|
+
frame_name=_frame_name(setup, side),
|
|
146
|
+
frame_type=setup.frame_types[side],
|
|
147
|
+
**task_kwargs,
|
|
148
|
+
)
|
|
149
|
+
for side in setup.sides
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
active_qpos: set[int] = set(
|
|
153
|
+
setup.joint_resolver._right.arm_qpos.tolist()
|
|
154
|
+
) | set(setup.joint_resolver._left.arm_qpos.tolist())
|
|
155
|
+
freeze_dofs = [
|
|
156
|
+
int(setup.model.jnt_dofadr[j])
|
|
157
|
+
for j in range(setup.model.njnt)
|
|
158
|
+
if setup.model.jnt_qposadr[j] not in active_qpos
|
|
159
|
+
]
|
|
160
|
+
print(active_qpos)
|
|
161
|
+
print(freeze_dofs)
|
|
162
|
+
self._freeze_task: mink.DofFreezingTask | None = (
|
|
163
|
+
mink.DofFreezingTask(model=setup.model, dof_indices=freeze_dofs)
|
|
164
|
+
if freeze_dofs
|
|
165
|
+
else None
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
self._limits = [mink.ConfigurationLimit(setup.model)]
|
|
169
|
+
|
|
170
|
+
if params.velocity_limits is not None:
|
|
171
|
+
self._limits.append(mink.VelocityLimit(setup.model, params.velocity_limits))
|
|
172
|
+
|
|
173
|
+
self._posture_task = mink.PostureTask(setup.model, cost=params.posture_cost)
|
|
174
|
+
self._posture_task.set_target(mid_qpos)
|
|
175
|
+
|
|
176
|
+
self._solver_params: dict = {"damping": params.damping}
|
|
177
|
+
if params.diag_reg > 0.0:
|
|
178
|
+
self._solver_params["diag_reg"] = params.diag_reg
|
|
179
|
+
|
|
180
|
+
self._pending: set[str] = set(setup.sides)
|
|
181
|
+
self._gripper = np.zeros(2, dtype=np.float32)
|
|
182
|
+
|
|
183
|
+
def set_target(self, side: str, pose: np.ndarray) -> None:
|
|
184
|
+
self._tasks[side].set_target(pose_to_se3(pose))
|
|
185
|
+
self._pending.discard(side)
|
|
186
|
+
|
|
187
|
+
def sync(self, values16: np.ndarray) -> None:
|
|
188
|
+
qpos = self._config.data.qpos.copy()
|
|
189
|
+
self._joint_resolver.set_qpos(qpos, values16[:8], "right")
|
|
190
|
+
self._joint_resolver.set_qpos(qpos, values16[8:16], "left")
|
|
191
|
+
self._config.update(q=qpos)
|
|
192
|
+
self._gripper[0] = values16[7]
|
|
193
|
+
self._gripper[1] = values16[15]
|
|
194
|
+
|
|
195
|
+
def ready(self) -> bool:
|
|
196
|
+
return len(self._pending) == 0
|
|
197
|
+
|
|
198
|
+
def solve(self) -> np.ndarray | None:
|
|
199
|
+
tasks = list(self._tasks.values())
|
|
200
|
+
if self._posture_cost > 0.0:
|
|
201
|
+
tasks.append(self._posture_task)
|
|
202
|
+
constraints = [self._freeze_task] if self._freeze_task else []
|
|
203
|
+
|
|
204
|
+
for _ in range(self._max_iters):
|
|
205
|
+
try:
|
|
206
|
+
vel = mink.solve_ik(
|
|
207
|
+
self._config,
|
|
208
|
+
tasks,
|
|
209
|
+
self._dt,
|
|
210
|
+
self._solver_name,
|
|
211
|
+
limits=self._limits,
|
|
212
|
+
constraints=constraints,
|
|
213
|
+
safety_break=False,
|
|
214
|
+
**self._solver_params,
|
|
215
|
+
)
|
|
216
|
+
except mink.exceptions.NoSolutionFound:
|
|
217
|
+
try:
|
|
218
|
+
vel = mink.solve_ik(
|
|
219
|
+
self._config,
|
|
220
|
+
tasks,
|
|
221
|
+
self._dt,
|
|
222
|
+
self._solver_name,
|
|
223
|
+
limits=[],
|
|
224
|
+
constraints=constraints,
|
|
225
|
+
safety_break=False,
|
|
226
|
+
**self._solver_params,
|
|
227
|
+
)
|
|
228
|
+
except mink.exceptions.NoSolutionFound:
|
|
229
|
+
print(
|
|
230
|
+
"Warning: IK solver failed (constrained and unconstrained). Skipping step."
|
|
231
|
+
)
|
|
232
|
+
return None
|
|
233
|
+
self._config.integrate_inplace(vel, self._dt)
|
|
234
|
+
|
|
235
|
+
self._pending = set(self._sides)
|
|
236
|
+
|
|
237
|
+
qpos = self._config.data.qpos
|
|
238
|
+
right_joints, _ = self._joint_resolver.get_driver(qpos, "right")
|
|
239
|
+
left_joints, _ = self._joint_resolver.get_driver(qpos, "left")
|
|
240
|
+
return np.concatenate(
|
|
241
|
+
[
|
|
242
|
+
np.append(right_joints, self._gripper[0]),
|
|
243
|
+
np.append(left_joints, self._gripper[1]),
|
|
244
|
+
]
|
|
245
|
+
).astype(np.float32)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def _frame_name(setup: ArmSetup, side: str) -> str:
|
|
249
|
+
ftype = setup.frame_types[side]
|
|
250
|
+
fid = setup.frame_ids[side]
|
|
251
|
+
obj = {
|
|
252
|
+
"body": mujoco.mjtObj.mjOBJ_BODY,
|
|
253
|
+
"site": mujoco.mjtObj.mjOBJ_SITE,
|
|
254
|
+
"geom": mujoco.mjtObj.mjOBJ_GEOM,
|
|
255
|
+
}[ftype]
|
|
256
|
+
return mujoco.mj_id2name(setup.model, obj, fid)
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def _convert_velocity(
|
|
260
|
+
rad_per_sec: float,
|
|
261
|
+
dt: float,
|
|
262
|
+
max_iters: int,
|
|
263
|
+
tick_hz: float,
|
|
264
|
+
) -> float:
|
|
265
|
+
if max_iters <= 0 or dt <= 0.0 or tick_hz <= 0.0:
|
|
266
|
+
raise ValueError("max_iters, dt, and tick_hz must all be positive.")
|
|
267
|
+
return rad_per_sec / (max_iters * dt * tick_hz)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
# ── CLI helpers ───────────────────────────────────────────────────────────────
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def register_ik_args(parser: argparse.ArgumentParser) -> None:
|
|
274
|
+
"""Register IK-specific CLI flags. Call after register_common_args."""
|
|
275
|
+
parser.add_argument(
|
|
276
|
+
"--pos-cost", type=float, default=1.0, help="Position task cost (default: 1.0)"
|
|
277
|
+
)
|
|
278
|
+
parser.add_argument(
|
|
279
|
+
"--ori-cost",
|
|
280
|
+
type=float,
|
|
281
|
+
default=1.0,
|
|
282
|
+
help="Orientation task cost (default: 1.0)",
|
|
283
|
+
)
|
|
284
|
+
parser.add_argument(
|
|
285
|
+
"--lm-damping",
|
|
286
|
+
type=float,
|
|
287
|
+
default=0.01,
|
|
288
|
+
help="Per-task LM damping (default: 0.01)",
|
|
289
|
+
)
|
|
290
|
+
parser.add_argument(
|
|
291
|
+
"--damping",
|
|
292
|
+
type=float,
|
|
293
|
+
default=0.25,
|
|
294
|
+
help="Global Tikhonov regularization (default: 0.25)",
|
|
295
|
+
)
|
|
296
|
+
parser.add_argument("--solver", default="daqp", help="QP backend (default: daqp)")
|
|
297
|
+
parser.add_argument(
|
|
298
|
+
"--max-iters", type=int, default=5, help="IK iterations per event (default: 5)"
|
|
299
|
+
)
|
|
300
|
+
parser.add_argument(
|
|
301
|
+
"--dt",
|
|
302
|
+
type=float,
|
|
303
|
+
default=0.1,
|
|
304
|
+
help="Integration timestep per iteration (default: 0.1)",
|
|
305
|
+
)
|
|
306
|
+
parser.add_argument(
|
|
307
|
+
"--posture-cost",
|
|
308
|
+
type=float,
|
|
309
|
+
default=0.01,
|
|
310
|
+
help="Posture task weight, 0=disabled (default: 0.01)",
|
|
311
|
+
)
|
|
312
|
+
parser.add_argument(
|
|
313
|
+
"--diag-reg",
|
|
314
|
+
type=float,
|
|
315
|
+
default=0.0,
|
|
316
|
+
help="QP diagonal regularization (default: 0.0)",
|
|
317
|
+
)
|
|
318
|
+
parser.add_argument(
|
|
319
|
+
"--limit-velocity",
|
|
320
|
+
action="store_true",
|
|
321
|
+
help="Enable per-joint velocity limits (caps in config.ARM_JOINT_VELOCITY_LIMITS_RAD_S).",
|
|
322
|
+
)
|
|
323
|
+
parser.add_argument(
|
|
324
|
+
"--tick-hz",
|
|
325
|
+
type=float,
|
|
326
|
+
default=500.0,
|
|
327
|
+
help="Dora tick rate in Hz; must match the dataflow timer (default: 500.0).",
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def ik_params_from_args(args: argparse.Namespace) -> IKParams:
|
|
332
|
+
"""Build IKParams from parsed args (requires register_ik_args to have been called)."""
|
|
333
|
+
velocity_limits: dict[str, float] | None = None
|
|
334
|
+
if args.limit_velocity:
|
|
335
|
+
velocity_limits = {
|
|
336
|
+
f"openarm_{side}_joint{i + 1}": _convert_velocity(
|
|
337
|
+
rad_per_sec=v,
|
|
338
|
+
dt=args.dt,
|
|
339
|
+
max_iters=args.max_iters,
|
|
340
|
+
tick_hz=args.tick_hz,
|
|
341
|
+
)
|
|
342
|
+
for side in ("left", "right")
|
|
343
|
+
for i, v in enumerate(ARM_JOINT_VELOCITY_LIMITS_RAD_S)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return IKParams(
|
|
347
|
+
position_cost=args.pos_cost,
|
|
348
|
+
orientation_cost=args.ori_cost,
|
|
349
|
+
lm_damping=args.lm_damping,
|
|
350
|
+
damping=args.damping,
|
|
351
|
+
solver=args.solver,
|
|
352
|
+
posture_cost=args.posture_cost,
|
|
353
|
+
diag_reg=args.diag_reg,
|
|
354
|
+
dt=args.dt,
|
|
355
|
+
max_iters=args.max_iters,
|
|
356
|
+
velocity_limits=velocity_limits,
|
|
357
|
+
)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Copyright 2026 Enactic, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Pose conversion utilities shared across FK, IK, and controller nodes.
|
|
16
|
+
|
|
17
|
+
Convention: float32[7] = [px, py, pz, qw, qx, qy, qz]
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import mujoco
|
|
23
|
+
import numpy as np
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def read_ee_pose(data: mujoco.MjData, fid: int, ftype: str) -> np.ndarray:
|
|
27
|
+
"""Read EE pose from MjData after mj_forward.
|
|
28
|
+
|
|
29
|
+
Returns float32[7] = [px, py, pz, qw, qx, qy, qz].
|
|
30
|
+
"""
|
|
31
|
+
if ftype == "body":
|
|
32
|
+
pos = data.xpos[fid]
|
|
33
|
+
quat = data.xquat[fid]
|
|
34
|
+
elif ftype == "site":
|
|
35
|
+
pos = data.site_xpos[fid]
|
|
36
|
+
quat = np.empty(4)
|
|
37
|
+
mujoco.mju_mat2Quat(quat, data.site_xmat[fid])
|
|
38
|
+
else: # geom
|
|
39
|
+
pos = data.geom_xpos[fid]
|
|
40
|
+
quat = np.empty(4)
|
|
41
|
+
mujoco.mju_mat2Quat(quat, data.geom_xmat[fid])
|
|
42
|
+
return np.concatenate([pos, quat]).astype(np.float32)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def pose_to_se3(pose: np.ndarray): # -> mink.SE3
|
|
46
|
+
"""float32[7] [px, py, pz, qw, qx, qy, qz] → mink.SE3.
|
|
47
|
+
|
|
48
|
+
mink internal layout: wxyz_xyz = [qw, qx, qy, qz, x, y, z].
|
|
49
|
+
"""
|
|
50
|
+
import mink # lazy: FK nodes don't depend on mink
|
|
51
|
+
|
|
52
|
+
wxyz_xyz = np.empty(7, dtype=np.float64)
|
|
53
|
+
wxyz_xyz[:4] = pose[3:7] # quat: wxyz
|
|
54
|
+
wxyz_xyz[4:] = pose[:3] # translation: xyz
|
|
55
|
+
return mink.SE3(wxyz_xyz=wxyz_xyz)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def se3_to_pose(se3) -> np.ndarray: # se3: mink.SE3
|
|
59
|
+
"""mink.SE3 → float32[7] [px, py, pz, qw, qx, qy, qz]."""
|
|
60
|
+
wxyz_xyz = se3.wxyz_xyz
|
|
61
|
+
return np.concatenate([wxyz_xyz[4:], wxyz_xyz[:4]]).astype(np.float32)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openarm_control
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Kinematics and control utilities for OpenArm
|
|
5
|
+
Author: Enactic, Inc.
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Changelog, https://github.com/enactic/openarm_control/releases
|
|
8
|
+
Project-URL: Issues, https://github.com/enactic/openarm_control/issues
|
|
9
|
+
Project-URL: Repository, https://github.com/enactic/openarm_control.git
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE.txt
|
|
13
|
+
Requires-Dist: daqp==0.7.2
|
|
14
|
+
Requires-Dist: mink>=1.1.0
|
|
15
|
+
Requires-Dist: mujoco>=3.6.0
|
|
16
|
+
Requires-Dist: numpy
|
|
17
|
+
Requires-Dist: openarm-mujoco
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# OpenArm Control
|
|
21
|
+
|
|
22
|
+
Reusable kinematics and control utilities for OpenArm, backed by MuJoCo and [mink](https://github.com/kevinzakka/mink).
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
uv sync
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### `Kinematics`
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from openarm_control import Kinematics, IKParams, ArmSetup
|
|
36
|
+
|
|
37
|
+
# FK only
|
|
38
|
+
kin = Kinematics(setup)
|
|
39
|
+
pose = kin.fk("right", joints) # float32[7]
|
|
40
|
+
pose_r, pose_l = kin.fk_bimanual(r, l) # single mj_forward
|
|
41
|
+
|
|
42
|
+
# IK
|
|
43
|
+
kin = Kinematics(setup, IKParams(damping=0.25, posture_cost=0.01))
|
|
44
|
+
kin.set_target("right", pose_r)
|
|
45
|
+
kin.set_target("left", pose_l)
|
|
46
|
+
result = kin.solve(dt=0.1, n_iters=5) # float32[16] right[8]+left[8]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### `IKParams`
|
|
50
|
+
|
|
51
|
+
Solver configuration passed to `Kinematics`. All fields have defaults.
|
|
52
|
+
|
|
53
|
+
| Field | Default | Description |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `position_cost` | `1.0` | Position task weight |
|
|
56
|
+
| `orientation_cost` | `1.0` | Orientation task weight |
|
|
57
|
+
| `lm_damping` | `0.01` | Per-task Levenberg-Marquardt damping |
|
|
58
|
+
| `damping` | `0.25` | Global Tikhonov regularization |
|
|
59
|
+
| `solver` | `"daqp"` | QP backend |
|
|
60
|
+
| `posture_cost` | `0.01` | Neutral posture task weight (0 = disabled) |
|
|
61
|
+
| `diag_reg` | `0.0` | QP diagonal regularization |
|
|
62
|
+
| `dt` | `0.1` | Integration timestep per iteration |
|
|
63
|
+
| `max_iters` | `5` | IK iterations per solve |
|
|
64
|
+
| `velocity_limits` | `None` | Per-joint velocity limits (applied in rad/s from `config.py`); `None` = disabled |
|
|
65
|
+
|
|
66
|
+
Build from CLI args with `register_ik_args` + `ik_params_from_args`:
|
|
67
|
+
|
|
68
|
+
## Related links
|
|
69
|
+
|
|
70
|
+
- 💬 Join the community on [Discord](https://discord.gg/FsZaZ4z3We)
|
|
71
|
+
- 📬 Contact us through <openarm@enactic.ai>
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
Licensed under the Apache License 2.0. See [LICENSE.txt](LICENSE.txt) for details.
|
|
76
|
+
|
|
77
|
+
Copyright 2026 Enactic, Inc.
|
|
78
|
+
|
|
79
|
+
## Code of Conduct
|
|
80
|
+
|
|
81
|
+
All participation in the OpenArm project is governed by our [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE.txt
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/openarm_control/__init__.py
|
|
5
|
+
src/openarm_control/config.py
|
|
6
|
+
src/openarm_control/kinematics.py
|
|
7
|
+
src/openarm_control/poses.py
|
|
8
|
+
src/openarm_control.egg-info/PKG-INFO
|
|
9
|
+
src/openarm_control.egg-info/SOURCES.txt
|
|
10
|
+
src/openarm_control.egg-info/dependency_links.txt
|
|
11
|
+
src/openarm_control.egg-info/requires.txt
|
|
12
|
+
src/openarm_control.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
openarm_control
|