如何从dev Wiki使用带有SITL vagrant VM的dronekit

时间:2015-04-01 09:32:30

标签: python dronekit dronekit-python

我正在遵循DroneKit-Python中的getting started指令,在VM中设置DroneKit。为了让自己更轻松,我从Setting up SITL using Vagrant开始。但是,我无法弄清楚如何让SITL运行并从示例脚本中与它进行对话。

我做了什么:

  1. Ran SITL vagrant script并让SITL工作(测试连接到 Mission Planner在Windows上运行。
  2. 通过执行以下操作在“Setting up on Linux”中进行了测试:

    param load ../ Tools / autotest / copter_params.parm

    param set ARMING_CHECK 0

  3. 注意 - 不是“STABILIZE>”提示在我的MAVProxy提示符中可见。 这些成功(似乎是)成功

    1. 然后我按Ctrl + D退出SITL模拟,vagrant ssh到 打开我对虚拟机的提示。
    2. 我安装了dependencies as described here(修好后) pip规范):

      sudo apt-get install python-pip python-numpy python-opencv python-serial python-pyparsing python-wxgtk2.8

    3. 然后是MAVProxy

      sudo pip install MAVProxy
      

      然后droneapi(注意,必须使用“sudo”安装)

      sudo pip install droneapi
      

      然后从命令提示符(vagrant @ vagrant-ubuntu-trusty-32:/ vagrant / ArduCopter $)获得git clone并导航到演示:

      git clone http://github.com/diydrones/droneapi-python.git
      cd droneapi-python/example/small_demo
      

      我使用“mavproxy.py”(通过USB进行Linux VM通信的正确类型)启动了MavProxy。得到以下信息:

      Auto-detected serial ports are:
      /dev/ttyS31
      /dev/ttyS30
      ...
      /dev/ttyS1
      /dev/ttyS0
      Logging to mav.tlog
      libdc1394 error: Failed to initialize libdc1394
      

      最后,尽管有上述错误,我还是尝试加载并使用该模块。

      MAV> module load droneapi.module.api
      MAV> DroneAPI loaded
      Loaded module droneapi.module.api
      api start small_demo.py
      MAV> Exception in APIThread-0:
      Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/droneapi/module/api.py", line 322, in run
      self.fn()
      File "/usr/local/lib/python2.7/dist-packages/droneapi/module/api.py", line 593, in <lambda>
      APIThread(self, lambda: execfile(args[1], g), args[1])
      ...
      

      注意“MAV&gt;”提示不是“手动&gt;”如文档中所列。

      问题是“为什么这会失败,我需要做些什么才能让它发挥作用?”我猜测问题是SITL实际上并没有运行。

      谢谢!

1 个答案:

答案 0 :(得分:1)

从主机操作系统中的ardupilot代码的新结帐开始。

droneapi-python将安装,但让我们获取示例脚本:

ardupilot$ git clone http://github.com/diydrones/droneapi-python.git

打开流浪盒:

ardupilot$ vagrant up

按照"Setting up SITL using Vagrant"

中的说明启动SITL
ardupilot$ vagrant ssh -c "sim_vehicle.sh -j 2"

会有很多输出,但最后我看到了:

+ mavproxy.py --master tcp:127.0.0.1:5760 --sitl 127.0.0.1:5501 --out 10.0.2.2:14550 --out 127.0.0.1:14550 --out 127.0.0.1:14551 --cmd=
Connect tcp:127.0.0.1:5760 source_system=255
Logging to mav.tlog
libdc1394 error: Failed to initialize libdc1394
MAV> 

Init APM:Copter V3.3-dev (e1be8148)
Free RAM: 4096
FW Ver: 120
----------------------------------------

Firmware change: erasing EEPROM...
done.
0 0 0 online system 1
STABILIZE> Mode STABILIZE
APM: APM:Copter V3.3-dev (e1be8148)
APM: Frame: QUAD
APM: Calibrating barometer
APM: Initialising APM...
APM: barometer calibration complete
APM: GROUND START
Init Gyro**
INS
----------------------------------------
G_off: 0.00, 0.00, 0.00
A_off: 0.00, 0.00, 0.00
A_scale: 1.00, 1.00, 1.00

Ready to FLY  ublox Received 473 parameters
fence breach
GPS lock at 0 meters
APM: PreArm: RC not calibrated

加载droneapi模块。有关如何在mavproxy启动时自动执行此操作的信息,请参阅"Loading DroneKit"

STABILIZE> module load droneapi.module.api
STABILIZE> DroneAPI loaded

运行DroneKit small_demo.py script

STABILIZE> api start ../droneapi-python/example/small_demo/small_demo.py 

输出:

STABILIZE> Mode: VehicleMode:STABILIZE
Location: Location:lat=-35.3632609,lon=149.1652299,alt=-0.280000001192,is_relative=False
Attitude: Attitude:pitch=-0.0046319803223,yaw=-0.571676075459,roll=-0.00480426847935
Velocity: [0.11, -0.06, -0.06]
GPS: GPSInfo:fix=3,num_sat=10
Armed: False
groundspeed: 0.0
airspeed: 0.0
Requesting 0 waypoints t=Fri May  1 02:18:50 2015 now=Fri May  1 02:18:50 2015
Home WP: MISSION_ITEM {target_system : 255, target_component : 0, seq : 0, frame : 0, command : 16, current : 0, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : -35.3632621765, y : 149.165237427, z : 584.33001709}
Current dest: 0
Disarming...
Arming...
Overriding a RC channel
Current overrides are: {'1': 900, '4': 1000}
RC readback: {'1': 1500, '3': 1000, '2': 1500, '5': 1800, '4': 1500, '7': 1000, '6': 1000, '8': 1800}
Cancelling override
APIThread-0 exiting...
Got MAVLink msg: COMMAND_ACK {command : 400, result : 0}
APM: PreArm: RC not calibrated
Got MAVLink msg: COMMAND_ACK {command : 400, result : 4}
Got MAVLink msg: COMMAND_ACK {command : 11, result : 0}
AUTO> Mode AUTO