ezgo 0.0.1__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.
ezgo-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ezgo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ezgo-0.0.1/MANIFEST.in ADDED
@@ -0,0 +1,9 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ include MANIFEST.in
5
+ recursive-include src *.py
6
+ global-exclude *.pyc
7
+ global-exclude __pycache__
8
+ global-exclude .git*
9
+ global-exclude .DS_Store
ezgo-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,295 @@
1
+ Metadata-Version: 2.1
2
+ Name: ezgo
3
+ Version: 0.0.1
4
+ Summary: 宇树Go2机器狗Python控制库
5
+ Author-email: ezgo <noreply@example.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/your-username/ezgo
8
+ Project-URL: Repository, https://github.com/your-username/ezgo
9
+ Project-URL: Bug Reports, https://github.com/your-username/ezgo/issues
10
+ Keywords: robotics,unitree,go2,robot,control
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.7
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.7
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Provides-Extra: full
26
+ Requires-Dist: opencv-python>=4.5.0; extra == "full"
27
+ Requires-Dist: numpy>=1.19.0; extra == "full"
28
+ Requires-Dist: Pillow>=8.0.0; extra == "full"
29
+ Requires-Dist: netifaces>=0.10.0; extra == "full"
30
+ Requires-Dist: unitree-sdk2py; extra == "full"
31
+ Provides-Extra: basic
32
+ Requires-Dist: opencv-python>=4.5.0; extra == "basic"
33
+ Requires-Dist: numpy>=1.19.0; extra == "basic"
34
+ Requires-Dist: Pillow>=8.0.0; extra == "basic"
35
+
36
+ # ezgo - 宇树Go2机器狗Python控制库
37
+
38
+ [![PyPI version](https://badge.fury.io/py/ezgo.svg)](https://badge.fury.io/py/ezgo)
39
+ [![Python versions](https://img.shields.io/pypi/pyversions/ezgo.svg)](https://pypi.org/project/ezgo/)
40
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
41
+
42
+ ezgo 是一个用于控制宇树Go2机器狗的Python库,提供了简单易用的API接口,支持运动控制、视频流获取、UI界面等功能。
43
+
44
+ ## 功能特性
45
+
46
+ - 🤖 **运动控制**: 支持前进、后退、转向、舞蹈等多种动作
47
+ - 📹 **视频流**: 实时获取机器狗摄像头画面
48
+ - 🎮 **状态管理**: 智能状态检测和动作切换
49
+ - 🖥️ **UI界面**: 提供简单的图形界面用于显示和控制
50
+ - 🔧 **易于集成**: 简洁的API设计,便于快速开发
51
+
52
+ ## 安装
53
+
54
+ ### 使用pip安装
55
+
56
+ ```bash
57
+ pip install ezgo
58
+ ```
59
+
60
+ ### 从源码安装
61
+
62
+ ```bash
63
+ git clone https://github.com/your-username/ezgo.git
64
+ cd ezgo
65
+ pip install -e .
66
+ ```
67
+
68
+ ## 系统要求
69
+
70
+ 在安装 ezgo 之前,请确保您的系统已安装以下依赖:
71
+
72
+ ```bash
73
+ # Ubuntu/Debian
74
+ sudo apt update
75
+ sudo apt install python3-opencv python3-numpy python3-pil
76
+
77
+ # CentOS/RHEL
78
+ sudo yum install opencv-python numpy Pillow
79
+
80
+ # macOS
81
+ brew install opencv
82
+
83
+ # Windows
84
+ # 请使用 pip 安装或下载预编译的二进制包
85
+ pip install opencv-python numpy Pillow
86
+ ```
87
+
88
+ **注意**: ezgo 不会自动安装这些依赖,因为它们可能需要系统级安装或特定配置。
89
+
90
+ ## 快速开始
91
+
92
+ ### 基本使用
93
+
94
+ ```python
95
+ from ezgo import Go2
96
+
97
+ # 初始化Go2控制器
98
+ go2 = Go2(interface="enx00e0986113a6") # 替换为你的网卡接口
99
+
100
+ # 初始化连接
101
+ if go2.init():
102
+ print("连接成功!")
103
+
104
+ # 基本动作
105
+ go2.StandUp() # 站立
106
+ go2.Forward(0.3, 2) # 向前移动2秒
107
+ go2.TurnLeft(0.5, 1) # 左转1秒
108
+ go2.Hello() # 打招呼
109
+ go2.Damp() # 进入阻尼状态
110
+ else:
111
+ print("连接失败!")
112
+ ```
113
+
114
+ ### 视频流使用
115
+
116
+ ```python
117
+ import cv2
118
+ from ezgo import Go2
119
+
120
+ # 初始化
121
+ go2 = Go2()
122
+ if go2.init():
123
+ print("开始获取视频流...")
124
+
125
+ while True:
126
+ frame = go2.read_image()
127
+ if frame is not None:
128
+ cv2.imshow('Go2 Camera', frame)
129
+
130
+ if cv2.waitKey(1) & 0xFF == ord('q'):
131
+ break
132
+
133
+ cv2.destroyAllWindows()
134
+ ```
135
+
136
+ ### UI界面使用
137
+
138
+ ```python
139
+ from ezgo.ui import APP
140
+ from ezgo.camera import Camera
141
+ import time
142
+
143
+ # 创建UI应用
144
+ app = APP(title="Go2控制面板", width=480, height=800)
145
+
146
+ # 创建摄像头
147
+ camera = Camera(index=0)
148
+ camera.open_camera()
149
+
150
+ # 更新界面
151
+ while app.is_running:
152
+ try:
153
+ # 获取摄像头图像
154
+ frame = camera.read_cv2_image()
155
+ image_tk = camera.cv2_to_tk(frame)
156
+ app.set_image(image_tk)
157
+ app.set_text("系统运行正常")
158
+
159
+ app.update()
160
+ time.sleep(0.03) # 约30FPS
161
+ except Exception as e:
162
+ print(f"更新界面出错: {e}")
163
+ break
164
+
165
+ app.mainloop()
166
+ ```
167
+
168
+ ## API 文档
169
+
170
+ ### Go2 类
171
+
172
+ 主要的机器狗控制类,提供以下方法:
173
+
174
+ #### 运动控制
175
+ - `StandUp()` - 站立
176
+ - `StandDown()` - 蹲下
177
+ - `Sit()` - 坐下
178
+ - `Damp()` - 进入阻尼状态
179
+ - `BalanceStand()` - 平衡站立
180
+ - `StopMove()` - 停止移动
181
+
182
+ #### 移动控制
183
+ - `Move(vx, vy, vyaw)` - 移动控制
184
+ - `Forward(speed, duration)` - 向前移动
185
+ - `Backward(speed, duration)` - 向后移动
186
+ - `Left(speed, duration)` - 向左移动
187
+ - `Right(speed, duration)` - 向右移动
188
+ - `TurnLeft(speed, duration)` - 左转
189
+ - `TurnRight(speed, duration)` - 右转
190
+
191
+ #### 动作控制
192
+ - `Hello()` - 打招呼
193
+ - `Stretch()` - 伸懒腰
194
+ - `Content()` - 开心
195
+ - `Heart()` - 比心
196
+ - `Scrape()` - 拜年作揖
197
+ - `Dance1()` - 舞蹈1
198
+ - `Dance2()` - 舞蹈2
199
+ - `FrontJump()` - 前跳
200
+ - `FrontPounce()` - 向前扑人
201
+
202
+ #### 视频控制
203
+ - `read_image()` - 获取一帧图像
204
+ - `open_video(width, height)` - 打开视频流
205
+
206
+ ### Camera 类
207
+
208
+ 摄像头控制类,提供以下方法:
209
+ - `open_camera()` - 打开摄像头
210
+ - `read_cv2_image()` - 读取OpenCV格式图像
211
+ - `read_pil_image()` - 读取PIL格式图像
212
+ - `cv2_to_tk(frame)` - 转换为Tkinter格式
213
+ - `resize(frame, size)` - 调整图像尺寸
214
+ - `crop_to_square(frame)` - 裁剪为正方形
215
+
216
+ ### APP 类
217
+
218
+ UI界面类,基于Tkinter:
219
+ - `set_image(image)` - 设置显示图像
220
+ - `set_text(text)` - 设置显示文字
221
+
222
+ ## 项目结构
223
+
224
+ ```
225
+ ezgo/
226
+ ├── src/
227
+ │ ├── __init__.py # 包初始化文件
228
+ │ ├── go2.py # Go2机器狗控制类
229
+ │ ├── camera.py # 摄像头控制类
230
+ │ └── ui.py # UI界面类
231
+ ├── pyproject.toml # 现代Python项目配置
232
+ ├── README.md # 项目文档
233
+ ├── LICENSE # 开源协议
234
+ ├── quick_update.py # 快速更新脚本
235
+ └── .pypirc # PyPI配置文件
236
+ ```
237
+
238
+ ## 开发指南
239
+
240
+ ### 本地开发
241
+
242
+ ```bash
243
+ # 克隆仓库
244
+ git clone https://github.com/your-username/ezgo.git
245
+ cd ezgo
246
+
247
+ # 安装开发依赖
248
+ pip install -e .
249
+
250
+ # 运行测试
251
+ python -m pytest tests/
252
+ ```
253
+
254
+ ### 发布新版本
255
+
256
+ ```bash
257
+ # 更新补丁版本
258
+ python quick_update.py patch
259
+
260
+ # 更新次版本
261
+ python quick_update.py minor
262
+
263
+ # 更新主版本
264
+ python quick_update.py major
265
+
266
+ # 发布到PyPI
267
+ python quick_update.py publish
268
+ ```
269
+
270
+ ## 常见问题
271
+
272
+ ### Q: 连接机器狗失败怎么办?
273
+ A: 请检查网络连接,确保机器狗IP (192.168.123.161) 可以ping通,并确认网卡接口名称正确。
274
+
275
+ ### Q: 视频流无法打开?
276
+ A: 请检查GStreamer是否正确安装,以及网卡多播配置是否正确。
277
+
278
+ ### Q: 某些动作无法执行?
279
+ A: 请检查机器狗当前状态,某些动作需要在特定状态下才能执行。
280
+
281
+ ## 贡献
282
+
283
+ 欢迎提交 Issue 和 Pull Request!
284
+
285
+ ## 许可证
286
+
287
+ 本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件。
288
+
289
+ ## 更新日志
290
+
291
+ ### v0.0.1 (2024-01-01)
292
+ - 初始版本发布
293
+ - 基本运动控制功能
294
+ - 视频流获取功能
295
+ - UI界面功能
ezgo-0.0.1/README.md ADDED
@@ -0,0 +1,260 @@
1
+ # ezgo - 宇树Go2机器狗Python控制库
2
+
3
+ [![PyPI version](https://badge.fury.io/py/ezgo.svg)](https://badge.fury.io/py/ezgo)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/ezgo.svg)](https://pypi.org/project/ezgo/)
5
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ ezgo 是一个用于控制宇树Go2机器狗的Python库,提供了简单易用的API接口,支持运动控制、视频流获取、UI界面等功能。
8
+
9
+ ## 功能特性
10
+
11
+ - 🤖 **运动控制**: 支持前进、后退、转向、舞蹈等多种动作
12
+ - 📹 **视频流**: 实时获取机器狗摄像头画面
13
+ - 🎮 **状态管理**: 智能状态检测和动作切换
14
+ - 🖥️ **UI界面**: 提供简单的图形界面用于显示和控制
15
+ - 🔧 **易于集成**: 简洁的API设计,便于快速开发
16
+
17
+ ## 安装
18
+
19
+ ### 使用pip安装
20
+
21
+ ```bash
22
+ pip install ezgo
23
+ ```
24
+
25
+ ### 从源码安装
26
+
27
+ ```bash
28
+ git clone https://github.com/your-username/ezgo.git
29
+ cd ezgo
30
+ pip install -e .
31
+ ```
32
+
33
+ ## 系统要求
34
+
35
+ 在安装 ezgo 之前,请确保您的系统已安装以下依赖:
36
+
37
+ ```bash
38
+ # Ubuntu/Debian
39
+ sudo apt update
40
+ sudo apt install python3-opencv python3-numpy python3-pil
41
+
42
+ # CentOS/RHEL
43
+ sudo yum install opencv-python numpy Pillow
44
+
45
+ # macOS
46
+ brew install opencv
47
+
48
+ # Windows
49
+ # 请使用 pip 安装或下载预编译的二进制包
50
+ pip install opencv-python numpy Pillow
51
+ ```
52
+
53
+ **注意**: ezgo 不会自动安装这些依赖,因为它们可能需要系统级安装或特定配置。
54
+
55
+ ## 快速开始
56
+
57
+ ### 基本使用
58
+
59
+ ```python
60
+ from ezgo import Go2
61
+
62
+ # 初始化Go2控制器
63
+ go2 = Go2(interface="enx00e0986113a6") # 替换为你的网卡接口
64
+
65
+ # 初始化连接
66
+ if go2.init():
67
+ print("连接成功!")
68
+
69
+ # 基本动作
70
+ go2.StandUp() # 站立
71
+ go2.Forward(0.3, 2) # 向前移动2秒
72
+ go2.TurnLeft(0.5, 1) # 左转1秒
73
+ go2.Hello() # 打招呼
74
+ go2.Damp() # 进入阻尼状态
75
+ else:
76
+ print("连接失败!")
77
+ ```
78
+
79
+ ### 视频流使用
80
+
81
+ ```python
82
+ import cv2
83
+ from ezgo import Go2
84
+
85
+ # 初始化
86
+ go2 = Go2()
87
+ if go2.init():
88
+ print("开始获取视频流...")
89
+
90
+ while True:
91
+ frame = go2.read_image()
92
+ if frame is not None:
93
+ cv2.imshow('Go2 Camera', frame)
94
+
95
+ if cv2.waitKey(1) & 0xFF == ord('q'):
96
+ break
97
+
98
+ cv2.destroyAllWindows()
99
+ ```
100
+
101
+ ### UI界面使用
102
+
103
+ ```python
104
+ from ezgo.ui import APP
105
+ from ezgo.camera import Camera
106
+ import time
107
+
108
+ # 创建UI应用
109
+ app = APP(title="Go2控制面板", width=480, height=800)
110
+
111
+ # 创建摄像头
112
+ camera = Camera(index=0)
113
+ camera.open_camera()
114
+
115
+ # 更新界面
116
+ while app.is_running:
117
+ try:
118
+ # 获取摄像头图像
119
+ frame = camera.read_cv2_image()
120
+ image_tk = camera.cv2_to_tk(frame)
121
+ app.set_image(image_tk)
122
+ app.set_text("系统运行正常")
123
+
124
+ app.update()
125
+ time.sleep(0.03) # 约30FPS
126
+ except Exception as e:
127
+ print(f"更新界面出错: {e}")
128
+ break
129
+
130
+ app.mainloop()
131
+ ```
132
+
133
+ ## API 文档
134
+
135
+ ### Go2 类
136
+
137
+ 主要的机器狗控制类,提供以下方法:
138
+
139
+ #### 运动控制
140
+ - `StandUp()` - 站立
141
+ - `StandDown()` - 蹲下
142
+ - `Sit()` - 坐下
143
+ - `Damp()` - 进入阻尼状态
144
+ - `BalanceStand()` - 平衡站立
145
+ - `StopMove()` - 停止移动
146
+
147
+ #### 移动控制
148
+ - `Move(vx, vy, vyaw)` - 移动控制
149
+ - `Forward(speed, duration)` - 向前移动
150
+ - `Backward(speed, duration)` - 向后移动
151
+ - `Left(speed, duration)` - 向左移动
152
+ - `Right(speed, duration)` - 向右移动
153
+ - `TurnLeft(speed, duration)` - 左转
154
+ - `TurnRight(speed, duration)` - 右转
155
+
156
+ #### 动作控制
157
+ - `Hello()` - 打招呼
158
+ - `Stretch()` - 伸懒腰
159
+ - `Content()` - 开心
160
+ - `Heart()` - 比心
161
+ - `Scrape()` - 拜年作揖
162
+ - `Dance1()` - 舞蹈1
163
+ - `Dance2()` - 舞蹈2
164
+ - `FrontJump()` - 前跳
165
+ - `FrontPounce()` - 向前扑人
166
+
167
+ #### 视频控制
168
+ - `read_image()` - 获取一帧图像
169
+ - `open_video(width, height)` - 打开视频流
170
+
171
+ ### Camera 类
172
+
173
+ 摄像头控制类,提供以下方法:
174
+ - `open_camera()` - 打开摄像头
175
+ - `read_cv2_image()` - 读取OpenCV格式图像
176
+ - `read_pil_image()` - 读取PIL格式图像
177
+ - `cv2_to_tk(frame)` - 转换为Tkinter格式
178
+ - `resize(frame, size)` - 调整图像尺寸
179
+ - `crop_to_square(frame)` - 裁剪为正方形
180
+
181
+ ### APP 类
182
+
183
+ UI界面类,基于Tkinter:
184
+ - `set_image(image)` - 设置显示图像
185
+ - `set_text(text)` - 设置显示文字
186
+
187
+ ## 项目结构
188
+
189
+ ```
190
+ ezgo/
191
+ ├── src/
192
+ │ ├── __init__.py # 包初始化文件
193
+ │ ├── go2.py # Go2机器狗控制类
194
+ │ ├── camera.py # 摄像头控制类
195
+ │ └── ui.py # UI界面类
196
+ ├── pyproject.toml # 现代Python项目配置
197
+ ├── README.md # 项目文档
198
+ ├── LICENSE # 开源协议
199
+ ├── quick_update.py # 快速更新脚本
200
+ └── .pypirc # PyPI配置文件
201
+ ```
202
+
203
+ ## 开发指南
204
+
205
+ ### 本地开发
206
+
207
+ ```bash
208
+ # 克隆仓库
209
+ git clone https://github.com/your-username/ezgo.git
210
+ cd ezgo
211
+
212
+ # 安装开发依赖
213
+ pip install -e .
214
+
215
+ # 运行测试
216
+ python -m pytest tests/
217
+ ```
218
+
219
+ ### 发布新版本
220
+
221
+ ```bash
222
+ # 更新补丁版本
223
+ python quick_update.py patch
224
+
225
+ # 更新次版本
226
+ python quick_update.py minor
227
+
228
+ # 更新主版本
229
+ python quick_update.py major
230
+
231
+ # 发布到PyPI
232
+ python quick_update.py publish
233
+ ```
234
+
235
+ ## 常见问题
236
+
237
+ ### Q: 连接机器狗失败怎么办?
238
+ A: 请检查网络连接,确保机器狗IP (192.168.123.161) 可以ping通,并确认网卡接口名称正确。
239
+
240
+ ### Q: 视频流无法打开?
241
+ A: 请检查GStreamer是否正确安装,以及网卡多播配置是否正确。
242
+
243
+ ### Q: 某些动作无法执行?
244
+ A: 请检查机器狗当前状态,某些动作需要在特定状态下才能执行。
245
+
246
+ ## 贡献
247
+
248
+ 欢迎提交 Issue 和 Pull Request!
249
+
250
+ ## 许可证
251
+
252
+ 本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件。
253
+
254
+ ## 更新日志
255
+
256
+ ### v0.0.1 (2024-01-01)
257
+ - 初始版本发布
258
+ - 基本运动控制功能
259
+ - 视频流获取功能
260
+ - UI界面功能