按照DroneKit说明,我可以从他们的QuickStart指南运行hello.py代码:http://python.dronekit.io/guide/quick_start.html .
但是,当我尝试运行他们的基本任务示例时,我在标题中得到setBaudrate错误:
$ python mission_basic.py --connect=/dev/tty.usbmodem1411 Connecting to vehicle on: /dev/tty.usbmodem1411 Traceback (most recent call last): File "mission_basic.py", line 23, invehicle = connect(args.connect, wait_ready=True) File "/Library/Python/2.7/site-packages/dronekit/__init__.py", line 2344, in connect handler = MAVConnection(ip, baud=baud, source_system=source_system) File "/Library/Python/2.7/site-packages/dronekit/mavlink.py", line 37, in __init__ self.master = mavutil.mavlink_connection(ip, baud=baud, source_system=source_system) File "/Library/Python/2.7/site-packages/pymavlink/mavutil.py", line 1106, in mavlink_connection return mavserial(device, baud=baud, source_system=source_system, autoreconnect=autoreconnect, use_native=use_native) File "/Library/Python/2.7/site-packages/pymavlink/mavutil.py", line 735, in __init__ self.set_baudrate(self.baud) File "/Library/Python/2.7/site-packages/pymavlink/mavutil.py", line 746, in set_baudrate self.port.setBaudrate(baudrate) AttributeError: 'Serial' object has no attribute 'setBaudrate'
注意:tty.usbmodem1411是我的USB电缆直接从运行Yosemite的Mac运行到APM.我也试过3DR遥测套件,结果相同.我也尝试在波特率选项中添加相同的结果.
更新:使用陈昭宇给出的链接补丁解决了我的波特率问题; 但是,我仍然遇到一个永远不会发现心跳的问题.这个问题也是因为pyserial更新.使用Tim Ryan提供的旧的pyserial解决方案解决了这两个问题.
Fin,看起来像pySerial 3.0在过去一周发布,它改变了它的API.pymavlink(由DroneKit-Python使用)需要pySerial 2.0.我已经提交了一个问题并将努力解决它.
在此期间,请尝试pip install "pySerial>=2.0,<=2.9999"
查看这是否可以解决您的问题.