From 1ccc27014ac38fb168a8dfca0cbdcc1b9ebbbd92 Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Mon, 26 Oct 2015 18:56:24 -0700 Subject: [PATCH] Fixes waypoints clear. --- dronekit/module/api.py | 6 +++--- tests/sitl/test_waypoints.py | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/sitl/test_waypoints.py diff --git a/dronekit/module/api.py b/dronekit/module/api.py index c410cc22d..1b8219bf8 100644 --- a/dronekit/module/api.py +++ b/dronekit/module/api.py @@ -92,14 +92,14 @@ def clear(self): '''Clears the command list''' self.wait_valid() self.__module.wploader.clear() - self.__module.vehicle.wpts_dirty = True + self.__module.api._FakeAPI__vehicle.wpts_dirty = True def add(self, cmd): '''Add a new command at the end of the command list''' self.wait_valid() self.__module.fix_targets(cmd) self.__module.wploader.add(cmd, comment = 'Added by DroneAPI') - self.__module.vehicle.wpts_dirty = True + self.__module.api._FakeAPI__vehicle.wpts_dirty = True @property def count(self): @@ -123,7 +123,7 @@ def __getitem__(self, index): def __setitem__(self, index, value): self.__module.wploader.set(value, index) - self.__module.vehicle.wpts_dirty = True + self.__module.api._FakeAPI__vehicle.wpts_dirty = True class MPVehicle(Vehicle): def __init__(self, module): diff --git a/tests/sitl/test_waypoints.py b/tests/sitl/test_waypoints.py new file mode 100644 index 000000000..ef3e132f1 --- /dev/null +++ b/tests/sitl/test_waypoints.py @@ -0,0 +1,21 @@ +from dronekit import connect +import time +import math +from dronekit import connect +from dronekit.tools import with_sitl +from dronekit.lib import VehicleMode, LocationGlobal +import time +from nose.tools import assert_not_equals + +# This test runs first! +@with_sitl +def test_parameter(connpath): + # Connect to the Vehicle + vehicle = connect(connpath, await_params=True) + + cmds = vehicle.commands + cmds.download() + cmds.wait_valid() + + vehicle.commands.clear() + vehicle.flush()