简体   繁体   English

Dronekit Python车辆连接超时

[英]Dronekit python vehicle connection timeout

we are having a bit of trouble getting Dronekit working with our copter. 让Dronekit与我们的直升机配合使用会遇到一些麻烦。 Thus far we have tested everything using SITL and it all works fine, however this success has not transferred across to the real thing very well. 到目前为止,我们已经使用SITL测试了所有内容,并且一切正常,但是这种成功并未很好地转移到真实事物上。

Our setup is: Windows GCS running Mavproxy (Master via COM9, UDP outputs for the Dronekit script and Mission Planner) and a basic Dronekit script (Takeoff and land). 我们的设置是:运行Mavproxy(通过COM9为主,Dronekit脚本和Mission Planner的UDP输出)和基本Dronekit脚本(起飞和降落)的Windows GCS。 Please see the diagram for a clearer explanation. 请参阅该图以获得更清晰的说明。

在此处输入图片说明

We use the following command when running MAVProxy: mavproxy.exe --master=com9,57600 --out=udp:127.0.0.1:14550 --out=udp:127.0.0.1:14551 --console 运行MAVProxy时,我们使用以下命令:mavproxy.exe --master = com9,57600 --out = udp:127.0.0.1:14550 --out = udp:127.0.0.1:14551 --console

The issue we are having is connecting to the vehicle ( http://python.dronekit.io/guide/connecting_vehicle.html ), we are able to connect to the drone and get some board information. 我们遇到的问题是连接到车辆( http://python.dronekit.io/guide/connecting_vehicle.html ),我们能够连接到无人机并获得一些主板信息。 However then we do not receive a heartbeat message for 30 seconds, leading to a timeout. 但是,在30秒钟内我们没有收到心跳消息,导致超时。

>>> APM:Copter V3.5.2 (4322ffda)
>>> PX4: 1d6bf64c NuttX: 1a99ba58
>>> Frame: QUAD
>>> PX4v3 0020002E 30365110 35323931

Traceback (most recent call last):
  File "C:/Users/simon/PycharmProjects/uas_lol/test_mission.py", line 32, in <module>
    vehicle = connect(connection_string, wait_ready=True, baud=57600, heartbeat_timeout=120)
  File "C:\Python27\lib\site-packages\dronekit\__init__.py", line 2849, in connect
    vehicle.wait_ready(True)
  File "C:\Python27\lib\site-packages\dronekit\__init__.py", line 2199, in wait_ready
    timeout)
dronekit.APIException: wait_ready experienced a timeout after 30 seconds.

Process finished with exit code 1

We can bypass the timeout by setting wait_ready=False. 我们可以通过设置wait_ready = False来绕过超时。 Using this we can connect to the vehicle and arm the drone. 使用此工具,我们可以连接到车辆并武装无人机。 When it comes to taking off, it only works some of the time. 关于起飞,它仅在某些时间有效。 We find it is more likely to work (takes off) when we reset MAVProxy. 我们发现重置MAVProxy时,它更有可能工作(起飞)。

I would like to confirm that connecting to the drone using udp 127.0.0.1:14550 with Mission Planner works perfectly. 我想确认,使用带有Mission Planner的udp 127.0.0.1:14550连接到无人机是否可以正常工作。

Any insight as to what we may be doing incorrectly would be greatly appreciated, thank you! 非常感谢您对我们可能做错的任何见解,谢谢!

Turns out the issue was that because we were connected over serial telemetry at a baud rate of 57600 it takes ~2 minutes to download the parameters and Dronekit times out after 30 seconds. 原来的问题是,因为我们以57600的波特率通过串行遥测进行连接,所以下载参数大约需要2分钟,而Dronekit在30秒后会超时。

According to the documentation you can set the timeout using heartbeat_timeout=180 ( http://python.dronekit.io/automodule.html#dronekit.connect ). 根据文档,您可以使用heartbeat_timeout = 180( http://python.dronekit.io/automodule.html#dronekit.connect )设置超时。 However this did not actually solve the problem as it was still timing out after 30 seconds. 但是,这实际上并没有解决问题,因为它在30秒后仍然超时。

It looks like 30 seconds may be coded into the library, changing 30 to 180 in the following line solved my issue. 看来30秒可能已编码到库中,在下一行中将30更改为180解决了我的问题。 https://github.com/dronekit/dronekit-python/blob/754ce6223dd26179045eaa394d5df0a5f787ebb2/dronekit/ init .py#L2216 https://github.com/dronekit/dronekit-python/blob/754ce6223dd26179045eaa394d5df0a5f787ebb2/dronekit/ init .py#L2216

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM