Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/examples/flight_replay.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -96,5 +97,7 @@ Source code

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>`_):

.. include:: ../../examples/flight_replay/flight_replay.py
:literal:

.. literalinclude:: ../../examples/flight_replay/flight_replay.py
:language: python

8 changes: 8 additions & 0 deletions droneapi/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ class CommandSequence(object):

cmds = vehicle.commands
cmds.clear()
vehicle.flush()
lat = -34.364114,
lon = 149.166022
altitude = 30.0
Expand Down Expand Up @@ -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 <https://github.com/diydrones/dronekit-python/issues/132>`_).

.. todo:: The above note should be removed when https://github.com/diydrones/dronekit-python/issues/132 fixed
'''
pass

Expand Down
24 changes: 15 additions & 9 deletions examples/flight_replay/flight_replay.py
Original file line number Diff line number Diff line change
@@ -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 <missionid>
# (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 <missionid>

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
Expand Down Expand Up @@ -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']
Expand Down