6

I am following the getting started instructions in DroneKit-Python to set up DroneKit in a VM. To make things easier for myself I started by Setting up SITL using Vagrant. However I can't work out how to have SITL running and talk to it from the example scripts.

What I did:

  1. Ran SITL vagrant script and got SITL working (tested connection to Mission Planner running on Windows).
  2. Tested it as discussed in "Setting up on Linux" by doing:

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

    param set ARMING_CHECK 0

NOTE - not "STABILIZE>" prompt visible in my MAVProxy prompt. These ran (what appeared to be) successfully

  1. Then I did Ctrl+D to exit the SITL simulation, and vagrant ssh to open my prompt to the virtual machine.
  2. I installed the dependencies as described here (after fixing up the pip specification):

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

Then MAVProxy

sudo pip install MAVProxy

Then droneapi (note, had to be installed using "sudo")

sudo pip install droneapi

Then from command prompt (vagrant@vagrant-ubuntu-trusty-32:/vagrant/ArduCopter$) I got the git clone and navigated to the demo:

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

I started MavProxy using "mavproxy.py" (correct type for Linux VM communicating by USB). Got the following:

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

Finally, despite error above I tried to load and use the module.

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])
...

NOTE "MAV>" prompt not "MANUAL>" as listed in the docs.

The question is "why has this failed, and what do I need to get it to work?" I am guessing the problem is that SITL is not actually running.

Thanks!

Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
Hamish Willee
  • 372
  • 1
  • 3
  • 11

1 Answers1

1

Starting from a fresh checkout of the ardupilot code, in your host OS.

droneapi-python will get installed, but lets get the sample scripts:

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

Bring up the vagrant box:

ardupilot$ vagrant up

Start the SITL as described in "Setting up SITL using Vagrant":

ardupilot$ vagrant ssh -c "sim_vehicle.sh -j 2"

There will be a lot of output, but at the end I see this:

+ 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

Load the droneapi module. See "Loading DroneKit" for information on how to do this automatically when mavproxy starts.

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

Run the DroneKit small_demo.py script:

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

Output:

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
John Wiseman
  • 3,081
  • 1
  • 22
  • 31
  • The missing part of the picture was correctly starting MAVProxy to talk to SITL (and also setting up SITL so I could simultaneously talk to Mission Planner). This is achieved by starting mavproxy using: mavproxy.py --master=127.0.0.1:14550 I will fix the documents so they capture this in the coming week. – Hamish Willee May 04 '15 at 11:24
  • @HamishWillee Should I add something to my answer or is it acceptable? – John Wiseman May 05 '15 at 16:52
  • This runs droneapi within the SITL VM while I am trying to connect to the SITL VM from the host. The approach works but it a) doesn't quite match what I am trying to do b) is not recommended practice (or at least it won't be once I update the docs). This is a good answer to the question "how do I run SITL and droneAPI within the same vagrant vm" – Hamish Willee May 06 '15 at 23:50