openflex-driver 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. openflex_driver-1.0.0/LICENSE +52 -0
  2. openflex_driver-1.0.0/MANIFEST.in +26 -0
  3. openflex_driver-1.0.0/PKG-INFO +339 -0
  4. openflex_driver-1.0.0/README.md +308 -0
  5. openflex_driver-1.0.0/pyproject.toml +68 -0
  6. openflex_driver-1.0.0/setup.cfg +4 -0
  7. openflex_driver-1.0.0/setup.py +171 -0
  8. openflex_driver-1.0.0/src/openflex_driver/__init__.py +467 -0
  9. openflex_driver-1.0.0/src/openflex_driver/_lib/__init__.py +12 -0
  10. openflex_driver-1.0.0/src/openflex_driver/_lib/auto_calibration.cpython-310-x86_64-linux-gnu.so +0 -0
  11. openflex_driver-1.0.0/src/openflex_driver/_lib/can_comm.cpython-310-x86_64-linux-gnu.so +0 -0
  12. openflex_driver-1.0.0/src/openflex_driver/_lib/can_utils.cpython-310-x86_64-linux-gnu.so +0 -0
  13. openflex_driver-1.0.0/src/openflex_driver/_lib/lift_canopen.cpython-310-x86_64-linux-gnu.so +0 -0
  14. openflex_driver-1.0.0/src/openflex_driver/_lib/log_utils.cpython-310-x86_64-linux-gnu.so +0 -0
  15. openflex_driver-1.0.0/src/openflex_driver/_lib/motor_config_loader.cpython-310-x86_64-linux-gnu.so +0 -0
  16. openflex_driver-1.0.0/src/openflex_driver/_lib/motor_control.cpython-310-x86_64-linux-gnu.so +0 -0
  17. openflex_driver-1.0.0/src/openflex_driver/_lib/motor_manager.cpython-310-x86_64-linux-gnu.so +0 -0
  18. openflex_driver-1.0.0/src/openflex_driver/_lib/swerve_kinematics.cpython-310-x86_64-linux-gnu.so +0 -0
  19. openflex_driver-1.0.0/src/openflex_driver/_lib/teleop_core.cpython-310-x86_64-linux-gnu.so +0 -0
  20. openflex_driver-1.0.0/src/openflex_driver/_lib/um_motor_manager.cpython-310-x86_64-linux-gnu.so +0 -0
  21. openflex_driver-1.0.0/src/openflex_driver/arm.py +1277 -0
  22. openflex_driver-1.0.0/src/openflex_driver/chassis.py +1279 -0
  23. openflex_driver-1.0.0/src/openflex_driver/column.py +1531 -0
  24. openflex_driver-1.0.0/src/openflex_driver/config/__init__.py +12 -0
  25. openflex_driver-1.0.0/src/openflex_driver/config/direction_config.yaml +57 -0
  26. openflex_driver-1.0.0/src/openflex_driver/config/lift_calibration.yaml +3 -0
  27. openflex_driver-1.0.0/src/openflex_driver/config/motor_config.yaml +94 -0
  28. openflex_driver-1.0.0/src/openflex_driver/exceptions.py +491 -0
  29. openflex_driver-1.0.0/src/openflex_driver/head.py +850 -0
  30. openflex_driver-1.0.0/src/openflex_driver/motor_inventory.py +66 -0
  31. openflex_driver-1.0.0/src/openflex_driver/robot.py +1247 -0
  32. openflex_driver-1.0.0/src/openflex_driver.egg-info/PKG-INFO +339 -0
  33. openflex_driver-1.0.0/src/openflex_driver.egg-info/SOURCES.txt +34 -0
  34. openflex_driver-1.0.0/src/openflex_driver.egg-info/dependency_links.txt +1 -0
  35. openflex_driver-1.0.0/src/openflex_driver.egg-info/requires.txt +4 -0
  36. openflex_driver-1.0.0/src/openflex_driver.egg-info/top_level.txt +1 -0
@@ -0,0 +1,52 @@
1
+ Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
2
+
3
+ Copyright (c) 2025 Wei Lindong
4
+
5
+ This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
6
+
7
+ To view a copy of this license, visit:
8
+ http://creativecommons.org/licenses/by-nc-sa/4.0/
9
+
10
+ or send a letter to:
11
+ Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
12
+
13
+ ---
14
+
15
+ You are free to:
16
+
17
+ - Share: copy and redistribute the material in any medium or format
18
+ - Adapt: remix, transform, and build upon the material
19
+
20
+ Under the following terms:
21
+
22
+ - Attribution: You must give appropriate credit, provide a link to the license,
23
+ and indicate if changes were made. You may do so in any reasonable manner,
24
+ but not in any way that suggests the licensor endorses you or your use.
25
+
26
+ - NonCommercial: You may not use the material for commercial purposes.
27
+
28
+ - ShareAlike: If you remix, transform, or build upon the material, you must
29
+ distribute your contributions under the same license as the original.
30
+
31
+ - No additional restrictions: You may not apply legal terms or technological
32
+ measures that legally restrict others from doing anything the license permits.
33
+
34
+ Notices:
35
+
36
+ - You do not have to comply with the license for elements of the material in
37
+ the public domain or where your use is permitted by an applicable exception
38
+ or limitation.
39
+
40
+ - No warranties are given. The license may not give you all of the permissions
41
+ necessary for your intended use. For example, other rights such as publicity,
42
+ privacy, or moral rights may limit how you use the material.
43
+
44
+ ---
45
+
46
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
52
+ THE SOFTWARE.
@@ -0,0 +1,26 @@
1
+ # 包含项目元数据
2
+ include README.md
3
+ include LICENSE
4
+
5
+ # 包含配置文件
6
+ recursive-include src/openflex_driver/config *.yaml
7
+
8
+ # 只包含 _lib 的 __init__.py 和已编译的 .so 文件
9
+ include src/openflex_driver/_lib/__init__.py
10
+ recursive-include src/openflex_driver/_lib *.so
11
+
12
+ # 排除 _lib 中的 .py 源码文件(除了 __init__.py)
13
+ global-exclude src/openflex_driver/_lib/*.py
14
+ include src/openflex_driver/_lib/__init__.py
15
+
16
+ # 完全排除 _backup_py 目录
17
+ prune src/openflex_driver/_lib/_backup_py
18
+
19
+ # 排除本地辅助脚本
20
+ exclude build_so.py
21
+ exclude clean_so.py
22
+
23
+ # 排除其他不需要的文件
24
+ global-exclude __pycache__
25
+ global-exclude *.py[cod]
26
+ global-exclude .DS_Store
@@ -0,0 +1,339 @@
1
+ Metadata-Version: 2.4
2
+ Name: openflex-driver
3
+ Version: 1.0.0
4
+ Summary: Python SDK for OpenFlex robotic arm control via CAN bus
5
+ Author-email: Wei Lindong <weilindong02@gmail.com>
6
+ License-Expression: CC-BY-NC-SA-4.0
7
+ Project-URL: Homepage, https://www.openarmx.com
8
+ Project-URL: Documentation, https://docs.openarmx.com
9
+ Project-URL: Repository, https://www.openarmx.com
10
+ Project-URL: Issues, https://www.openarmx.com
11
+ Keywords: robotics,can-bus,motor-control,openflex,openarmx
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: python-can>=4.0.0
27
+ Requires-Dist: PyYAML>=5.4.0
28
+ Requires-Dist: numpy>=1.21.0
29
+ Requires-Dist: pin>=2.6.0
30
+ Dynamic: license-file
31
+
32
+ # OpenFlex Driver
33
+
34
+ > **Developed by Chengdu Changshu Robotics Co., Ltd.**
35
+
36
+ OpenFlex Driver is the Python SDK for OpenFlex / OpenArmX full-body robot control over CAN bus. It provides high-level interfaces for dual arms, head, lift column, and swerve chassis, while also exposing lower-level motor, CAN, calibration, and teleoperation utilities for integration and research workflows.
37
+
38
+ The package is designed for Linux robots using SocketCAN-compatible CAN adapters and Robstride / CANopen motor controllers.
39
+
40
+ ## Features
41
+
42
+ - Dual-arm control through `Arm` and `Robot`
43
+ - Head control with yaw / pitch joints
44
+ - Lift column control over CANopen CiA402
45
+ - Four-wheel swerve chassis control with steering and driving modules
46
+ - MIT and CSP motor control modes
47
+ - Motor enable / disable, mode switching, status reading, zero calibration
48
+ - CAN interface discovery and setup helpers
49
+ - Automatic and passive zero calibration utilities
50
+ - VR teleoperation / IK interface based on Pinocchio
51
+ - Binary wheel build support with Cython-compiled internal modules
52
+
53
+ ## Supported Components
54
+
55
+ | Component | Interface | Default CAN | Notes |
56
+ |---|---|---:|---|
57
+ | Right arm | `Arm`, `Robot.right_arm` | `can0` | Robstride arm motors, IDs 1-8 |
58
+ | Left arm | `Arm`, `Robot.left_arm` | `can1` | Robstride arm motors, IDs 1-8 |
59
+ | Head | `Head`, `Robot.head` | `can2` | Yaw ID 1, pitch ID 2 |
60
+ | Lift column | `Column`, `Robot.column` | `can3` | CANopen CiA402 node, default ID 16 |
61
+ | Chassis driving | `Chassis` | `can4` | UM wheel motors, default IDs 1-4 |
62
+ | Chassis steering | `Chassis` | `can5` | RS steering motors, default IDs 5-8 |
63
+
64
+ ## Installation
65
+
66
+ Install from PyPI:
67
+
68
+ ```bash
69
+ pip install openflex-driver
70
+ ```
71
+
72
+ For local development:
73
+
74
+ ```bash
75
+ git clone <your-repository-url>
76
+ cd openflex_driver
77
+ python3 -m pip install -e .
78
+ ```
79
+
80
+ ## Requirements
81
+
82
+ - Linux with SocketCAN support
83
+ - Python >= 3.9
84
+ - `python-can >= 4.0.0`
85
+ - `PyYAML >= 5.4.0`
86
+ - `numpy >= 1.21.0`
87
+ - `pin >= 2.6.0` for teleoperation / IK functionality
88
+ - Cython is required when building wheels from source
89
+
90
+ ## CAN Setup
91
+
92
+ The driver can try to enable CAN interfaces automatically when `auto_enable_can=True`. For manual setup, use standard SocketCAN commands:
93
+
94
+ ```bash
95
+ sudo ip link set can0 up type can bitrate 1000000
96
+ sudo ip link set can1 up type can bitrate 1000000
97
+ sudo ip link set can2 up type can bitrate 1000000
98
+ sudo ip link set can3 up type can bitrate 1000000
99
+ sudo ip link set can4 up type can bitrate 1000000
100
+ sudo ip link set can5 up type can bitrate 1000000
101
+ ```
102
+
103
+ Check available CAN interfaces:
104
+
105
+ ```python
106
+ from openflex_driver import get_available_can_interfaces, verify_can_interface
107
+
108
+ print(get_available_can_interfaces())
109
+ print(verify_can_interface("can0"))
110
+ ```
111
+
112
+ ## Quick Start
113
+
114
+ ### Single Arm
115
+
116
+ ```python
117
+ from openflex_driver import Arm
118
+
119
+ arm = Arm(can_channel="can0", side="right")
120
+
121
+ try:
122
+ arm.enable_arm_motors()
123
+ arm.set_mode("mit")
124
+ arm.move_to_mit(
125
+ motor_id=1,
126
+ position=0.3,
127
+ velocity=0.0,
128
+ torque=0.0,
129
+ kp=20.0,
130
+ kd=1.0,
131
+ )
132
+ status = arm.get_motor_status(motor_id=1)
133
+ print(status)
134
+ finally:
135
+ arm.disable_arm_motors()
136
+ arm.close()
137
+ ```
138
+
139
+ ### Dual Arms and Full Robot
140
+
141
+ ```python
142
+ from openflex_driver import Robot
143
+
144
+ robot = Robot(
145
+ right_arm_can="can0",
146
+ left_arm_can="can1",
147
+ )
148
+
149
+ try:
150
+ robot.enable_right_arm()
151
+ robot.enable_left_arm()
152
+ robot.right_arm.set_mode("mit")
153
+ robot.left_arm.set_mode("mit")
154
+
155
+ robot.move_to_mit_right_arm(
156
+ motor_id=2,
157
+ position=0.2,
158
+ kp=20.0,
159
+ kd=1.0,
160
+ )
161
+ robot.move_to_mit_left_arm(
162
+ motor_id=2,
163
+ position=0.2,
164
+ kp=20.0,
165
+ kd=1.0,
166
+ )
167
+
168
+ robot.show_arms_status()
169
+ finally:
170
+ robot.disable_right_arm()
171
+ robot.disable_left_arm()
172
+ robot.shutdown()
173
+ ```
174
+
175
+ To manage optional full-body components from `Robot`, pass `head_can`, `column_can`, `steering_can`, and `driving_can`, then initialize each component according to your hardware startup sequence.
176
+
177
+ ## Component Examples
178
+
179
+ ### Head
180
+
181
+ ```python
182
+ from openflex_driver import Head, JOINT_YAW, JOINT_PITCH
183
+
184
+ head = Head(can_channel="can2")
185
+
186
+ try:
187
+ head.connect()
188
+ head.enable()
189
+ head.move_to_mit(motor_id=JOINT_YAW, position=0.2)
190
+ head.move_to_mit(motor_id=JOINT_PITCH, position=-0.1)
191
+ print(head.get_joint_status())
192
+ finally:
193
+ head.disable()
194
+ head.disconnect()
195
+ ```
196
+
197
+ ### Lift Column
198
+
199
+ ```python
200
+ from openflex_driver import Column
201
+
202
+ column = Column(can_interface="can3", node_id=16)
203
+
204
+ try:
205
+ column.connect()
206
+ column.enable()
207
+ column.switch_to_position_mode()
208
+ column.move_to_user_position(0.15)
209
+ print(column.get_status())
210
+ column.stop_motion()
211
+ finally:
212
+ column.disable()
213
+ column.close()
214
+ ```
215
+
216
+ ### Swerve Chassis
217
+
218
+ ```python
219
+ from openflex_driver import Chassis
220
+
221
+ chassis = Chassis(steering_can="can5", driving_can="can4")
222
+
223
+ try:
224
+ chassis.connect()
225
+ chassis.enable_all()
226
+
227
+ # vx: forward m/s, vy: left m/s, omega: counter-clockwise rad/s
228
+ chassis.set_chassis_velocity(vx=0.2, vy=0.0, omega=0.0)
229
+ chassis.stop_motion()
230
+
231
+ print(chassis.get_status_table())
232
+ finally:
233
+ chassis.disable_all()
234
+ chassis.close()
235
+ ```
236
+
237
+ ### Motor Inventory
238
+
239
+ ```python
240
+ from openflex_driver import position_motors, velocity_motors
241
+
242
+ for motor in position_motors():
243
+ print(motor.component, motor.name, motor.can_channel, motor.motor_id)
244
+
245
+ for motor in velocity_motors():
246
+ print(motor.component, motor.name, motor.can_channel, motor.motor_id)
247
+ ```
248
+
249
+ ## Public API Overview
250
+
251
+ Main classes:
252
+
253
+ - `Arm`: one arm controller
254
+ - `Robot`: full robot controller that owns left / right arms and optional head, column, chassis
255
+ - `Head`: two-axis head controller
256
+ - `Column`: lift column controller
257
+ - `Chassis`: swerve chassis controller
258
+ - `MotorConfigLoader`: load motor configuration and limits
259
+
260
+ Common helper APIs:
261
+
262
+ - CAN utilities: `get_available_can_interfaces`, `verify_can_interface`, `enable_can_interface`, `disable_can_interface`
263
+ - Motor management: `enable_motor`, `disable_motor`, `set_control_mode`, `get_motor_status_readonly`
264
+ - Motor control: `mit_motion_control`, `csp_motion_control`, `csp_set_speed_limits`
265
+ - Calibration: `auto_calibrate_zero`, `move_to_limit`, `move_to_position_smooth`
266
+ - Chassis kinematics: `ChassisSpeeds`, `SwerveDriveKinematics`, `default_module_positions`
267
+ - Teleoperation: `TeleopConfig`, `TeleopInputFrame`, `OpenArmTeleopController`, `PinocchioTeleopCore`
268
+
269
+ ## Build From Source
270
+
271
+ The package compiles internal `_lib` modules into `.so` files during wheel / source distribution builds.
272
+
273
+ For local builds on a machine that already has build dependencies installed:
274
+
275
+ ```bash
276
+ python3 -m build --no-isolation
277
+ ```
278
+
279
+ For a clean isolated build, network access is required so Python can install build dependencies declared in `pyproject.toml`:
280
+
281
+ ```bash
282
+ python3 -m build
283
+ ```
284
+
285
+ Inspect generated wheels:
286
+
287
+ ```bash
288
+ unzip -l dist/openflex_driver-*.whl
289
+ ```
290
+
291
+ The helper scripts `build_so.py` and `clean_so.py` are local build tools and are excluded from the published source distribution.
292
+
293
+ ## Publishing
294
+
295
+ This repository includes GitHub Actions workflow support under `.github/workflows/build.yml`.
296
+
297
+ - Push to `main`, `master`, or `linux_*`: build wheels and publish to TestPyPI when `TEST_PYPI_API_TOKEN` is configured.
298
+ - Push a tag like `v1.2.0`: build wheels and publish to PyPI when `PYPI_API_TOKEN` is configured.
299
+ - Supported build matrix: Python 3.9, 3.10, 3.11, 3.12 on `x86_64` and `aarch64`.
300
+
301
+ Before a release:
302
+
303
+ ```bash
304
+ # Update version in pyproject.toml and src/openflex_driver/__init__.py
305
+ git add .
306
+ git commit -m "Release v1.2.0"
307
+ git tag -a v1.2.0 -m "Release version 1.2.0"
308
+ git push
309
+ git push origin v1.2.0
310
+ ```
311
+
312
+ ## Safety Notes
313
+
314
+ - Always verify CAN interfaces and motor IDs before enabling motors.
315
+ - Start with low velocity, low torque, and conservative `kp` / `kd` values.
316
+ - Keep the robot clear of people and obstacles during calibration and first motion tests.
317
+ - Run active zero calibration only when mechanical limits and emergency stop behavior are verified.
318
+ - Disable motors and close CAN connections when control is finished.
319
+
320
+ ## License
321
+
322
+ This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
323
+
324
+ Commercial use requires a separate license from Chengdu Changshu Robotics Co., Ltd. See [LICENSE](LICENSE) for details.
325
+
326
+ ## Contact Us
327
+
328
+ ### Chengdu Changshu Robotics Co., Ltd.
329
+
330
+ | Contact | Information |
331
+ |---------|-------------|
332
+ | 📧 Email | wangxunyue1@163.com <br> openarmrobot@gmail.com |
333
+ | 📱 Phone/WeChat | +86-17746530375 |
334
+ | 🌐 Website | <https://openarmx.com/> |
335
+ | 🌐 Documentation | <http://docs.openarmx.com/> |
336
+ | 📍 Address | Xiqing District, Tianjin・Daochao Robotics Experience Center (Tomorrow City)・Tianjin Humanoid Robot Center |
337
+ | 👤 Contact Person | Mr. Wang |
338
+
339
+ Copyright © 2025 Chengdu Changshu Robotics Co., Ltd. All Rights Reserved.