Debugging

DroneKit-Python apps can be debugged in the same way as any other standalone Python scripts. The sections below outline a few methods.

pdb - The Python Debugger

The Python Debugger - pdb can be used to debug DroneKit-Python apps.

The command below can be used to run a script in debug mode:

python -m pdb my_dronekit_script.py

You can also instrument your code to invoke the debugger at a certain point. To do this add set-trace() at the point where you want to break execution:

# Connect to the Vehicle on udp at 127.0.0.1:14550
vehicle = connect('127.0.0.1:14550', wait_ready=True)

import pdb; pdb.set_trace()
print "Global Location: %s" % vehicle.location.global_frame

The available debugger commands are listed here.

pudb - A full-screen, console-based Python debugger

If you prefer a IDE like debug you can use pudb - A full-screen, console-based Python debugger.

pip install pudb

To start debugging, simply insert:

from pudb import set_trace; set_trace()

Insert either of these snippets into the piece of code you want to debug, or run the entire script with:

pudb my-script.py

Other IDEs/debuggers

There is no reason you should not be able to straightforwardly use other popular Python IDEs including IDLE and Eclipse.