dora-openarm-cell-lifter 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.
- dora_openarm_cell_lifter-0.1.0/LICENSE +202 -0
- dora_openarm_cell_lifter-0.1.0/PKG-INFO +27 -0
- dora_openarm_cell_lifter-0.1.0/README.md +13 -0
- dora_openarm_cell_lifter-0.1.0/pyproject.toml +55 -0
- dora_openarm_cell_lifter-0.1.0/setup.cfg +4 -0
- dora_openarm_cell_lifter-0.1.0/src/dora_openarm_cell_lifter/__init__.py +27 -0
- dora_openarm_cell_lifter-0.1.0/src/dora_openarm_cell_lifter/main.py +391 -0
- dora_openarm_cell_lifter-0.1.0/src/dora_openarm_cell_lifter.egg-info/PKG-INFO +27 -0
- dora_openarm_cell_lifter-0.1.0/src/dora_openarm_cell_lifter.egg-info/SOURCES.txt +12 -0
- dora_openarm_cell_lifter-0.1.0/src/dora_openarm_cell_lifter.egg-info/dependency_links.txt +1 -0
- dora_openarm_cell_lifter-0.1.0/src/dora_openarm_cell_lifter.egg-info/entry_points.txt +2 -0
- dora_openarm_cell_lifter-0.1.0/src/dora_openarm_cell_lifter.egg-info/requires.txt +2 -0
- dora_openarm_cell_lifter-0.1.0/src/dora_openarm_cell_lifter.egg-info/top_level.txt +1 -0
- dora_openarm_cell_lifter-0.1.0/tests/test_joystick_y_elevation.py +53 -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,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dora-openarm-cell-lifter
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: dora-rs node to control OpenArm Cell Lifter
|
|
5
|
+
Author: Enactic, Inc.
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Repository, https://github.com/enactic/dora-openarm-cell-lifter
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: dora-rs>=0.5.0
|
|
12
|
+
Requires-Dist: openarm-can
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# dora-openarm-cell-lifter
|
|
16
|
+
|
|
17
|
+
A [dora-rs](https://dora-rs.ai/) node to control OpenArm Cell Lifter.
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
Licensed under the Apache License 2.0. See [LICENSE](LICENSE) for details.
|
|
22
|
+
|
|
23
|
+
Copyright 2026 Enactic, Inc.
|
|
24
|
+
|
|
25
|
+
## Code of Conduct
|
|
26
|
+
|
|
27
|
+
All participation in the OpenArm project is governed by our [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# dora-openarm-cell-lifter
|
|
2
|
+
|
|
3
|
+
A [dora-rs](https://dora-rs.ai/) node to control OpenArm Cell Lifter.
|
|
4
|
+
|
|
5
|
+
## License
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License 2.0. See [LICENSE](LICENSE) for details.
|
|
8
|
+
|
|
9
|
+
Copyright 2026 Enactic, Inc.
|
|
10
|
+
|
|
11
|
+
## Code of Conduct
|
|
12
|
+
|
|
13
|
+
All participation in the OpenArm project is governed by our [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
@@ -0,0 +1,55 @@
|
|
|
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 = "dora-openarm-cell-lifter"
|
|
21
|
+
version = "0.1.0"
|
|
22
|
+
authors = [{ name = "Enactic, Inc." }]
|
|
23
|
+
description = "dora-rs node to control OpenArm Cell Lifter"
|
|
24
|
+
license = { text = "Apache-2.0" }
|
|
25
|
+
readme = "README.md"
|
|
26
|
+
requires-python = ">=3.10"
|
|
27
|
+
|
|
28
|
+
dependencies = ["dora-rs >= 0.5.0", "openarm-can"]
|
|
29
|
+
|
|
30
|
+
[dependency-groups]
|
|
31
|
+
dev = [
|
|
32
|
+
"pytest >= 8.1.1",
|
|
33
|
+
"ruff == 0.14.11", # sync with .pre-commit-config.yaml
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.scripts]
|
|
37
|
+
dora-openarm-cell-lifter = "dora_openarm_cell_lifter.main:main"
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Repository = "https://github.com/enactic/dora-openarm-cell-lifter"
|
|
41
|
+
|
|
42
|
+
[tool.setuptools]
|
|
43
|
+
package-dir = {"" = "src"}
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.packages.find]
|
|
46
|
+
where = ["src"]
|
|
47
|
+
|
|
48
|
+
[tool.ruff.lint]
|
|
49
|
+
extend-select = [
|
|
50
|
+
"D", # pydocstyle
|
|
51
|
+
"UP"
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[tool.ruff.lint.per-file-ignores]
|
|
55
|
+
"!src/**.py" = ["D"]
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
"""dora-rs node to control OpenArm Cell Lifter."""
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
|
|
19
|
+
# Define the path to the README file relative to the package directory
|
|
20
|
+
readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.md")
|
|
21
|
+
|
|
22
|
+
# Read the content of the README file
|
|
23
|
+
try:
|
|
24
|
+
with open(readme_path, encoding="utf-8") as f:
|
|
25
|
+
__doc__ = f.read()
|
|
26
|
+
except FileNotFoundError:
|
|
27
|
+
__doc__ = "README file not found."
|
|
@@ -0,0 +1,391 @@
|
|
|
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
|
+
"""dora-rs node to control OpenArm Cell Lifter."""
|
|
16
|
+
|
|
17
|
+
import argparse
|
|
18
|
+
import dora
|
|
19
|
+
import openarm_can as oa
|
|
20
|
+
import math
|
|
21
|
+
import os
|
|
22
|
+
import time
|
|
23
|
+
|
|
24
|
+
import pyarrow as pa
|
|
25
|
+
|
|
26
|
+
# --- Constants ---
|
|
27
|
+
VEL_MAX = 30.0
|
|
28
|
+
POS_MIN = 0.0
|
|
29
|
+
HOLD_POS_VEL = 1.0
|
|
30
|
+
|
|
31
|
+
# Threshold for joystick deadzone
|
|
32
|
+
JOYSTICK_DEADZONE = 0.15
|
|
33
|
+
# Scaling factor for velocity calculation (1.0 - 0.15)
|
|
34
|
+
JOYSTICK_RANGE = 0.85
|
|
35
|
+
|
|
36
|
+
# Torque threshold for anomaly detection (collision / mechanical limit)
|
|
37
|
+
TORQUE_LIMIT = 1.5
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class PositionUnwrapper:
|
|
41
|
+
"""Class to handle wrap-around of multi-turn motor encoders (-4pi to 4pi)."""
|
|
42
|
+
|
|
43
|
+
def __init__(self, wrap_range=8.0 * math.pi, wrap_threshold=4.0 * math.pi):
|
|
44
|
+
"""Initialize the tracker for wrapped encoder positions."""
|
|
45
|
+
self._wrap_range = wrap_range
|
|
46
|
+
self._wrap_threshold = wrap_threshold
|
|
47
|
+
self._prev_raw = None
|
|
48
|
+
self._continuous_pos = 0.0
|
|
49
|
+
|
|
50
|
+
def update(self, current_raw):
|
|
51
|
+
"""Update the continuous position estimate from the raw encoder value."""
|
|
52
|
+
if self._prev_raw is None:
|
|
53
|
+
self._prev_raw = current_raw
|
|
54
|
+
self._continuous_pos = current_raw
|
|
55
|
+
return self._continuous_pos
|
|
56
|
+
|
|
57
|
+
diff = current_raw - self._prev_raw
|
|
58
|
+
|
|
59
|
+
# Unwrap logic for 8pi range
|
|
60
|
+
if diff > self._wrap_threshold:
|
|
61
|
+
diff -= self._wrap_range
|
|
62
|
+
elif diff < -self._wrap_threshold:
|
|
63
|
+
diff += self._wrap_range
|
|
64
|
+
|
|
65
|
+
self._continuous_pos += diff
|
|
66
|
+
self._prev_raw = current_raw
|
|
67
|
+
return self._continuous_pos
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _calc_next_elevation(current_elevation, velocity, dt, lead_length):
|
|
71
|
+
return current_elevation + velocity * dt * lead_length / (2.0 * math.pi)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _calc_elevation_action_from_joystick(
|
|
75
|
+
current_elevation, joystick_y, dt, lead_length, speed_factor=1.0
|
|
76
|
+
):
|
|
77
|
+
if joystick_y > JOYSTICK_DEADZONE:
|
|
78
|
+
applied_vel = VEL_MAX * (abs(joystick_y - JOYSTICK_DEADZONE) / JOYSTICK_RANGE)
|
|
79
|
+
applied_vel *= speed_factor
|
|
80
|
+
return _calc_next_elevation(
|
|
81
|
+
current_elevation, applied_vel, dt, lead_length
|
|
82
|
+
), applied_vel
|
|
83
|
+
|
|
84
|
+
elif joystick_y < -JOYSTICK_DEADZONE:
|
|
85
|
+
applied_vel = VEL_MAX * (abs(joystick_y + JOYSTICK_DEADZONE) / JOYSTICK_RANGE)
|
|
86
|
+
applied_vel *= speed_factor
|
|
87
|
+
return _calc_next_elevation(
|
|
88
|
+
current_elevation, -applied_vel, dt, lead_length
|
|
89
|
+
), applied_vel
|
|
90
|
+
|
|
91
|
+
else:
|
|
92
|
+
return None, 0.0
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _dora_main(lifter, args):
|
|
96
|
+
pos_max = (args.screw_length / args.lead_length) * 2.0 * math.pi
|
|
97
|
+
slow_margin = pos_max * 0.05
|
|
98
|
+
|
|
99
|
+
node = dora.Node()
|
|
100
|
+
|
|
101
|
+
lifter_pos = 0.0
|
|
102
|
+
lifter_tau = 0.0
|
|
103
|
+
|
|
104
|
+
joystick_y = 0.0
|
|
105
|
+
|
|
106
|
+
for motor in lifter.get_arm().get_motors():
|
|
107
|
+
lifter_pos = motor.get_position()
|
|
108
|
+
lifter_tau = motor.get_torque()
|
|
109
|
+
|
|
110
|
+
unwrapper = PositionUnwrapper()
|
|
111
|
+
|
|
112
|
+
calibrated = False
|
|
113
|
+
offset_pos = 0.0
|
|
114
|
+
|
|
115
|
+
# State management variables
|
|
116
|
+
jammed_direction = None
|
|
117
|
+
hold_pos = 0.0
|
|
118
|
+
hold_elevation = 0.0
|
|
119
|
+
is_stopping = False
|
|
120
|
+
|
|
121
|
+
prev_time = time.time()
|
|
122
|
+
|
|
123
|
+
for event in node:
|
|
124
|
+
if event["type"] != "INPUT":
|
|
125
|
+
continue
|
|
126
|
+
|
|
127
|
+
event_id = event.get("id")
|
|
128
|
+
|
|
129
|
+
value = event.get("value")
|
|
130
|
+
if value is None:
|
|
131
|
+
continue
|
|
132
|
+
|
|
133
|
+
if event_id == "joystick_y":
|
|
134
|
+
py_value = value[0].as_py()
|
|
135
|
+
joystick_y = py_value
|
|
136
|
+
elif event_id == "command":
|
|
137
|
+
command = event["value"][0].as_py()
|
|
138
|
+
if command == "lifter-up":
|
|
139
|
+
joystick_y = 0.5
|
|
140
|
+
elif command == "lifter-down":
|
|
141
|
+
joystick_y = -0.5
|
|
142
|
+
else:
|
|
143
|
+
joystick_y = 0
|
|
144
|
+
elif event_id == "move_elevation":
|
|
145
|
+
pass # handled in normal operation phase
|
|
146
|
+
elif event_id == "tick":
|
|
147
|
+
pass
|
|
148
|
+
else:
|
|
149
|
+
continue
|
|
150
|
+
|
|
151
|
+
# --- Calibration Phase ---
|
|
152
|
+
if not calibrated:
|
|
153
|
+
lifter.get_arm().posvel_control_all(
|
|
154
|
+
[oa.PosVelParam(q=POS_MIN - 1000.0, dq=VEL_MAX / 5.0)]
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
lifter.recv_all(1000) # Wait up to 1ms for the motor response
|
|
158
|
+
|
|
159
|
+
for motor in lifter.get_arm().get_motors():
|
|
160
|
+
lifter_pos = motor.get_position()
|
|
161
|
+
lifter_tau = motor.get_torque()
|
|
162
|
+
if abs(lifter_tau) > 1.0:
|
|
163
|
+
offset_pos = lifter_pos
|
|
164
|
+
calibrated = True
|
|
165
|
+
lifter.get_arm().posvel_control_all(
|
|
166
|
+
[oa.PosVelParam(q=pos_max, dq=VEL_MAX / 20.0)]
|
|
167
|
+
)
|
|
168
|
+
time.sleep(0.2)
|
|
169
|
+
continue
|
|
170
|
+
|
|
171
|
+
# --- Normal Operation Phase ---
|
|
172
|
+
now = time.time()
|
|
173
|
+
dt = now - prev_time
|
|
174
|
+
prev_time = now
|
|
175
|
+
|
|
176
|
+
lifter.recv_all()
|
|
177
|
+
|
|
178
|
+
for motor in lifter.get_arm().get_motors():
|
|
179
|
+
lifter_pos = motor.get_position()
|
|
180
|
+
lifter_tau = motor.get_torque()
|
|
181
|
+
obs_position = unwrapper.update(lifter_pos) - offset_pos
|
|
182
|
+
# obs: elevation(mm)
|
|
183
|
+
obs_elevation = obs_position / (2.0 * math.pi) * args.lead_length
|
|
184
|
+
node.send_output(
|
|
185
|
+
"elevation_observation", pa.array([obs_elevation], type=pa.float32())
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
# Calculate distance to the nearest physical limit (lower 0.0 or upper pos_max)
|
|
189
|
+
distance_to_min = obs_position - 0.0
|
|
190
|
+
distance_to_max = pos_max - obs_position
|
|
191
|
+
distance_to_edge = min(distance_to_min, distance_to_max)
|
|
192
|
+
|
|
193
|
+
# Calculate the linear deceleration factor
|
|
194
|
+
if distance_to_edge < slow_margin:
|
|
195
|
+
# Clamp to prevent negative values due to slight sensor noise
|
|
196
|
+
clamped_distance = max(0.0, distance_to_edge)
|
|
197
|
+
# Linear interpolation: 0.25x at the edge, 1.0x at the slow_margin boundary
|
|
198
|
+
speed_factor = 0.25 + 0.75 * (clamped_distance / slow_margin)
|
|
199
|
+
else:
|
|
200
|
+
speed_factor = 1.0
|
|
201
|
+
|
|
202
|
+
# --- Elevation (mm) ---
|
|
203
|
+
if event_id == "move_elevation":
|
|
204
|
+
elevation = max(0.0, min(args.screw_length, value[0].as_py()))
|
|
205
|
+
target_position = elevation / args.lead_length * 2.0 * math.pi + offset_pos
|
|
206
|
+
is_stopping = False
|
|
207
|
+
|
|
208
|
+
node.send_output(
|
|
209
|
+
"elevation_action",
|
|
210
|
+
pa.array([elevation], type=pa.float32()),
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
lifter.get_arm().posvel_control_all(
|
|
214
|
+
[oa.PosVelParam(q=target_position, dq=VEL_MAX * speed_factor)]
|
|
215
|
+
)
|
|
216
|
+
continue
|
|
217
|
+
|
|
218
|
+
# --- 1. Jam detection and direction memorization ---
|
|
219
|
+
if abs(lifter_tau) > TORQUE_LIMIT:
|
|
220
|
+
if jammed_direction is None:
|
|
221
|
+
# Memorize the exact position at impact to prevent hunting
|
|
222
|
+
hold_pos = obs_position + offset_pos # Use the unwrapper position
|
|
223
|
+
hold_elevation = obs_elevation # obs elevation is calculated from the unwrapper lifter_pos(hold_pos)
|
|
224
|
+
|
|
225
|
+
if joystick_y > JOYSTICK_DEADZONE:
|
|
226
|
+
jammed_direction = "UP"
|
|
227
|
+
elif joystick_y < -JOYSTICK_DEADZONE:
|
|
228
|
+
jammed_direction = "DOWN"
|
|
229
|
+
else:
|
|
230
|
+
jammed_direction = "UNKNOWN"
|
|
231
|
+
else:
|
|
232
|
+
# Do not release the lock if the joystick is held in the same direction,
|
|
233
|
+
# even if the torque drops to a normal value
|
|
234
|
+
if jammed_direction == "UP" and joystick_y <= JOYSTICK_DEADZONE:
|
|
235
|
+
jammed_direction = None
|
|
236
|
+
elif jammed_direction == "DOWN" and joystick_y >= -JOYSTICK_DEADZONE:
|
|
237
|
+
jammed_direction = None
|
|
238
|
+
elif jammed_direction == "UNKNOWN":
|
|
239
|
+
jammed_direction = None
|
|
240
|
+
|
|
241
|
+
# --- 2. Action determination (One-way block, reverse allow, linear deceleration at limits) ---
|
|
242
|
+
|
|
243
|
+
# UP operation
|
|
244
|
+
if joystick_y > JOYSTICK_DEADZONE:
|
|
245
|
+
is_stopping = False
|
|
246
|
+
if jammed_direction in ["UP", "UNKNOWN"]:
|
|
247
|
+
# Hold silently at the memorized position while jammed in the UP direction
|
|
248
|
+
node.send_output(
|
|
249
|
+
"elevation_action",
|
|
250
|
+
pa.array([hold_elevation], type=pa.float32()),
|
|
251
|
+
)
|
|
252
|
+
lifter.get_arm().posvel_control_all(
|
|
253
|
+
[oa.PosVelParam(q=hold_pos, dq=0.0)]
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
else:
|
|
257
|
+
action_elevation, applied_vel = _calc_elevation_action_from_joystick(
|
|
258
|
+
obs_elevation,
|
|
259
|
+
joystick_y,
|
|
260
|
+
dt,
|
|
261
|
+
args.lead_length,
|
|
262
|
+
speed_factor,
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
node.send_output(
|
|
266
|
+
"elevation_action",
|
|
267
|
+
pa.array([action_elevation], type=pa.float32()),
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
# Drive toward the top stroke limit (positive joystick_y = up)
|
|
271
|
+
lifter.get_arm().posvel_control_all(
|
|
272
|
+
[oa.PosVelParam(q=pos_max + offset_pos, dq=applied_vel)]
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
# DOWN operation
|
|
276
|
+
elif joystick_y < -JOYSTICK_DEADZONE:
|
|
277
|
+
is_stopping = False
|
|
278
|
+
if jammed_direction in ["DOWN", "UNKNOWN"]:
|
|
279
|
+
# Hold silently at the memorized position while jammed in the DOWN direction
|
|
280
|
+
|
|
281
|
+
node.send_output(
|
|
282
|
+
"elevation_action",
|
|
283
|
+
pa.array([hold_elevation], type=pa.float32()),
|
|
284
|
+
)
|
|
285
|
+
lifter.get_arm().posvel_control_all(
|
|
286
|
+
[oa.PosVelParam(q=hold_pos, dq=0.0)]
|
|
287
|
+
)
|
|
288
|
+
else:
|
|
289
|
+
action_elevation, applied_vel = _calc_elevation_action_from_joystick(
|
|
290
|
+
obs_elevation,
|
|
291
|
+
joystick_y,
|
|
292
|
+
dt,
|
|
293
|
+
args.lead_length,
|
|
294
|
+
speed_factor,
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
node.send_output(
|
|
298
|
+
"elevation_action",
|
|
299
|
+
pa.array([action_elevation], type=pa.float32()),
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
# Drive toward the bottom stroke limit (negative joystick_y = down)
|
|
303
|
+
lifter.get_arm().posvel_control_all(
|
|
304
|
+
[oa.PosVelParam(q=offset_pos, dq=applied_vel)]
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
# STOP (Within deadzone)
|
|
308
|
+
else:
|
|
309
|
+
if not is_stopping:
|
|
310
|
+
# Memorize the exact position at the moment the joystick is released
|
|
311
|
+
hold_pos = obs_position + offset_pos # Use the unwrapper position
|
|
312
|
+
hold_elevation = obs_elevation # obs elevation is calculated from the unwrapper position(hold_pos)
|
|
313
|
+
is_stopping = True
|
|
314
|
+
|
|
315
|
+
node.send_output(
|
|
316
|
+
"elevation_action",
|
|
317
|
+
pa.array([hold_elevation], type=pa.float32()),
|
|
318
|
+
)
|
|
319
|
+
# Hold position with a small velocity to maintain stiffness, preventing drift due to gravity or disturbances
|
|
320
|
+
lifter.get_arm().posvel_control_all(
|
|
321
|
+
[oa.PosVelParam(q=hold_pos, dq=HOLD_POS_VEL)]
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
def main():
|
|
326
|
+
"""Control the OpenArm Lifter using joystick inputs.
|
|
327
|
+
|
|
328
|
+
observation:
|
|
329
|
+
elevation (mm) from the bottom, converted from motor angle (rad) using the lead length.
|
|
330
|
+
|
|
331
|
+
action:
|
|
332
|
+
Estimated next elevation (mm), calculated from observation and `applied_vel`.
|
|
333
|
+
`applied_vel` is reduced linearly near the stroke limits (within `SLOW_MARGIN`) to avoid collision.
|
|
334
|
+
`action` is only output when the joystick is operated.
|
|
335
|
+
"""
|
|
336
|
+
parser = argparse.ArgumentParser(description="Control the OpenArm Lifter")
|
|
337
|
+
parser.add_argument(
|
|
338
|
+
"--can-interface",
|
|
339
|
+
default=os.getenv("CAN_INTERFACE", "can2"),
|
|
340
|
+
help="The CAN interface name",
|
|
341
|
+
)
|
|
342
|
+
parser.add_argument(
|
|
343
|
+
"--lead-length",
|
|
344
|
+
default=float(os.getenv("LEAD_LENGTH", 5.0)),
|
|
345
|
+
help="Lead screw lead length in mm/rev",
|
|
346
|
+
type=float,
|
|
347
|
+
)
|
|
348
|
+
parser.add_argument(
|
|
349
|
+
"--screw-length",
|
|
350
|
+
default=float(os.getenv("SCREW_LENGTH", 300.0)),
|
|
351
|
+
help="Lead screw stroke length in mm",
|
|
352
|
+
type=float,
|
|
353
|
+
)
|
|
354
|
+
args = parser.parse_args()
|
|
355
|
+
|
|
356
|
+
lifter = oa.OpenArm(args.can_interface, enable_fd=True)
|
|
357
|
+
|
|
358
|
+
motor_types = [oa.MotorType.DM4310]
|
|
359
|
+
send_ids = [0x0A]
|
|
360
|
+
recv_ids = [0x1A]
|
|
361
|
+
control_modes = [oa.ControlMode.POS_VEL]
|
|
362
|
+
|
|
363
|
+
lifter.init_arm_motors(motor_types, send_ids, recv_ids, control_modes)
|
|
364
|
+
lifter.set_callback_mode_all(oa.CallbackMode.STATE)
|
|
365
|
+
|
|
366
|
+
lifter.enable_all()
|
|
367
|
+
lifter.recv_all()
|
|
368
|
+
|
|
369
|
+
_dora_main(lifter, args)
|
|
370
|
+
|
|
371
|
+
# Move the lifter down to the mechanical stop before disabling
|
|
372
|
+
for _ in range(200):
|
|
373
|
+
lifter.get_arm().posvel_control_all(
|
|
374
|
+
[oa.PosVelParam(q=POS_MIN - 1000.0, dq=VEL_MAX / 1.0)]
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
lifter.recv_all(1000) # Wait up to 1ms for the motor response
|
|
378
|
+
time.sleep(0.05) # Small delay to allow the motor to move
|
|
379
|
+
|
|
380
|
+
for motor in lifter.get_arm().get_motors():
|
|
381
|
+
lifter_tau = motor.get_torque()
|
|
382
|
+
if abs(lifter_tau) > 1.0:
|
|
383
|
+
break
|
|
384
|
+
# stops the shutdown homing when abs(lifter_tau) > 1.0
|
|
385
|
+
|
|
386
|
+
# Disable motors for safety after exiting the loop
|
|
387
|
+
lifter.disable_all()
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
if __name__ == "__main__":
|
|
391
|
+
main()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dora-openarm-cell-lifter
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: dora-rs node to control OpenArm Cell Lifter
|
|
5
|
+
Author: Enactic, Inc.
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Repository, https://github.com/enactic/dora-openarm-cell-lifter
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: dora-rs>=0.5.0
|
|
12
|
+
Requires-Dist: openarm-can
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# dora-openarm-cell-lifter
|
|
16
|
+
|
|
17
|
+
A [dora-rs](https://dora-rs.ai/) node to control OpenArm Cell Lifter.
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
Licensed under the Apache License 2.0. See [LICENSE](LICENSE) for details.
|
|
22
|
+
|
|
23
|
+
Copyright 2026 Enactic, Inc.
|
|
24
|
+
|
|
25
|
+
## Code of Conduct
|
|
26
|
+
|
|
27
|
+
All participation in the OpenArm project is governed by our [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/dora_openarm_cell_lifter/__init__.py
|
|
5
|
+
src/dora_openarm_cell_lifter/main.py
|
|
6
|
+
src/dora_openarm_cell_lifter.egg-info/PKG-INFO
|
|
7
|
+
src/dora_openarm_cell_lifter.egg-info/SOURCES.txt
|
|
8
|
+
src/dora_openarm_cell_lifter.egg-info/dependency_links.txt
|
|
9
|
+
src/dora_openarm_cell_lifter.egg-info/entry_points.txt
|
|
10
|
+
src/dora_openarm_cell_lifter.egg-info/requires.txt
|
|
11
|
+
src/dora_openarm_cell_lifter.egg-info/top_level.txt
|
|
12
|
+
tests/test_joystick_y_elevation.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dora_openarm_cell_lifter
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
|
|
16
|
+
import pytest
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
import dora_openarm_cell_lifter.main as main_module # noqa: E402
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.mark.parametrize(
|
|
23
|
+
("joystick_y", "expected_elevation", "expected_velocity"),
|
|
24
|
+
[
|
|
25
|
+
(1.0, 28.8732414637843, 30.0),
|
|
26
|
+
(-1.0, -18.8732414637843, 30.0),
|
|
27
|
+
],
|
|
28
|
+
)
|
|
29
|
+
def test_joystick_y_produces_expected_elevation_action(
|
|
30
|
+
joystick_y, expected_elevation, expected_velocity
|
|
31
|
+
):
|
|
32
|
+
action_elevation, applied_vel = main_module._calc_elevation_action_from_joystick(
|
|
33
|
+
current_elevation=5.0,
|
|
34
|
+
joystick_y=joystick_y,
|
|
35
|
+
dt=1.0,
|
|
36
|
+
lead_length=5.0,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
assert action_elevation == pytest.approx(expected_elevation)
|
|
40
|
+
assert applied_vel == pytest.approx(expected_velocity)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@pytest.mark.parametrize("joystick_y", [-0.15, 0.0, 0.15])
|
|
44
|
+
def test_deadzone_joystick_y_does_not_produce_elevation_action(joystick_y):
|
|
45
|
+
action_elevation, applied_vel = main_module._calc_elevation_action_from_joystick(
|
|
46
|
+
current_elevation=5.0,
|
|
47
|
+
joystick_y=joystick_y,
|
|
48
|
+
dt=1.0,
|
|
49
|
+
lead_length=5.0,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
assert action_elevation is None
|
|
53
|
+
assert applied_vel == 0.0
|