xgolib 1.4.2__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.
xgolib-1.4.2/PKG-INFO ADDED
@@ -0,0 +1,4 @@
1
+ Metadata-Version: 2.4
2
+ Name: xgolib
3
+ Version: 1.4.2
4
+ Requires-Dist: pyserial
@@ -0,0 +1,10 @@
1
+ [build-system]
2
+ requires = ["setuptools>=45", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "xgolib"
7
+ version = "1.4.2"
8
+ dependencies = [
9
+ "pyserial",
10
+ ]
xgolib-1.4.2/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,59 @@
1
+ """
2
+ XGO 机器人控制库
3
+ 统一入口,自动选择设备类型
4
+ """
5
+
6
+ # 直接导入所有类
7
+ from .xgolib_dog import XGO_DOG
8
+ from .xgolib_rider import XGO_RIDER
9
+
10
+ __version__ = '1.4.2'
11
+ __all__ = ['XGO', 'XGO_DOG', 'XGO_RIDER']
12
+
13
+ def XGO(port="/dev/ttyAMA0", baud=115200, version="auto", verbose=False):
14
+ """
15
+ 统一的XGO类工厂函数
16
+
17
+ Args:
18
+ port: 串口设备路径
19
+ baud: 波特率
20
+ version: 设备版本
21
+ "auto" - 自动检测
22
+ "xgomini" - XGO-MINI
23
+ "xgolite" - XGO-LITE
24
+ "xgomini3w" - XGO-MINI3W
25
+ "xgorider" - XGO-RIDER
26
+ verbose: 是否显示调试信息
27
+ """
28
+ if version == "auto":
29
+ try:
30
+
31
+ temp_dog = XGO_DOG(port, baud, version="xgomini", verbose=verbose)
32
+ firmware = temp_dog.read_firmware()
33
+ temp_dog.reset()
34
+
35
+ print(f"Detected firmware: {firmware}")
36
+
37
+ if firmware and firmware[0] == 'R':
38
+ print("Auto-detected: XGO-RIDER")
39
+ return XGO_RIDER(port, baud, version="xgorider", verbose=verbose)
40
+ elif firmware and firmware[0] in ['M', 'L', 'W']:
41
+ print(f"Auto-detected: XGO-{firmware[0]}")
42
+ return XGO_DOG(port, baud, version="auto", verbose=verbose)
43
+ else:
44
+ print("Auto-detection failed, using default: XGO-MINI")
45
+ return XGO_DOG(port, baud, version="xgomini", verbose=verbose)
46
+
47
+ except Exception as e:
48
+ print(f"Auto detection failed: {e}, using default: XGO-MINI")
49
+ return XGO_DOG(port, baud, version="xgomini", verbose=verbose)
50
+
51
+ elif version in ["xgomini", "xgolite", "xgomini3w"]:
52
+ return XGO_DOG(port, baud, version=version, verbose=verbose)
53
+
54
+ elif version == "xgorider":
55
+ return XGO_RIDER(port, baud, version=version, verbose=verbose)
56
+
57
+ else:
58
+ print(f"Warning: Unknown version '{version}', using 'xgomini' instead")
59
+ return XGO_DOG(port, baud, version="xgomini", verbose=verbose)