0

我按照此页面上的说明进行操作:http:
//python.dronekit.io/guide/quick_start.html

我做了什么:

pip install dronekit

pip install dronekit-sitl

然后我在其中创建了一个 python 文件:

print ("Start simulator (SITL)")
import dronekit_sitl

sitl = dronekit_sitl.start_default()
#connection_string = sitl.connection_string()

# Import DroneKit-Python
from dronekit import connect, VehicleMode

# Connect to the Vehicle.
print("Connecting to vehicle on: %s" % ('tcp:127.0.0.1:5760',))
vehicle = connect('tcp:127.0.0.1:5760', wait_ready=True)

# Get some vehicle attributes (state)
print ("Get some vehicle attribute values:")
print (" GPS: %s" % vehicle.gps_0)
print (" Battery: %s" % vehicle.battery)
print (" Last Heartbeat: %s" % vehicle.last_heartbeat)
print (" Is Armable?: %s" % vehicle.is_armable)
print (" System status: %s" % vehicle.system_status.state)
print (" Mode: %s" % vehicle.mode.name)    # settable

# Close vehicle object before exiting script
vehicle.close()

# Shut down simulator
sitl.stop()
print("Completed")

然后我运行它,这是我在终端上遇到的错误:

olin30259168:Desktop physics$ python hello.py
Start simulator (SITL)
Starting copter simulator (SITL)
SITL already Downloaded and Extracted.
Ready to boot.
Connecting to vehicle on: tcp:127.0.0.1:5760
>>> APM:Copter V3.3 (d6053245)
>>> Frame: QUAD
>>> Calibrating barometer
Traceback (most recent call last):
  File "hello.py", line 12, in <module>
    vehicle = connect('tcp:127.0.0.1:5760', wait_ready=True)
  File "/Users/physics/anaconda/lib/python3.6/site-packages/dronekit/__init__.py", line 2849, in connect
    vehicle.wait_ready(True)
  File "/Users/physics/anaconda/lib/python3.6/site-packages/dronekit/__init__.py", line 2199, in wait_ready
    timeout)
dronekit.APIException: wait_ready experienced a timeout after 30 seconds.
olin30259168:Desktop physics$ 

我应该得到的是:

Start simulator (SITL)
Downloading SITL from http://dronekit-assets.s3.amazonaws.com/sitl/copter/sitl-win-copter-3.3.tar.gz
Extracted.
Connecting to vehicle on: 'tcp:127.0.0.1:5760'
>>> APM:Copter V3.3 (d6053245)
>>> Frame: QUAD
>>> Calibrating barometer
>>> Initialising APM...
>>> barometer calibration complete
>>> GROUND START
Get some vehicle attribute values:
 GPS: GPSInfo:fix=3,num_sat=10
 Battery: Battery:voltage=12.587,current=0.0,level=100
 Last Heartbeat: 0.713999986649
 Is Armable?: False
 System status: STANDBY
 Mode: STABILIZE
Completed

它似乎已连接,但尝试校准气压计超时,当我运行从该目录克隆的示例时遇到了同样的问题:

https://github.com/dronekit/dronekit-python/tree/master/examples

4

1 回答 1

0

这是我在 Windows 10 上安装的,如果出现同样的问题,只需重新启动计算机并重新运行最多 4 次,然后告诉我。

1) 安装 Python 2.7

2) 访问https://pip.pypa.io/en/stable/installing/ 单击 get-pip.py b。保存在桌面 C. 下载后双击它

3) 转到命令提示符 如果它显示 C:\Users\oscar4423> i。键入 cd C:\Python27\Scripts b。完成步骤后,键入 pip,如下所示 C:\Python27\Scripts>pip c。现在输入 pip install requests:C:\Python27\Scripts>pip install requests

4)关闭命令提示符

5) 前往https://git-scm.com/downloads,然后点击“download for Windows”</p>

6) 安装 git 7) 打开命令提示符并输入 cd C:\Python27\Scripts

8) 键入 pip install git+ https://github.com/3drobotics/solo-cli C:\Python27\Scripts>pip install git+ https://github.com/3drobotics/solo-cli

9) 现在安装以下 pip install virtualenv 10) 在命令提示符下键入 pip install dronekit,如下所示:C:\Python27\Scripts> pip install dronekit

11) 在命令提示符下键入 pip install dronekit-sitl,如下所示:C:\Python27\Scripts> pip install dronekit-sitl

12) pip install numpy pyparsing

13) 点安装 MAVProxy

于 2017-12-03T01:58:38.390 回答