From 562950f0a7bfeb08f4f0251eafd673040f915b72 Mon Sep 17 00:00:00 2001 From: hamishwillee Date: Fri, 17 Jul 2015 10:13:36 +1000 Subject: [PATCH] Improve docs to reduce issues from #132 --- docs/examples/flight_replay.rst | 7 +++++-- droneapi/lib/__init__.py | 8 ++++++++ examples/flight_replay/flight_replay.py | 24 +++++++++++++++--------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/docs/examples/flight_replay.rst b/docs/examples/flight_replay.rst index af61b7c9f..794e90a08 100644 --- a/docs/examples/flight_replay.rst +++ b/docs/examples/flight_replay.rst @@ -70,6 +70,7 @@ We generate up to 100 waypoints for the vehicle with the following code: print "Generating %s waypoints from replay..." % len(messages) cmds = v.commands cmds.clear() + v.flush() for i in xrange(0, len(messages)): pt = messages[i] lat = pt['lat'] @@ -96,5 +97,7 @@ Source code The full source code at documentation build-time is listed below (`current version on github `_): -.. include:: ../../examples/flight_replay/flight_replay.py - :literal: + +.. literalinclude:: ../../examples/flight_replay/flight_replay.py + :language: python + \ No newline at end of file diff --git a/droneapi/lib/__init__.py b/droneapi/lib/__init__.py index c32ea72b4..26bd20853 100644 --- a/droneapi/lib/__init__.py +++ b/droneapi/lib/__init__.py @@ -853,6 +853,7 @@ class CommandSequence(object): cmds = vehicle.commands cmds.clear() + vehicle.flush() lat = -34.364114, lon = 149.166022 altitude = 30.0 @@ -921,6 +922,13 @@ def goto(self, location): def clear(self): ''' Clear the command list. + + .. warning:: + + Call ``flush()`` immediately after clearing the commands/before adding new commands (see + `#132 for more information `_). + + .. todo:: The above note should be removed when https://github.com/diydrones/dronekit-python/issues/132 fixed ''' pass diff --git a/examples/flight_replay/flight_replay.py b/examples/flight_replay/flight_replay.py index 20af98da3..ef123947b 100644 --- a/examples/flight_replay/flight_replay.py +++ b/examples/flight_replay/flight_replay.py @@ -1,12 +1,17 @@ -# -# This is an example of talking to Droneshare to receive a past flight, and then 'replaying' that flight by sending waypoints -# to the vehicle that approximates the stored flight log. -# Usage: -# * mavproxy.py -# * module load api -# * api start flight_replay.py -# (Where mission ID is a numeric mission number from a public droneshare flight) -# +""" +flight_replay.py: + +An example of talking to Droneshare to receive a past flight, and then 'replaying' +that flight by sending waypoints to a vehicle. + +Start this example as shown below, specifying the +missionid (a numeric mission number from a public droneshare flight): + + api start flight_replay.py + +Full documentation is provided at http://python.dronekit.io/examples/flight_replay.html +""" + from droneapi.lib import Command from pymavlink import mavutil import json, urllib, math @@ -73,6 +78,7 @@ def replay_mission(payload): print "Generating %s waypoints from replay..." % len(messages) cmds = v.commands cmds.clear() + v.flush() for i in xrange(0, len(messages)): pt = messages[i] lat = pt['lat']