ezgo 0.0.8__py3-none-any.whl → 0.0.10__py3-none-any.whl
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.
- ezgo/__init__.py +54 -14
- {ezgo-0.0.8.dist-info → ezgo-0.0.10.dist-info}/METADATA +92 -11
- {ezgo-0.0.8.dist-info → ezgo-0.0.10.dist-info}/RECORD +6 -6
- {ezgo-0.0.8.dist-info → ezgo-0.0.10.dist-info}/LICENSE +0 -0
- {ezgo-0.0.8.dist-info → ezgo-0.0.10.dist-info}/WHEEL +0 -0
- {ezgo-0.0.8.dist-info → ezgo-0.0.10.dist-info}/top_level.txt +0 -0
ezgo/__init__.py
CHANGED
|
@@ -8,26 +8,41 @@ ezgo - 宇树Go2机器狗Python控制库
|
|
|
8
8
|
支持运动控制、视频流获取、UI界面等功能。
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
__version__ = "0.0.
|
|
11
|
+
__version__ = "0.0.10"
|
|
12
12
|
__author__ = "ezgo"
|
|
13
13
|
__email__ = ""
|
|
14
14
|
__license__ = "MIT"
|
|
15
15
|
|
|
16
|
-
#
|
|
16
|
+
# 懒加载模块 - 只在实际使用时才导入
|
|
17
|
+
def _lazy_import(module_name, class_name):
|
|
18
|
+
"""懒加载模块,避免导入时的依赖检查"""
|
|
19
|
+
def _import():
|
|
20
|
+
try:
|
|
21
|
+
# 使用importlib代替__import__,更可靠
|
|
22
|
+
import importlib
|
|
23
|
+
module = importlib.import_module(f'.{module_name}', package=__name__)
|
|
24
|
+
return getattr(module, class_name)
|
|
25
|
+
except ImportError as e:
|
|
26
|
+
# 只在使用时才提示依赖缺失
|
|
27
|
+
raise ImportError(f"使用 {class_name} 需要安装额外依赖: {e}")
|
|
28
|
+
return _import
|
|
29
|
+
|
|
30
|
+
# 定义懒加载函数
|
|
31
|
+
_Go2 = _lazy_import('go2', 'Go2')
|
|
32
|
+
_Camera = _lazy_import('camera', 'Camera')
|
|
33
|
+
_APP = _lazy_import('ui', 'APP')
|
|
34
|
+
_Go2Camera = _lazy_import('go2_camera', 'Go2Camera')
|
|
35
|
+
_Go2VUI = _lazy_import('go2_vui', 'Go2VUI')
|
|
36
|
+
|
|
37
|
+
# 直接导入不需要额外依赖的模块
|
|
17
38
|
try:
|
|
18
|
-
from .
|
|
19
|
-
from .
|
|
20
|
-
from .ui import APP
|
|
21
|
-
from .go2_camera import Go2Camera
|
|
22
|
-
from .go2_vui import Go2VUI
|
|
39
|
+
from .eztk import EasyTk
|
|
40
|
+
from .ezcamera import Camera as EzCamera
|
|
23
41
|
except ImportError as e:
|
|
24
|
-
|
|
25
|
-
print("
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
APP = None
|
|
29
|
-
Go2Camera = None
|
|
30
|
-
Go2VUI = None
|
|
42
|
+
# 这些模块应该能正常导入,如果失败则显示错误
|
|
43
|
+
print(f"错误: 无法导入核心模块: {e}")
|
|
44
|
+
EasyTk = None
|
|
45
|
+
EzCamera = None
|
|
31
46
|
|
|
32
47
|
# 定义公开的API
|
|
33
48
|
__all__ = [
|
|
@@ -36,6 +51,31 @@ __all__ = [
|
|
|
36
51
|
"APP",
|
|
37
52
|
"Go2Camera",
|
|
38
53
|
"Go2VUI",
|
|
54
|
+
"EasyTk",
|
|
55
|
+
"EzCamera",
|
|
39
56
|
"__version__"
|
|
40
57
|
]
|
|
41
58
|
|
|
59
|
+
# 懒加载属性访问器
|
|
60
|
+
class _LazyModule:
|
|
61
|
+
def __init__(self, import_func):
|
|
62
|
+
self._import_func = import_func
|
|
63
|
+
self._module = None
|
|
64
|
+
|
|
65
|
+
def __call__(self, *args, **kwargs):
|
|
66
|
+
if self._module is None:
|
|
67
|
+
self._module = self._import_func()
|
|
68
|
+
return self._module(*args, **kwargs)
|
|
69
|
+
|
|
70
|
+
def __getattr__(self, name):
|
|
71
|
+
if self._module is None:
|
|
72
|
+
self._module = self._import_func()
|
|
73
|
+
return getattr(self._module, name)
|
|
74
|
+
|
|
75
|
+
# 创建懒加载对象
|
|
76
|
+
Go2 = _LazyModule(_Go2)
|
|
77
|
+
Camera = _LazyModule(_Camera)
|
|
78
|
+
APP = _LazyModule(_APP)
|
|
79
|
+
Go2Camera = _LazyModule(_Go2Camera)
|
|
80
|
+
Go2VUI = _LazyModule(_Go2VUI)
|
|
81
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ezgo
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.10
|
|
4
4
|
Summary: 宇树Go2机器狗Python控制库
|
|
5
5
|
Author-email: ezgo <noreply@example.com>
|
|
6
6
|
License: MIT
|
|
@@ -83,7 +83,7 @@ pip install ezgo[basic]
|
|
|
83
83
|
```python
|
|
84
84
|
import ezgo
|
|
85
85
|
|
|
86
|
-
# 创建Go2
|
|
86
|
+
# 创建Go2控制对象(需要安装unitree-sdk2py)
|
|
87
87
|
robot = ezgo.Go2()
|
|
88
88
|
|
|
89
89
|
# 初始化连接
|
|
@@ -96,16 +96,16 @@ if robot.init():
|
|
|
96
96
|
robot.StopMove() # 停止移动
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
### 摄像头控制
|
|
99
|
+
### Go2摄像头控制
|
|
100
100
|
|
|
101
101
|
```python
|
|
102
102
|
import ezgo
|
|
103
103
|
|
|
104
|
-
# 方法1: 通过Go2
|
|
104
|
+
# 方法1: 通过Go2对象获取摄像头(需要unitree-sdk2py)
|
|
105
105
|
robot = ezgo.Go2()
|
|
106
106
|
camera = robot.get_camera()
|
|
107
107
|
|
|
108
|
-
# 方法2:
|
|
108
|
+
# 方法2: 直接使用Go2摄像头类(需要unitree-sdk2py)
|
|
109
109
|
camera = ezgo.Go2Camera()
|
|
110
110
|
|
|
111
111
|
# 初始化摄像头
|
|
@@ -118,16 +118,16 @@ if camera.init():
|
|
|
118
118
|
frame = camera.read_frame()
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
### 声光控制
|
|
121
|
+
### Go2声光控制
|
|
122
122
|
|
|
123
123
|
```python
|
|
124
124
|
import ezgo
|
|
125
125
|
|
|
126
|
-
# 方法1: 通过Go2对象获取VUI
|
|
126
|
+
# 方法1: 通过Go2对象获取VUI控制(需要unitree-sdk2py)
|
|
127
127
|
robot = ezgo.Go2()
|
|
128
128
|
vui = robot.get_vui()
|
|
129
129
|
|
|
130
|
-
# 方法2: 直接使用VUI
|
|
130
|
+
# 方法2: 直接使用VUI类(需要unitree-sdk2py)
|
|
131
131
|
vui = ezgo.Go2VUI()
|
|
132
132
|
|
|
133
133
|
# 初始化VUI
|
|
@@ -142,12 +142,70 @@ if vui.init():
|
|
|
142
142
|
vui.set_volume(3)
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
+
### EasyTk 简化界面开发
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
import ezgo
|
|
149
|
+
|
|
150
|
+
# 创建EasyTk窗口(自动适配灵芯派480x800分辨率)
|
|
151
|
+
app = ezgo.EasyTk(title="机器狗控制", size="480x800")
|
|
152
|
+
|
|
153
|
+
# 添加标签
|
|
154
|
+
label = app.add_label(text="欢迎使用ezgo", font=("SimHei", 24))
|
|
155
|
+
|
|
156
|
+
# 添加按钮
|
|
157
|
+
def on_click():
|
|
158
|
+
print("按钮被点击了!")
|
|
159
|
+
|
|
160
|
+
button = app.add_button(text="点击我", command=on_click)
|
|
161
|
+
|
|
162
|
+
# 添加图片显示(支持文件路径、OpenCV图像、PIL图像)
|
|
163
|
+
image_label = app.add_label(image="path/to/image.jpg")
|
|
164
|
+
|
|
165
|
+
# 运行主循环
|
|
166
|
+
app.root.mainloop()
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### EzCamera 优化摄像头控制
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
import ezgo
|
|
173
|
+
import cv2
|
|
174
|
+
|
|
175
|
+
# 创建摄像头对象(自动适配平台)
|
|
176
|
+
camera = ezgo.EzCamera(index=0, width=640, height=480, fps=30)
|
|
177
|
+
|
|
178
|
+
# 打开摄像头
|
|
179
|
+
if camera.open():
|
|
180
|
+
print("摄像头打开成功!")
|
|
181
|
+
|
|
182
|
+
# 读取最新帧
|
|
183
|
+
frame = camera.read()
|
|
184
|
+
if frame is not None:
|
|
185
|
+
# 保存图片
|
|
186
|
+
camera.save_image(frame, "capture.jpg")
|
|
187
|
+
|
|
188
|
+
# 调整尺寸
|
|
189
|
+
resized = camera.resize(frame, (224, 224))
|
|
190
|
+
|
|
191
|
+
# 裁剪为正方形
|
|
192
|
+
square = camera.crop_to_square(frame)
|
|
193
|
+
|
|
194
|
+
# 显示图像
|
|
195
|
+
cv2.imshow("Camera", frame)
|
|
196
|
+
cv2.waitKey(0)
|
|
197
|
+
cv2.destroyAllWindows()
|
|
198
|
+
|
|
199
|
+
# 关闭摄像头
|
|
200
|
+
camera.close()
|
|
201
|
+
```
|
|
202
|
+
|
|
145
203
|
### 高级运动模式
|
|
146
204
|
|
|
147
205
|
```python
|
|
148
206
|
import ezgo
|
|
149
207
|
|
|
150
|
-
robot = ezgo.Go2()
|
|
208
|
+
robot = ezgo.Go2() # 需要unitree-sdk2py
|
|
151
209
|
if robot.init():
|
|
152
210
|
# 步态模式切换
|
|
153
211
|
robot.FreeWalk(True) # 开启灵动模式
|
|
@@ -173,7 +231,7 @@ if robot.init():
|
|
|
173
231
|
```python
|
|
174
232
|
import ezgo
|
|
175
233
|
|
|
176
|
-
robot = ezgo.Go2()
|
|
234
|
+
robot = ezgo.Go2() # 需要unitree-sdk2py
|
|
177
235
|
if robot.init():
|
|
178
236
|
# 表演动作
|
|
179
237
|
robot.Hello() # 打招呼
|
|
@@ -197,7 +255,7 @@ if robot.init():
|
|
|
197
255
|
```python
|
|
198
256
|
import ezgo
|
|
199
257
|
|
|
200
|
-
robot = ezgo.Go2()
|
|
258
|
+
robot = ezgo.Go2() # 需要unitree-sdk2py
|
|
201
259
|
if robot.init():
|
|
202
260
|
# 设置自动翻身
|
|
203
261
|
success = robot.AutoRecoverSet(True)
|
|
@@ -359,6 +417,29 @@ pip install opencv-python numpy Pillow netifaces
|
|
|
359
417
|
|
|
360
418
|
## 更新日志
|
|
361
419
|
|
|
420
|
+
### v0.0.10 (2025-12-09)
|
|
421
|
+
**修复**:
|
|
422
|
+
- 🐛 修复懒加载模块导入错误,解决TypeError问题
|
|
423
|
+
- 🐛 修复使用importlib替代__import__,提高兼容性
|
|
424
|
+
- 🐛 修复Go2相关模块无法正确实例化的问题
|
|
425
|
+
|
|
426
|
+
**改进**:
|
|
427
|
+
- 🔧 更新README中的使用示例,明确标注依赖要求
|
|
428
|
+
- 🔧 为每个工具类添加独立的使用示例
|
|
429
|
+
- 🔧 优化文档结构,区分Go2相关和独立功能
|
|
430
|
+
|
|
431
|
+
### v0.0.9 (2025-12-09)
|
|
432
|
+
**改进**:
|
|
433
|
+
- 🔧 实现懒加载机制,避免导入时的依赖检查
|
|
434
|
+
- 🔧 只在实际使用Go2相关功能时才检查依赖
|
|
435
|
+
- 🔧 eztk和ezcamera模块可直接使用,无任何依赖警告
|
|
436
|
+
- 🔧 优化模块导入结构,提升用户体验
|
|
437
|
+
|
|
438
|
+
**修复**:
|
|
439
|
+
- 🐛 修复导入ezgo时提示netifaces等依赖缺失的问题
|
|
440
|
+
- 🐛 修复使用eztk/ezcamera时的不必要警告
|
|
441
|
+
- 🐛 实现真正的按需依赖检查机制
|
|
442
|
+
|
|
362
443
|
### v0.0.8 (2025-12-09)
|
|
363
444
|
**改进**:
|
|
364
445
|
- 🔧 移除自动依赖检查逻辑,避免导入时的警告提示
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
ezgo/__init__.py,sha256=
|
|
1
|
+
ezgo/__init__.py,sha256=RJRxE28ZkbxrPqZY5siOikj6wLBXxbaTWVOSE8iNumI,2268
|
|
2
2
|
ezgo/camera.py,sha256=Vsr44vFtaop4LE0DlWyOHyvxF-jHnVO8iMPUwp5mbsE,2538
|
|
3
3
|
ezgo/ezcamera.py,sha256=6-3y-1X_L60QsWdsd5-caLoj7Quy9rpyHdp3Tq3JFbU,6536
|
|
4
4
|
ezgo/eztk.py,sha256=MHWkkZYIL1AFjUXFu2Qq8U9idJV_E1VxFUBe82dvbyA,10463
|
|
@@ -6,8 +6,8 @@ ezgo/go2.py,sha256=lSZwpYRAljcV4bAalkZXvs9X-qMaEGcuaHSNegGcX6M,31610
|
|
|
6
6
|
ezgo/go2_camera.py,sha256=nawUSLyvqTNiVRQ2sM-UdoJzqwZcySltLbCfUb0G9Qc,8614
|
|
7
7
|
ezgo/go2_vui.py,sha256=52I4Y8uqGkW9muDEnDzQ236HqVVTIgNIN_2gW5RTC48,10161
|
|
8
8
|
ezgo/ui.py,sha256=jUik6maaoemI2vsBM92OLZfJfskg54W7hwMls_gxppg,2777
|
|
9
|
-
ezgo-0.0.
|
|
10
|
-
ezgo-0.0.
|
|
11
|
-
ezgo-0.0.
|
|
12
|
-
ezgo-0.0.
|
|
13
|
-
ezgo-0.0.
|
|
9
|
+
ezgo-0.0.10.dist-info/LICENSE,sha256=Zk4eZBT3KaBhqM3LB_xN7QquwnoWsEHAoA6eLdE6W5M,1060
|
|
10
|
+
ezgo-0.0.10.dist-info/METADATA,sha256=9k7D5jZ5vCJ_Fbjgsic9jA97EAF7MBmSgg2UAtBbgiA,15565
|
|
11
|
+
ezgo-0.0.10.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
12
|
+
ezgo-0.0.10.dist-info/top_level.txt,sha256=BdCFEVD5V_4FxUtvH0BVlZKgxYnp7EKNsYs5OyFxj-g,5
|
|
13
|
+
ezgo-0.0.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|