Skip to content

Commit 5cea543

Browse files
committed
Merge pull request #213 from diydrones/fix_use_of_cmds_clear
Improve docs to reduce issues from #132 mk 2
2 parents 50b650a + 562950f commit 5cea543

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

docs/examples/flight_replay.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ We generate up to 100 waypoints for the vehicle with the following code:
7070
print "Generating %s waypoints from replay..." % len(messages)
7171
cmds = v.commands
7272
cmds.clear()
73+
v.flush()
7374
for i in xrange(0, len(messages)):
7475
pt = messages[i]
7576
lat = pt['lat']
@@ -96,5 +97,7 @@ Source code
9697

9798
The full source code at documentation build-time is listed below (`current version on github <https://github.com/diydrones/dronekit-python/blob/master/examples/flight_replay/flight_replay.py>`_):
9899

99-
.. include:: ../../examples/flight_replay/flight_replay.py
100-
:literal:
100+
101+
.. literalinclude:: ../../examples/flight_replay/flight_replay.py
102+
:language: python
103+

droneapi/lib/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ class CommandSequence(object):
853853
854854
cmds = vehicle.commands
855855
cmds.clear()
856+
vehicle.flush()
856857
lat = -34.364114,
857858
lon = 149.166022
858859
altitude = 30.0
@@ -921,6 +922,13 @@ def goto(self, location):
921922
def clear(self):
922923
'''
923924
Clear the command list.
925+
926+
.. warning::
927+
928+
Call ``flush()`` immediately after clearing the commands/before adding new commands (see
929+
`#132 for more information <https://github.com/diydrones/dronekit-python/issues/132>`_).
930+
931+
.. todo:: The above note should be removed when https://github.com/diydrones/dronekit-python/issues/132 fixed
924932
'''
925933
pass
926934

examples/flight_replay/flight_replay.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
#
2-
# This is an example of talking to Droneshare to receive a past flight, and then 'replaying' that flight by sending waypoints
3-
# to the vehicle that approximates the stored flight log.
4-
# Usage:
5-
# * mavproxy.py
6-
# * module load api
7-
# * api start flight_replay.py <missionid>
8-
# (Where mission ID is a numeric mission number from a public droneshare flight)
9-
#
1+
"""
2+
flight_replay.py:
3+
4+
An example of talking to Droneshare to receive a past flight, and then 'replaying'
5+
that flight by sending waypoints to a vehicle.
6+
7+
Start this example as shown below, specifying the
8+
missionid (a numeric mission number from a public droneshare flight):
9+
10+
api start flight_replay.py <missionid>
11+
12+
Full documentation is provided at http://python.dronekit.io/examples/flight_replay.html
13+
"""
14+
1015
from droneapi.lib import Command
1116
from pymavlink import mavutil
1217
import json, urllib, math
@@ -73,6 +78,7 @@ def replay_mission(payload):
7378
print "Generating %s waypoints from replay..." % len(messages)
7479
cmds = v.commands
7580
cmds.clear()
81+
v.flush()
7682
for i in xrange(0, len(messages)):
7783
pt = messages[i]
7884
lat = pt['lat']

0 commit comments

Comments
 (0)