我想通过 USB 使用 Python 3 连接到 LEGO Mindstorms NXT 机器人,但是当我尝试连接时出现 BrickNotFoundError。
这是我试图运行的脚本:
#!/usr/bin/env python
import nxt.locator
from nxt.motor import *
#nxt.locator.make_config()
def spin_around(b):
m_left = Motor(b, PORT_B)
m_left.turn(100, 360)
m_right = Motor(b, PORT_C)
m_right.turn(-100, 360)
b = nxt.locator.find_one_brick(debug = True)
#spin_around(b)
在 Windows 10 中的 python 3.6 上运行此程序,NXT 机器人通过 USB 电缆连接到计算机,得到以下堆栈跟踪:
Host: AB:CD:EF:GH:IJ:KL Name: BRUCE Strict: True
USB: True BT: False Fantom: True FUSB: False FBT: True
Fantom module unavailable, not searching there
Traceback (most recent call last):
File "C:\Users\George\Downloads\nxt\examples\spin.py", line 14, in <module>
b = nxt.locator.find_one_brick(debug = True)
File "C:\Users\George\AppData\Local\Programs\Python\Python36-32\lib\site-packages\nxt\locator.py", line 138, in find_one_brick
raise BrickNotFoundError
nxt.locator.BrickNotFoundError
我已经下载了 pyusb 和 usblib 并且已经解决了几个涉及找不到 USB 模块的错误。但是,由于乐高 NXT 官方软件可以成功识别和编程机器人,因此机器人显然已连接到计算机。
我不知道下一步该做什么。欢迎任何有关如何解决此错误的建议...