From 71a132397d9de2c69a235d3e21b9b7e1aa54aae6 Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Wed, 28 Oct 2015 18:29:13 -0700 Subject: [PATCH 01/13] Moves home_location out of commands array. --- dronekit/lib/__init__.py | 24 +++++++++++++++++------- tests/sitl/test_waypoints.py | 6 +++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/dronekit/lib/__init__.py b/dronekit/lib/__init__.py index 9ea88d94d..9a79ef80a 100644 --- a/dronekit/lib/__init__.py +++ b/dronekit/lib/__init__.py @@ -688,6 +688,12 @@ def channel_override(self, newch): def channel_readback(self): return self.__module.rc_readback + @property + def home_location(self): + if self._waypoints is None: # We create the wpts lazily (because this will start a fetch) + self._waypoints = CommandSequence(self.__module) + return self.__module.wploader.wp(0) + @property def commands(self): """ @@ -698,7 +704,7 @@ def commands(self): :returns: A :py:class:`CommandSequence` containing the waypoints for this vehicle. """ - if(self._waypoints is None): # We create the wpts lazily (because this will start a fetch) + if self._waypoints is None: # We create the wpts lazily (because this will start a fetch) self._waypoints = CommandSequence(self.__module) return self._waypoints @@ -1051,8 +1057,12 @@ def clear(self): .. todo:: The above note should be removed when https://github.com/dronekit/dronekit-python/issues/132 fixed ''' + + # Add home point again. self.wait_valid() + home = self.__module.wploader.wp(0) self.__module.wploader.clear() + self.__module.wploader.add(home, comment='Added by DroneKit') self.__module.vehicle.wpts_dirty = True def add(self, cmd): @@ -1065,7 +1075,7 @@ def add(self, cmd): ''' self.wait_valid() self.__module.fix_targets(cmd) - self.__module.wploader.add(cmd, comment = 'Added by DroneAPI') + self.__module.wploader.add(cmd, comment='Added by DroneKit') self.__module.vehicle.wpts_dirty = True @property @@ -1075,7 +1085,7 @@ def count(self): :return: The number of waypoints in the sequence. ''' - return self.__module.wploader.count() + return self.__module.wploader.count() - 1 @property def next(self): @@ -1089,7 +1099,7 @@ def next(self, index): """ Set a new ``next`` waypoint for the vehicle. """ - self.__module.master.waypoint_set_current_send(index) + self.__module.master.waypoint_set_current_send(index - 1) def __len__(self): ''' @@ -1097,11 +1107,11 @@ def __len__(self): :return: The number of waypoints in the sequence. ''' - return self.__module.wploader.count() + return self.__module.wploader.count() - 1 def __getitem__(self, index): - return self.__module.wploader.wp(index) + return self.__module.wploader.wp(index - 1) def __setitem__(self, index, value): - self.__module.wploader.set(value, index) + self.__module.wploader.set(value, index - 1) self.__module.vehicle.wpts_dirty = True diff --git a/tests/sitl/test_waypoints.py b/tests/sitl/test_waypoints.py index 1a745e560..29a5d512a 100644 --- a/tests/sitl/test_waypoints.py +++ b/tests/sitl/test_waypoints.py @@ -13,14 +13,14 @@ def test_parameter(connpath): cmds = vehicle.commands cmds.download() cmds.wait_valid() - assert_equals(len(cmds), 1) + assert_equals(len(cmds), 0) # After clearing cmds.clear() vehicle.flush() cmds.download() cmds.wait_valid() - assert_equals(len(cmds), 1) + assert_equals(len(cmds), 0) # Upload for command in [ @@ -39,4 +39,4 @@ def test_parameter(connpath): # After upload cmds.download() cmds.wait_valid() - assert_equals(len(cmds), 9) + assert_equals(len(cmds), 8) From a8a061328b81de7d588e07cea54fe1f03d24af20 Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Wed, 28 Oct 2015 18:45:57 -0700 Subject: [PATCH 02/13] Adds home checks. Statically creates commands array. --- dronekit/lib/__init__.py | 6 +----- tests/sitl/test_waypoints.py | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/dronekit/lib/__init__.py b/dronekit/lib/__init__.py index 9a79ef80a..9d5619307 100644 --- a/dronekit/lib/__init__.py +++ b/dronekit/lib/__init__.py @@ -560,7 +560,7 @@ def __init__(self, module): self.mavrx_callback = None self.__module = module self._parameters = Parameters(module) - self._waypoints = None + self._waypoints = CommandSequence(self.__module) self.wpts_dirty = False def close(self): @@ -690,8 +690,6 @@ def channel_readback(self): @property def home_location(self): - if self._waypoints is None: # We create the wpts lazily (because this will start a fetch) - self._waypoints = CommandSequence(self.__module) return self.__module.wploader.wp(0) @property @@ -704,8 +702,6 @@ def commands(self): :returns: A :py:class:`CommandSequence` containing the waypoints for this vehicle. """ - if self._waypoints is None: # We create the wpts lazily (because this will start a fetch) - self._waypoints = CommandSequence(self.__module) return self._waypoints @property diff --git a/tests/sitl/test_waypoints.py b/tests/sitl/test_waypoints.py index 29a5d512a..0b1b27b74 100644 --- a/tests/sitl/test_waypoints.py +++ b/tests/sitl/test_waypoints.py @@ -8,12 +8,23 @@ def test_parameter(connpath): # Connect to the Vehicle vehicle = connect(connpath, await_params=True) + cmds = vehicle.commands + + # Home should be None at first. + assert_equals(vehicle.home_location, None) + + # Wait for home position to be real and not 0, 0, 0 + # once we request it via cmds.download() + time.sleep(10) # Initial - cmds = vehicle.commands cmds.download() cmds.wait_valid() assert_equals(len(cmds), 0) + assert_not_equals(vehicle.home_location, None) + + # Save home for comparison. + home = vehicle.home_location # After clearing cmds.clear() @@ -40,3 +51,8 @@ def test_parameter(connpath): cmds.download() cmds.wait_valid() assert_equals(len(cmds), 8) + + # Home should be preserved + assert_equals(home.x, vehicle.home_location.x) + assert_equals(home.y, vehicle.home_location.y) + assert_equals(home.z, vehicle.home_location.z) From 44b1c80ee4bdfefbeec6aab7898b0548503b8100 Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Thu, 29 Oct 2015 14:21:58 -0700 Subject: [PATCH 03/13] Allows clear() on empty commands array. Fixes len < 0 bug. --- dronekit/lib/__init__.py | 7 ++++--- tests/sitl/test_waypoints.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dronekit/lib/__init__.py b/dronekit/lib/__init__.py index 9d5619307..b99b7afd4 100644 --- a/dronekit/lib/__init__.py +++ b/dronekit/lib/__init__.py @@ -1058,7 +1058,8 @@ def clear(self): self.wait_valid() home = self.__module.wploader.wp(0) self.__module.wploader.clear() - self.__module.wploader.add(home, comment='Added by DroneKit') + if home: + self.__module.wploader.add(home, comment='Added by DroneKit') self.__module.vehicle.wpts_dirty = True def add(self, cmd): @@ -1081,7 +1082,7 @@ def count(self): :return: The number of waypoints in the sequence. ''' - return self.__module.wploader.count() - 1 + return max(self.__module.wploader.count() - 1, 0) @property def next(self): @@ -1103,7 +1104,7 @@ def __len__(self): :return: The number of waypoints in the sequence. ''' - return self.__module.wploader.count() - 1 + return max(self.__module.wploader.count() - 1, 0) def __getitem__(self, index): return self.__module.wploader.wp(index - 1) diff --git a/tests/sitl/test_waypoints.py b/tests/sitl/test_waypoints.py index 0b1b27b74..635bdafa9 100644 --- a/tests/sitl/test_waypoints.py +++ b/tests/sitl/test_waypoints.py @@ -4,6 +4,17 @@ from dronekit.tools import with_sitl from nose.tools import assert_not_equals, assert_equals +@with_sitl +def test_empty_clear(connpath): + # Connect to the Vehicle + vehicle = connect(connpath) + + # Calling clear() on an empty object should not crash. + vehicle.commands.clear() + vehicle.flush() + + assert_equals(len(vehicle.commands), 0) + @with_sitl def test_parameter(connpath): # Connect to the Vehicle From a1d425cf32e2687f66e87df7d1511803224a4697 Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Thu, 29 Oct 2015 14:31:03 -0700 Subject: [PATCH 04/13] Corrects home_location to be LocationGlobal. --- dronekit/lib/__init__.py | 4 +++- tests/sitl/test_waypoints.py | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dronekit/lib/__init__.py b/dronekit/lib/__init__.py index b99b7afd4..8e196b971 100644 --- a/dronekit/lib/__init__.py +++ b/dronekit/lib/__init__.py @@ -690,7 +690,9 @@ def channel_readback(self): @property def home_location(self): - return self.__module.wploader.wp(0) + loc = self.__module.wploader.wp(0) + if loc: + return LocationGlobal(loc.x, loc.y, loc.z, is_relative=False) @property def commands(self): diff --git a/tests/sitl/test_waypoints.py b/tests/sitl/test_waypoints.py index 635bdafa9..0c3d5baef 100644 --- a/tests/sitl/test_waypoints.py +++ b/tests/sitl/test_waypoints.py @@ -6,7 +6,6 @@ @with_sitl def test_empty_clear(connpath): - # Connect to the Vehicle vehicle = connect(connpath) # Calling clear() on an empty object should not crash. @@ -17,7 +16,6 @@ def test_empty_clear(connpath): @with_sitl def test_parameter(connpath): - # Connect to the Vehicle vehicle = connect(connpath, await_params=True) cmds = vehicle.commands @@ -64,6 +62,6 @@ def test_parameter(connpath): assert_equals(len(cmds), 8) # Home should be preserved - assert_equals(home.x, vehicle.home_location.x) - assert_equals(home.y, vehicle.home_location.y) - assert_equals(home.z, vehicle.home_location.z) + assert_equals(home.lat, vehicle.home_location.lat) + assert_equals(home.lon, vehicle.home_location.lon) + assert_equals(home.alt, vehicle.home_location.alt) From 18b092f9d371144a62fedbf6bb7e995c6ba1772d Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Thu, 29 Oct 2015 14:33:10 -0700 Subject: [PATCH 05/13] Implements slicing and iteration for commands. --- dronekit/lib/__init__.py | 10 +++++++++- tests/sitl/test_waypoints.py | 12 ++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dronekit/lib/__init__.py b/dronekit/lib/__init__.py index 8e196b971..c59fa3f80 100644 --- a/dronekit/lib/__init__.py +++ b/dronekit/lib/__init__.py @@ -1109,7 +1109,15 @@ def __len__(self): return max(self.__module.wploader.count() - 1, 0) def __getitem__(self, index): - return self.__module.wploader.wp(index - 1) + if isinstance(index, slice): + return [self[ii] for ii in xrange(*index.indices(len(self)))] + elif isinstance(index, int): + item = self.__module.wploader.wp(index - 1) + if not item: + raise IndexError('Index %s out of range.' % index) + return item + else: + raise TypeError('Invalid argument type.') def __setitem__(self, index, value): self.__module.wploader.set(value, index - 1) diff --git a/tests/sitl/test_waypoints.py b/tests/sitl/test_waypoints.py index 0c3d5baef..8e826675f 100644 --- a/tests/sitl/test_waypoints.py +++ b/tests/sitl/test_waypoints.py @@ -61,6 +61,18 @@ def test_parameter(connpath): cmds.wait_valid() assert_equals(len(cmds), 8) + # Test iteration. + out = [] + for cmd in vehicle.commands: + assert_not_equals(cmd, None) + + # Test slicing + count = 0 + for cmd in vehicle.commands[2:5]: + assert_not_equals(cmd, None) + count += 1 + assert_equals(count, 3) + # Home should be preserved assert_equals(home.lat, vehicle.home_location.lat) assert_equals(home.lon, vehicle.home_location.lon) From c1f497aad7ddba98fd2a67a00a415d35d2f620f6 Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Fri, 30 Oct 2015 15:24:51 -0700 Subject: [PATCH 06/13] Fixes indexing logic. --- dronekit/lib/__init__.py | 6 +++--- tests/sitl/test_waypoints.py | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dronekit/lib/__init__.py b/dronekit/lib/__init__.py index c59fa3f80..0b0ac8202 100644 --- a/dronekit/lib/__init__.py +++ b/dronekit/lib/__init__.py @@ -1098,7 +1098,7 @@ def next(self, index): """ Set a new ``next`` waypoint for the vehicle. """ - self.__module.master.waypoint_set_current_send(index - 1) + self.__module.master.waypoint_set_current_send(index + 1) def __len__(self): ''' @@ -1112,7 +1112,7 @@ def __getitem__(self, index): if isinstance(index, slice): return [self[ii] for ii in xrange(*index.indices(len(self)))] elif isinstance(index, int): - item = self.__module.wploader.wp(index - 1) + item = self.__module.wploader.wp(index + 1) if not item: raise IndexError('Index %s out of range.' % index) return item @@ -1120,5 +1120,5 @@ def __getitem__(self, index): raise TypeError('Invalid argument type.') def __setitem__(self, index, value): - self.__module.wploader.set(value, index - 1) + self.__module.wploader.set(value, index + 1) self.__module.vehicle.wpts_dirty = True diff --git a/tests/sitl/test_waypoints.py b/tests/sitl/test_waypoints.py index 8e826675f..39b2e6737 100644 --- a/tests/sitl/test_waypoints.py +++ b/tests/sitl/test_waypoints.py @@ -62,16 +62,19 @@ def test_parameter(connpath): assert_equals(len(cmds), 8) # Test iteration. - out = [] + count = 0 for cmd in vehicle.commands: assert_not_equals(cmd, None) + count += 1 + assert_equals(count, 8) # Test slicing - count = 0 + count = 3 for cmd in vehicle.commands[2:5]: assert_not_equals(cmd, None) + assert_equals(cmd.seq, count) count += 1 - assert_equals(count, 3) + assert_equals(count, 6) # Home should be preserved assert_equals(home.lat, vehicle.home_location.lat) From e4201bb9aff6626b8d43440fc2689927f21224b5 Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Fri, 30 Oct 2015 15:29:44 -0700 Subject: [PATCH 07/13] Adds upload() command. --- dronekit/lib/__init__.py | 11 +++++++++++ tests/sitl/test_waypoints.py | 29 ++++++++++++++--------------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/dronekit/lib/__init__.py b/dronekit/lib/__init__.py index 0b0ac8202..20d54ee18 100644 --- a/dronekit/lib/__init__.py +++ b/dronekit/lib/__init__.py @@ -1077,6 +1077,17 @@ def add(self, cmd): self.__module.wploader.add(cmd, comment='Added by DroneKit') self.__module.vehicle.wpts_dirty = True + def upload(self): + """ + Call ``upload()`` after :py:func:`adding ` or :py:func:`clearing ` mission commands. + + After the return from ``upload()`` any writes are guaranteed to have completed (or thrown an + exception) and future reads will see their effects. + """ + if self.__module.vehicle.wpts_dirty: + self.__module.send_all_waypoints() + self.__module.vehicle.wpts_dirty = False + @property def count(self): ''' diff --git a/tests/sitl/test_waypoints.py b/tests/sitl/test_waypoints.py index 39b2e6737..06dbd0565 100644 --- a/tests/sitl/test_waypoints.py +++ b/tests/sitl/test_waypoints.py @@ -10,14 +10,13 @@ def test_empty_clear(connpath): # Calling clear() on an empty object should not crash. vehicle.commands.clear() - vehicle.flush() + vehicle.commands.upload() assert_equals(len(vehicle.commands), 0) @with_sitl def test_parameter(connpath): vehicle = connect(connpath, await_params=True) - cmds = vehicle.commands # Home should be None at first. assert_equals(vehicle.home_location, None) @@ -27,20 +26,20 @@ def test_parameter(connpath): time.sleep(10) # Initial - cmds.download() - cmds.wait_valid() - assert_equals(len(cmds), 0) + vehicle.commands.download() + vehicle.commands.wait_valid() + assert_equals(len(vehicle.commands), 0) assert_not_equals(vehicle.home_location, None) # Save home for comparison. home = vehicle.home_location # After clearing - cmds.clear() - vehicle.flush() - cmds.download() - cmds.wait_valid() - assert_equals(len(cmds), 0) + vehicle.commands.clear() + vehicle.commands.upload() + vehicle.commands.download() + vehicle.commands.wait_valid() + assert_equals(len(vehicle.commands), 0) # Upload for command in [ @@ -53,13 +52,13 @@ def test_parameter(connpath): Command(0, 0, 0, 3, 115, 0, 1, 2.0, 22.0, 1.0, 3.0, 0.0, 0.0, 0.0), Command(0, 0, 0, 3, 16, 0, 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), ]: - cmds.add(command) - vehicle.flush() + vehicle.commands.add(command) + vehicle.commands.upload() # After upload - cmds.download() - cmds.wait_valid() - assert_equals(len(cmds), 8) + vehicle.commands.download() + vehicle.commands.wait_valid() + assert_equals(len(vehicle.commands), 8) # Test iteration. count = 0 From e4b323428e9db49bf65a08ea9c29eeb8c69e482b Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 2 Nov 2015 16:17:38 +1100 Subject: [PATCH 08/13] Fix up mission examples now that home_location is not the first index. Update home_location in API Ref too --- docs/automodule.rst | 3 +- docs/examples/mission_basic.rst | 147 ++++++++---------- .../mission_basic_example_copter_path.png | Bin 0 -> 32804 bytes docs/examples/mission_import_export.rst | 111 +++++-------- docs/guide/auto_mode.rst | 105 +++++-------- docs/guide/migrating.rst | 14 ++ dronekit/lib/__init__.py | 25 +++ examples/mission_basic/mission_basic.py | 51 +++--- .../mission_import_export.py | 69 +++++--- examples/mission_import_export/mpmission.txt | 15 +- 10 files changed, 255 insertions(+), 285 deletions(-) create mode 100644 docs/examples/mission_basic_example_copter_path.png diff --git a/docs/automodule.rst b/docs/automodule.rst index 5a43bb22f..f79944102 100644 --- a/docs/automodule.rst +++ b/docs/automodule.rst @@ -8,7 +8,7 @@ DroneKit-Python API Reference .. automodule:: dronekit.lib :members: :inherited-members: - :exclude-members: Mission, get_mission, ConnectionInfo, web_connect, AuthInfo, delete, notify_observers, remove_all_observers, local_connect, APIConnection + :exclude-members: Mission, get_mission, ConnectionInfo, web_connect, AuthInfo, delete, notify_observers, remove_all_observers, local_connect, APIConnection, flush @@ -19,5 +19,4 @@ DroneKit-Python API Reference - .. todolist:: \ No newline at end of file diff --git a/docs/examples/mission_basic.rst b/docs/examples/mission_basic.rst index 874d11c49..8c3794ef2 100644 --- a/docs/examples/mission_basic.rst +++ b/docs/examples/mission_basic.rst @@ -12,13 +12,11 @@ command. The guide topic :ref:`auto_mode_vehicle_control` provides more detailed explanation of how the API should be used. -.. warning:: +.. figure:: mission_basic_example_copter_path.png + :width: 50 % + :alt: Basic Mission Path - At time of writing this example fails with an exception in DKYP2: `#355 DKPY2 Can't clear waypoints `_. - -.. todo:: - - Check if `#355 DKPY2 Can't clear waypoints `_ is fixed and re-review example. + Basic Mission Example: Flight path Running the example @@ -47,8 +45,8 @@ In summary, after cloning the repository: .. note:: - The command parameter above is the default, and may be omitted. This - connects to SITL on udp port 127.0.0.1:14550. + The ``--connect`` parameter above specifies the default value, and may be omitted. + This connects to SITL on udp port 127.0.0.1:14550. .. tip:: @@ -64,69 +62,66 @@ On the command prompt you should see (something like): Connecting to vehicle on: 127.0.0.1:14550 >>> APM:Copter V3.4-dev (e0810c2e) >>> Frame: QUAD - Clear the current mission - - Requesting 0 waypoints t=Wed Jul 29 21:27:58 2015 now=Wed Jul 29 21:27:58 2015 Create a new mission - Got MAVLink msg: MISSION_ACK {target_system : 255, target_component : 0, type : 0} - Sent waypoint 0 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 0, frame : 0, command : 16, current : 0, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : -35.3632621765, y : 149.165237427, z : 584.0} - Sent waypoint 1 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 1, frame : 3, command : 22, current : 0, autocontinue : 0, param1 : 0, param2 : 0, param3 : 0, param4 : 0, x : 0, y : 0, z : 10} - Sent waypoint 2 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 2, frame : 3, command : 16, current : 0, autocontinue : 0, param1 : 0, param2 : 0, param3 : 0, param4 : 0, x : -35.3628118424, y : 149.164679124, z : 11} - Sent waypoint 3 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 3, frame : 3, command : 16, current : 0, autocontinue : 0, param1 : 0, param2 : 0, param3 : 0, param4 : 0, x : -35.3628118424, y : 149.165780676, z : 12} - Sent waypoint 4 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 4, frame : 3, command : 16, current : 0, autocontinue : 0, param1 : 0, param2 : 0, param3 : 0, param4 : 0, x : -35.3637101576, y : 149.165780676, z : 13} - Sent waypoint 5 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 5, frame : 3, command : 16, current : 0, autocontinue : 0, param1 : 0, param2 : 0, param3 : 0, param4 : 0, x : -35.3637101576, y : 149.164679124, z : 14} - Sent all 6 waypoints - Got MAVLink msg: MISSION_ACK {target_system : 255, target_component : 0, type : 0} - APM: flight plan received + Clear any existing commands + Define/add new commands. + Upload new commands to vehicle Basic pre-arm checks + MODE: STABILIZE Arming motors Waiting for arming... - Got MAVLink msg: COMMAND_ACK {command : 11, result : 0} + >>> flight plan received Waiting for arming... - APM: ARMING MOTORS - APM: GROUND START Waiting for arming... - GUIDED> Mode GUIDED - APM: Initialising APM... - Got MAVLink msg: COMMAND_ACK {command : 400, result : 0} + >>> ARMING MOTORS + >>> GROUND START Waiting for arming... - ARMED + Waiting for arming... + >>> Initialising APM... Taking off! Altitude: 0.0 - Got MAVLink msg: COMMAND_ACK {command : 22, result : 0} - GPS lock at 0 meters - Altitude: 0.10000000149 + Altitude: 0.170000001788 + Altitude: 1.37000000477 ... - Altitude: 8.84000015259 - Altitude: 9.60999965668 + Altitude: 8.98999977112 + Altitude: 9.64000034332 Reached target altitude Starting mission - Got MAVLink msg: COMMAND_ACK {command : 11, result : 0} - waypoint 1 - waypoint 2 - AUTO> Mode AUTO - Distance to waypoint (2): 79.3138466142 - Distance to waypoint (2): 79.1869592549 - Distance to waypoint (2): 77.8436803794 + Distance to waypoint (0): None + Distance to waypoint (1): 78.8589586333 + Distance to waypoint (1): 78.4539918222 + ... + Distance to waypoint (1): 21.1854880899 + Distance to waypoint (1): 15.9962142785 + >>> Reached Command #1 + Distance to waypoint (2): 114.244008966 + Distance to waypoint (2): 117.552371221 + Distance to waypoint (2): 120.961820592 + ... + Distance to waypoint (2): 25.2782487833 + Distance to waypoint (2): 19.3676312264 + >>> Reached Command #2 + Distance to waypoint (3): 101.094964838 + Skipping to Waypoint 5 when reach waypoint 3 + Distance to waypoint (3): 100.297254801 + Skipping to Waypoint 5 when reach waypoint 3 ... - Distance to waypoint (2): 20.7677087176 - Distance to waypoint (2): 15.4592692026 - APM: Reached Command #2 - waypoint 3 - Distance to waypoint (3): 115.328425048 - Skipping to Waypoint 4 when reach waypoint 3 - waypoint 4 - Distance to waypoint (4): 152.376018911 - Distance to waypoint (4): 154.882233097 + Distance to waypoint (3): 19.3298648648 + Skipping to Waypoint 5 when reach waypoint 3 + Distance to waypoint (3): 14.5179746603 + Skipping to Waypoint 5 when reach waypoint 3 + >>> Reached Command #3 + Distance to waypoint (4): 123.867292399 + Distance to waypoint (4): 123.019536579 + Distance to waypoint (4): 121.278259418 ... - Distance to waypoint (4): 20.4052797291 - Distance to waypoint (4): 15.0592597507 - APM: Reached Command #4 - waypoint 5 - Distance to waypoint (5): 114.450267446 + Distance to waypoint (4): 27.7386666676 + Distance to waypoint (4): 20.3805334778 + >>> Reached Command #4 + Distance to waypoint (5): 14.5141106814 Exit 'standard' mission when start heading to final waypoint (5) Return to launch - APIThread-0 exiting... + Close vehicle object @@ -136,9 +131,11 @@ How does it work? The :ref:`source code ` is relatively self-documenting, and most of its main operations are explained in the guide topic :ref:`auto_mode_vehicle_control` . -In overview, the example first calls ``clear_mission()`` to clear the current mission and then creates and -uploads a new mission using ``adds_square_mission(vehicle.location.global_frame,50)``. This function defines a mission with a takeoff -command and four waypoints arranged in a square around the central position. +In overview, the example calls ``adds_square_mission(vehicle.location.global_frame,50)`` to first +clear the current mission and then define a new mission with a takeoff command and four waypoints arranged +in a square around the central position (two waypoints are added in the last position - +we use :py:func:`next ` to determine when we've reached the final point). +The clear command and new mission items are then uploaded to the vehicle. After taking off (in guided mode using the ``takeoff()`` function) the example starts the mission by setting the mode to AUTO: @@ -160,18 +157,19 @@ We also show how to move to a specified command using .. code:: python while True: - nextwaypoint =vehicle.commands.next - if nextwaypoint > 1: - print 'Distance to waypoint (%s): %s' % (nextwaypoint, distance_to_current_waypoint()) - if nextwaypoint ==3: #Skip to next waypoint - print 'Skipping to Waypoint 4 when reach waypoint 3' - vehicle.commands.next=4 - if nextwaypoint ==5: #Skip to next waypoint + nextwaypoint=vehicle.commands.next + print 'Distance to waypoint (%s): %s' % (nextwaypoint, distance_to_current_waypoint()) + + if nextwaypoint==3: #Skip to next waypoint + print 'Skipping to Waypoint 5 when reach waypoint 3' + vehicle.commands.next=5 + vehicle.commands.upload() + if nextwaypoint==5: #Dummy waypoint - as soon as we reach waypoint 4 this is true and we exit. print "Exit 'standard' mission when start heading to final waypoint (5)" break; time.sleep(1) -When the vehicle starts the 5th command the loop breaks and the mode is set to RTL (return to launch). +When the vehicle starts the 5th command (a dummy waypoint) the loop breaks and the mode is set to RTL (return to launch). .. _example_mission_basic_known_issues: @@ -179,21 +177,10 @@ When the vehicle starts the 5th command the loop breaks and the mode is set to R Known issues ============ -This example fails in DroneKit 2.0.0b6 and earlier releases (see `#355 DKPY2 Can't clear waypoints `_ to see if it has been fixed in the current release). - - -.. todo:: - - This is blocked by https://github.com/dronekit/dronekit-python/issues/355 (vehicle.commands.clear not working). - The code output in "running the example needs to be updated once this runs cleanly. - The above text for the error needs to be replaced with original text: - - > "This example works around the :ref:`known issues in the API `. - > Provided that the vehicle is connected and able to arm, it should run through to completion." - - Need to check all that clearing is still strictly necessary in DKPY2 which handles race conditions more gracefully. - Add image of waypoints /flight for top of page. +This example has the following issues: +* :py:func:`next ` does not appear to be writable, so the example does not skip steps as documented. + This is tracked as `#390 <#https://github.com/dronekit/dronekit-python/issues/390>`_. .. _example_mission_basic_source_code: diff --git a/docs/examples/mission_basic_example_copter_path.png b/docs/examples/mission_basic_example_copter_path.png new file mode 100644 index 0000000000000000000000000000000000000000..d858dd02859297d902a62bfab77567ad9e719e54 GIT binary patch literal 32804 zcmZsDWmHt(+x8HWA`ME1gfNsy2}8)xAl*Y6gp?pPQi8OIf($7!bc1xK0wOWAbTf1~ zi1d3#|G($cyA~|g%sFSDz3;g89oHsO=dlVI2?GfT1R_&Yh3bJoIDdfOVIo}Mo6eej z58w}uhn~tKP}v~UCh!5@PC-in1geZBy|B3fd?t2NH3e>>dWHSPnSaje0|Es$s6iDB zd@OfA6T)chrrV9%t-lv~Cu%fkxMP2sV1lP{O`oJmO-3F>Mz$!&+m}SJRcMq4N3lgA zrwZxhX$<6Pbc%vsDag~%R6fzrgtXcH4z=;At9bU@+w0`;dacqUM9G-zU%C)VTBS#t3x` z#XCjS#|`HE29cKbf8Y2h{z=&VFY?uyXvzV5hlh$ax5;dvZ4&qXcNsbPhv?#e&xa+& zqg{N8{B*m}M#n%mufRd}|{6_B&p)GCHBGYRw za)_V&RDJ_Yn(j7=Gf&C9|4xwO13HPLo=r};3F2P!$MWwVu)`oi;av=xm@zL(C@qqz zB|R4dieL#~!ZXJ%n2s0TT}_dQ=I1!3_g|in|KGP;N(&QuftP2r>faxM%(KK}*or6; z(8u81g%-yTrOsCW-R6M_qwz0K45fT)EgmWn?)C1AfA93c-?!dC*BE!{>CxfRK#)@F z>}M^g{gbL^U^$zyh0Spi@~HVQ6p?70W3{{ZHk8_11R&J5j!%`q7z+*gbzZ;`uA#c? zZ9oKsQ7j??P)~?aIElu@k?i~HWg`;?Dw>wBsA3zeX!2Yr$S4!gHKi4+X6e;IXtL{- zOtipzOHx-}tl%v0bweVc?ml& zJe8O%YJOQKLsS99$EiqxJIQc3 zstbHENW&rC9iL4ok8vb%MFxizRLTS)Rc_+{U4fxbc3vmdYT5izkS-rs7lVj6+pYw0 zJ$r-pl%ROa#)m2{s(30ut^g5>#)Y~rvJxt}Mgpc2uLwmN8`<=k1(+8=#55?mkrGa! zTv78>x~?Wk|1+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FeVl5lHu`9WE{l@n7bNjeazbHyS&kgh=1t=KUw?3X|03>!;BQEQxw@P|^uScq z!JgN^zRgZRWvmsr9Rj&cHfumU0_;V_+K^iz_<-m6dXg=f@Ahjko zGOL}K4%~i^jXX>M-a;Mz7Q)zKy1)|#?4oEsXkS2bX1cqCm}ou_kP%fFyX^``=2YU} z|NMdqnC?+9^VD~LOIbo>y~_xSEbRQc4<1TF7RDyU2F6419%vNU2Jk}?DE8np7*}xC z8mM>)6;Hs2JTUgfU8nhwqX~hh1X;8}M$&}&cP*dcAnF;TCP7vsAEKZZ>H>jHjod=7^b9zm7P67Uy&>;fN%!q{Jo zL1#wYrGtfkqy$gRhIv;h8*s?O0fO*)Le(f-xq%K9eErL7rGG7P1JC$ySJBlA0O!4H z1#(atoPlvyf)JosMP@v@YjpCvFZU6{bB`VW?RxAs#lQW6gZ!^w{->1x`~-H_eP9IH z3IG%t=w7_LhGaukX0ZOZF0y~6!m}^I`yGgR|X+$KN9LLf`|kkJa_xxCN;mK-KG5cjL5=bq`LC z0(C6@XB{2&|LOo_8u-Zj`yO8ZdI#rU$NMAvt7Gf_T^-B+3VRM1Jm5)%I&eHR|J)++ XFnjxXb*%&`_. -.. warning:: - - At time of writing this example fails with an exception in DKYP2: `#355 DKPY2 Can't clear waypoints `_. - -.. todo:: - - Check if `#355 DKPY2 Can't clear waypoints `_ is fixed and re-review example. - The commands are first imported from a file into a list and then uploaded to the vehicle. -Then the current mission is downloaded from the vehicle and put into a list, and finally -saved into (another file). +Then the current mission is downloaded from the vehicle and put into a list, which is then +saved into (another file). Finally, we print out both the original and new files +for comparison The example does not show how missions can be modified, but once the mission is in a list, changing the order and content of commands is straightforward. @@ -32,9 +25,6 @@ Running the example The example can be run as described in :doc:`running_examples` (which in turn assumes that the vehicle and DroneKit have been set up as described in :ref:`get-started`). -If you're using a simulated vehicle, remember to :ref:`disable arming checks ` so -that the example can run. - In summary, after cloning the repository: #. Navigate to the example folder as shown: @@ -53,10 +43,9 @@ In summary, after cloning the repository: .. note:: - The command parameter above is the default, and may be omitted. This - connects to SITL on udp port 127.0.0.1:14550. + The ``--connect`` parameter above specifies the default value, and may be omitted. + This connects to SITL on udp port 127.0.0.1:14550. - On the command prompt you should see (something like): @@ -64,51 +53,42 @@ On the command prompt you should see (something like): .. code:: bash Connecting to vehicle on: 127.0.0.1:14550 - >>> APM:Copter V3.4-dev (e0810c2e) + >>> APM:Copter V3.3 (d6053245) >>> Frame: QUAD - Link timeout, no heartbeat in last 5 seconds - Upload mission from a file: mpmission.txt Reading mission from file: mpmission.txt - STABILIZE> Import line: 0 1 0 16 0 0 0 0 -35.360500 149.172363 747.000000 1 - - Import line: 1 0 3 22 0.000000 0.000000 0.000000 0.000000 -35.359831 149.166334 100.000000 1 - - - Import line: 2 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.363489 149.167213 100.000000 1 - - Import line: 3 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.355491 149.169595 100.000000 1 - - Import line: 4 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.355071 149.175839 100.000000 1 - - Import line: 5 0 3 113 0.000000 0.000000 0.000000 0.000000 -35.362666 149.178715 22222.000000 1 - Import line: 6 0 3 115 2.000000 22.000000 1.000000 3.000000 0.000000 0.000000 0.000000 1 - - Import line: 7 0 3 16 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1 - - Clear mission - Requesting 9 waypoints t=Wed Jul 29 20:12:17 2015 now=Wed Jul 29 20:12:17 2015 - ClearCount: 0 - Got MAVLink msg: MISSION_ACK {target_system : 255, target_component : 0, type : 0} - Requesting 0 waypoints t=Wed Jul 29 20:12:17 2015 now=Wed Jul 29 20:12:17 2015 - Got MAVLink msg: MISSION_ACK {target_system : 255, target_component : 0, type : 0} - Sent waypoint 0 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 0, frame : 0, command : 16, current : 0, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : -35.3632621765, y : 149.165237427, z : 584.0} - Sent waypoint 1 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 1, frame : 0, command : 16, current : 1, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : -35.3605, y : 149.172363, z : 747.0} - Sent waypoint 2 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 2, frame : 3, command : 22, current : 0, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : -35.359831, y : 149.166334, z : 100.0} - Sent waypoint 3 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 3, frame : 3, command : 16, current : 0, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : -35.363489, y : 149.167213, z : 100.0} - Sent waypoint 4 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 4, frame : 3, command : 16, current : 0, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : -35.355491, y : 149.169595, z : 100.0} - Sent waypoint 5 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 5, frame : 3, command : 16, current : 0, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : -35.355071, y : 149.175839, z : 100.0} - Sent waypoint 6 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 6, frame : 3, command : 113, current : 0, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : -35.362666, y : 149.178715, z : 22222.0} - Sent waypoint 7 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 7, frame : 3, command : 115, current : 0, autocontinue : 1, param1 : 2.0, param2 : 22.0, param3 : 1.0, param4 : 3.0, x : 0.0, y : 0.0, z : 0.0} - Sent waypoint 8 : MISSION_ITEM {target_system : 1, target_component : 0, seq : 8, frame : 3, command : 16, current : 0, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : 0.0,y : 0.0, z : 0.0} - Sent all 9 waypoints - Got MAVLink msg: MISSION_ACK {target_system : 255, target_component : 0, type : 0} - APM: flight plan received + Upload mission from a file: mpmission.txt + Clear mission + Upload mission Save mission from Vehicle to file: exportedmission.txt - Requesting 9 waypoints t=Wed Jul 29 20:12:18 2015 now=Wed Jul 29 20:12:18 2015 - APIThread-1 exiting... + Download mission from vehicle + >>> flight plan received + Write mission to file + Close vehicle object + + Show original and uploaded/downloaded files: + + Mission file: mpmission.txt + QGC WPL 110 + 0 1 0 16 0 0 0 0 -35.363262 149.165237 584.000000 1 + 1 0 0 22 0.000000 0.000000 0.000000 0.000000 -35.361988 149.163753 100.000000 1 + 2 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.361992 149.163593 100.000000 1 + 3 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.363812 149.163609 100.000000 1 + 4 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.363768 149.166055 100.000000 1 + 5 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.361835 149.166012 100.000000 1 + 6 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.362150 149.165046 100.000000 1 + + Mission file: exportedmission.txt + QGC WPL 110 + 0 1 0 16 0 0 0 0 0.0 0.0 0.0 1 + 1 0 0 22 0.0 0.0 0.0 0.0 -35.3619880676 149.163757324 100.0 1 + 2 0 0 16 0.0 0.0 0.0 0.0 -35.3619918823 149.163589478 100.0 1 + 3 0 0 16 0.0 0.0 0.0 0.0 -35.3638114929 149.163604736 100.0 1 + 4 0 0 16 0.0 0.0 0.0 0.0 -35.3637695312 149.166061401 100.0 1 + 5 0 0 16 0.0 0.0 0.0 0.0 -35.3618354797 149.166015625 100.0 1 + 6 0 0 16 0.0 0.0 0.0 0.0 -35.3621482849 149.165039062 100.0 1 @@ -125,26 +105,7 @@ More information about the functions can be found in the guide at Known issues ============ -* This example fails in DroneKit 2.0.0b6 and earlier - (see `#355 DKPY2 Can't clear waypoints `_ to see if it has been fixed). -* A ``time.sleep(1)`` has been placed between uploading the mission to the vehicle (from the file) and downloading the mission. - This is to avoid the race condition where the mission being downloaded has not yet successfully uploaded to the vehicle. - This race condition (probably) shouldn't exist because the mission is flushed to the Vehicle - - see `Race condition when updating and fetching commands `_ - - - -.. todo:: - - This is blocked by https://github.com/dronekit/dronekit-python/issues/355 (vehicle.commands.clear not working). - The code output in "running the example"" needs to be updated once this runs cleanly. - The above text for the error needs to be replaced with original text - - > "This example works around known issues in the API:." - - Need to check all that clearing is still strictly necessary in DKPY2 which handles race conditions more gracefully. - - +There are no known issues with this example. diff --git a/docs/guide/auto_mode.rst b/docs/guide/auto_mode.rst index 6cbeb4426..f5dbe7fee 100644 --- a/docs/guide/auto_mode.rst +++ b/docs/guide/auto_mode.rst @@ -80,13 +80,9 @@ use :py:func:`wait_valid() ` to block y .. note:: - The commands downloaded from the vehicle will include a waypoint for the :ref:`home location ` in the first position (0 index). - This waypoint is not editable - it cannot be removed or modified. + In DroneKit-Python 2 :py:attr:`Vehicle.commands ` contains just the editable waypoints (in version 1.x, the + commands included the non-editable home location as the first item). -.. todo:: - - The information about home location will change with - `#207 WIP:Adds separate .home_location from .commands array `_. .. _auto_mode_clear_mission: @@ -95,33 +91,25 @@ Clearing current mission ======================== To clear a mission you call :py:func:`clear() ` and then -:py:func:`flush() ` (to upload the changes to the vehicle): +:py:func:`Vehicle.commands.upload() ` (to upload the changes to the vehicle): .. code:: python # Connect to the Vehicle (in this case a simulated vehicle at 127.0.0.1:14550) vehicle = connect('127.0.0.1:14550', await_params=True) - # Get commands from Vehicle object. + # Get commands object from Vehicle. cmds = vehicle.commands - # Clear Vehicle.commands and flush. + # Call clear() on Vehicle.commands and upload the command to the vehicle. cmds.clear() - vehicle.flush() - - # Reset the Vehicle.commands from the vehicle. - cmds.download() - cmds.wait_valid() - -.. warning:: + cmds.upload() - You must re-download the mission from the vehicle after clearing (as shown above) or the first command you add - will be lost when you upload the new mission. +.. note:: - This happens because :py:attr:`Vehicle.commands ` removes the :ref:`home location ` - (see `#132 `_). Downloading adds it back again. + If a mission that is underway is cleared, the mission will continue to the next waypoint. If you don't add a new command + before the waypoint is reached then the vehicle mode will change to RTL (return to launch) mode. -If the current command completes before you add a new mission, then the vehicle mode will change to RTL (return to launch). .. _auto_mode_adding_command: @@ -131,7 +119,7 @@ Creating/adding mission commands After :ref:`downloading ` or :ref:`clearing ` a mission new commands can be added and uploaded to the vehicle. Commands are added to the mission using :py:func:`add() ` -and are sent to the vehicle (either individually or in batches) using :py:func:`flush() `. +and are sent to the vehicle (either individually or in batches) using :py:func:`upload() `. Each command is packaged in a :py:class:`Command ` object (see that class for the order/meaning of the parameters). The supported commands for each vehicle are :ref:`linked above `. @@ -152,7 +140,7 @@ The supported commands for each vehicle are :ref:`linked above ` after :ref:`downloading a mission ` it is not possible to directly modify and upload existing commands in ``Vehicle.commands`` (you can modify the commands but -changes do not propagate to the vehicle). +changes do not propagate to the vehicle). + +.. todo:: test above statement. Might not be true in DKPY2. Also check if we can flush items in a cycle. Instead you copy all the commands into another container (e.g. a list), modify them as needed, then clear ``Vehicle.commands`` and upload the list as a new mission: @@ -180,27 +170,24 @@ modify them as needed, then clear ``Vehicle.commands`` and upload the list as a # Save the vehicle commands to a list missionlist=[] - for cmd in cmds[1:]: #skip first item as it is home waypoint. + for cmd in cmds: missionlist.append(cmd) # Modify the mission as needed. For example, here we change the # first waypoint into a MAV_CMD_NAV_TAKEOFF command. missionlist[0].command=mavutil.mavlink.MAV_CMD_NAV_TAKEOFF - # Clear the current mission + # Clear the current mission (command is sent when we call upload()) cmds.clear() - vehicle.flush() - cmds.download() - cmds.wait_valid() #Write the modified mission and flush to the vehicle for cmd in missionlist: cmds.add(cmd) - vehicle.flush() + cmds.upload() The changes are not guaranteed to be complete until -:py:func:`flush() ` is called on the parent ``Vehicle`` object. +:py:func:`upload() ` is called on the parent ``Vehicle.commands`` object. .. _auto_mode_monitoring_controlling: @@ -208,7 +195,7 @@ The changes are not guaranteed to be complete until Running and monitoring missions =============================== -To start a mission change the mode to AUTO: +To start a mission, change the mode to AUTO: .. code:: python @@ -242,8 +229,8 @@ to get the current command number. You can also change the current command by se vehicle.commands.next=4 print "Current Waypoint: %s" % vehicle.commands.next -There is no need to ``flush()`` changes to ``next`` to the vehicle (and as with other attributes, if you fetch a value, it is updated -from the vehicle). +There is no need to ``upload()`` changes to send an update to the ``next`` attribute to the vehicle +(and as with other attributes, if you fetch a value, it is updated from the vehicle). .. _auto_mode_handle_mission_end: @@ -260,7 +247,7 @@ to perform some other operation) then you can either: * Add a dummy mission command and poll :py:func:`Vehicle.commands.next ` for the transition to the final command, or -* Compare the current position to the position in the last command. +* Compare the current position to the target position in the final waypoint. @@ -287,24 +274,22 @@ Adding mission commands is discussed :ref:`here in the guide ` objects. @@ -331,7 +316,6 @@ The commands are added to a list which is returned by the function. if not line.startswith('QGC WPL 110'): raise Exception('File is not supported WP version') else: - print ' Import line: %s' % line linearray=line.split('\t') ln_index=int(linearray[0]) ln_currentwp=int(linearray[1]) @@ -410,9 +394,9 @@ Get distance to waypoint It returns None for the first waypoint (Home location). """ nextwaypoint=vehicle.commands.next - if nextwaypoint==1: + if nextwaypoint ==0: return None - missionitem=vehicle.commands[nextwaypoint] + missionitem=vehicle.commands[nextwaypoint-1] #commands are zero indexed lat=missionitem.x lon=missionitem.y alt=missionitem.z @@ -425,8 +409,6 @@ and uses it to index the commands to get the latitude, longitude and altitude of (see :ref:`guided_mode_copter_useful_conversion_functions`) is then used to calculate and return the (horizontal) distance from the current vehicle location. -The implementation ignores the first waypoint (which will be the "home location"). - .. tip:: This implementation is very basic. It assumes that the next command number is for a valid NAV command (it might not be) @@ -449,9 +431,4 @@ Known Issues AUTO Mode/mission control has the following known issues (at time of writing): -* `#230 vehicle.commands must be reset after clearing `_ -* `#132 Vehicle.commands is throwing away the first command sent `_ -* `#252 Expose home location as separate from .commands array `_ -* `#207 WIP:Adds separate .home_location from .commands array `_ -* `#105 Implement Vehicle.waypoint_home `_ -* `#227 Race condition when updating and fetching commands `_ \ No newline at end of file +* `#390 Vehicle.commands.next is not writeable <#https://github.com/dronekit/dronekit-python/issues/390>`_. \ No newline at end of file diff --git a/docs/guide/migrating.rst b/docs/guide/migrating.rst index cd3724ccd..14dbfd621 100644 --- a/docs/guide/migrating.rst +++ b/docs/guide/migrating.rst @@ -161,3 +161,17 @@ Instead, use normal Python methods for getting file system information: full_directory_path_of_current_script = os.path.dirname(os.path.abspath(__file__)) +Home location +------------- + +DroneKit-Python 1.x code retrieved the home location from the first element in :py:attr:`Vehicle.commands `. +This code must be replaced with the DroneKit-Python 2.x :py:attr:`Vehicle.home_location ` attribute. + +.. tip:: + + Even though the home location is no longer returned as the first waypoint in :py:attr:`Vehicle.commands `, + you will still need to download the commands in order to populate the value of + :py:attr:`Vehicle.home_location `. + + + diff --git a/dronekit/lib/__init__.py b/dronekit/lib/__init__.py index 20d54ee18..f2481f5dd 100644 --- a/dronekit/lib/__init__.py +++ b/dronekit/lib/__init__.py @@ -572,6 +572,8 @@ def flush(self): After the return from ``flush()`` any writes are guaranteed to have completed (or thrown an exception) and future reads will see their effects. + + .. deprecated: In 2.x. """ if self.wpts_dirty: self.__module.send_all_waypoints() @@ -690,6 +692,29 @@ def channel_readback(self): @property def home_location(self): + """ + The current home location in a :py:class:`LocationGlobal`. This value is typically the + GPS location of the vehicle at the point it is armed. + + .. code-block:: python + + #Connect to a vehicle object (for example, on com14) + vehicle = connect('com14', await_params=True) + + # Download the vehicle waypoints (commands). Wait until download is complete. + cmds = vehicle.commands + cmds.download() + cmds.wait_valid() + + # Get the home location + home = vehicle.home_location + + .. warning:: + + The home location will have a value of ``None`` until :py:func:`Vehicle.commands` has been + downloaded. If no home position has been set the returned location will have + zero values for its member attributes. + """ loc = self.__module.wploader.wp(0) if loc: return LocationGlobal(loc.x, loc.y, loc.z, is_relative=False) diff --git a/examples/mission_basic/mission_basic.py b/examples/mission_basic/mission_basic.py index 56a4ad2f3..835e890e7 100644 --- a/examples/mission_basic/mission_basic.py +++ b/examples/mission_basic/mission_basic.py @@ -67,31 +67,15 @@ def distance_to_current_waypoint(): It returns None for the first waypoint (Home location). """ nextwaypoint=vehicle.commands.next - if nextwaypoint ==1: + if nextwaypoint ==0: return None - missionitem=vehicle.commands[nextwaypoint] + missionitem=vehicle.commands[nextwaypoint-1] #commands are zero indexed lat=missionitem.x lon=missionitem.y alt=missionitem.z targetWaypointLocation=LocationGlobal(lat,lon,alt,is_relative=True) distancetopoint = get_distance_metres(vehicle.location.global_frame, targetWaypointLocation) return distancetopoint - - -def clear_mission(): - """ - Clear the current mission. - """ - cmds = vehicle.commands - vehicle.commands.clear() - vehicle.flush() - - # After clearing the mission you MUST re-download the mission from the vehicle - # before vehicle.commands can be used again - # (see https://github.com/dronekit/dronekit-python/issues/230) - cmds = vehicle.commands - cmds.download() - cmds.wait_valid() def download_mission(): @@ -112,8 +96,15 @@ def adds_square_mission(aLocation, aSize): The function assumes vehicle.commands matches the vehicle mission state (you must have called download at least once in the session and after clearing the mission) """ - # Add the commands. The meaning/order of the parameters is documented in the Command class. + cmds = vehicle.commands + + print " Clear any existing commands" + cmds.clear() + + print " Define/add new commands." + # Add new commands. The meaning/order of the parameters is documented in the Command class. + #Add MAV_CMD_NAV_TAKEOFF command. This is ignored if the vehicle is already in the air. cmds.add(Command( 0, 0, 0, mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT, mavutil.mavlink.MAV_CMD_NAV_TAKEOFF, 0, 0, 0, 0, 0, 0, 0, 0, 10)) @@ -126,9 +117,11 @@ def adds_square_mission(aLocation, aSize): cmds.add(Command( 0, 0, 0, mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT, mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 0, 0, 0, 0, 0, 0, point2.lat, point2.lon, 12)) cmds.add(Command( 0, 0, 0, mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT, mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 0, 0, 0, 0, 0, 0, point3.lat, point3.lon, 13)) cmds.add(Command( 0, 0, 0, mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT, mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 0, 0, 0, 0, 0, 0, point4.lat, point4.lon, 14)) + #add dummy waypoint "5" at point 4 (lets us know when have reached destination) + cmds.add(Command( 0, 0, 0, mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT, mavutil.mavlink.MAV_CMD_NAV_WAYPOINT, 0, 0, 0, 0, 0, 0, point4.lat, point4.lon, 14)) - # Send commands to vehicle. - vehicle.flush() + print " Upload new commands to vehicle" + cmds.upload() def arm_and_takeoff(aTargetAltitude): @@ -169,13 +162,8 @@ def arm_and_takeoff(aTargetAltitude): time.sleep(1) - -print 'Clear the current mission' -clear_mission() - print 'Create a new mission' adds_square_mission(vehicle.location.global_frame,50) -time.sleep(2) # This is here so that mission being sent is displayed on console # From Copter 3.3 you will be able to take off using a mission item. Plane must take off using a mission item (currently). @@ -190,15 +178,14 @@ def arm_and_takeoff(aTargetAltitude): # Demonstrates getting and setting the command number # Uses distance_to_current_waypoint(), a convenience function for finding the # distance to the next waypoint. - while True: nextwaypoint=vehicle.commands.next - if nextwaypoint > 1: - print 'Distance to waypoint (%s): %s' % (nextwaypoint, distance_to_current_waypoint()) + print 'Distance to waypoint (%s): %s' % (nextwaypoint, distance_to_current_waypoint()) + if nextwaypoint==3: #Skip to next waypoint - print 'Skipping to Waypoint 4 when reach waypoint 3' - vehicle.commands.next=4 - if nextwaypoint==5: #Skip to next waypoint + print 'Skipping to Waypoint 5 when reach waypoint 3' + vehicle.commands.next=5 + if nextwaypoint==5: #Dummy waypoint - as soon as we reach waypoint 4 this is true and we exit. print "Exit 'standard' mission when start heading to final waypoint (5)" break; time.sleep(1) diff --git a/examples/mission_import_export/mission_import_export.py b/examples/mission_import_export/mission_import_export.py index dd22fe2cc..ce150c60f 100644 --- a/examples/mission_import_export/mission_import_export.py +++ b/examples/mission_import_export/mission_import_export.py @@ -10,10 +10,7 @@ from dronekit import connect -import time -import math from dronekit.lib import Command -from pymavlink import mavutil #Set up option parsing to get connection string @@ -24,7 +21,7 @@ args = parser.parse_args() -# Connect to the Vehicle +#Connect to the Vehicle print 'Connecting to vehicle on: %s' % args.connect vehicle = connect(args.connect, await_params=True) @@ -36,7 +33,7 @@ def readmission(aFileName): This function is used by upload_mission(). """ - print "Reading mission from file: %s\n" % aFileName + print "\nReading mission from file: %s" % aFileName cmds = vehicle.commands missionlist=[] with open(aFileName) as f: @@ -45,7 +42,6 @@ def readmission(aFileName): if not line.startswith('QGC WPL 110'): raise Exception('File is not supported WP version') else: - print ' Import line: %s' % line linearray=line.split('\t') ln_index=int(linearray[0]) ln_currentwp=int(linearray[1]) @@ -68,21 +64,19 @@ def upload_mission(aFileName): """ Upload a mission from a file. """ + #Read mission from file missionlist = readmission(aFileName) - #clear existing mission - print 'Clear mission' + + print "\nUpload mission from a file: %s" % import_mission_filename + #Clear existing mission from vehicle + print ' Clear mission' cmds = vehicle.commands - cmds.download() - cmds.wait_valid() cmds.clear() - vehicle.flush() - print 'ClearCount: %s' % cmds.count - #add new mission - cmds.download() - cmds.wait_valid() + #Add new mission to vehicle for command in missionlist: cmds.add(command) - vehicle.flush() + print ' Upload mission' + vehicle.commands.upload() def download_mission(): @@ -90,38 +84,65 @@ def download_mission(): Downloads the current mission and returns it in a list. It is used in save_mission() to get the file information to save. """ + print " Download mission from vehicle" missionlist=[] cmds = vehicle.commands cmds.download() cmds.wait_valid() - for cmd in cmds[1:]: #skip first item as it is home waypoint. + for cmd in cmds: missionlist.append(cmd) return missionlist def save_mission(aFileName): """ - Save a mission in the Waypoint file format (http://qgroundcontrol.org/mavlink/waypoint_protocol#waypoint_file_format). + Save a mission in the Waypoint file format + (http://qgroundcontrol.org/mavlink/waypoint_protocol#waypoint_file_format). """ + print "\nSave mission from Vehicle to file: %s" % export_mission_filename + #Download mission from vehicle missionlist = download_mission() + #Add file-format information output='QGC WPL 110\n' + #Add home location as 0th waypoint + home = vehicle.home_location + output+="%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (0,1,0,16,0,0,0,0,home.lat,home.lon,home.alt,1) + #Add commands for cmd in missionlist: commandline="%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (cmd.seq,cmd.current,cmd.frame,cmd.command,cmd.param1,cmd.param2,cmd.param3,cmd.param4,cmd.x,cmd.y,cmd.z,cmd.autocontinue) output+=commandline with open(aFileName, 'w') as file_: - file_.write(output) + print " Write mission to file" + file_.write(output) + + +def printfile(aFileName): + """ + Print a mission file to demonstrate "round trip" + """ + print "\nMission file: %s" % aFileName + with open(aFileName) as f: + for line in f: + print ' %s' % line.strip() import_mission_filename = 'mpmission.txt' export_mission_filename = 'exportedmission.txt' -print "\nUpload mission from a file: %s" % import_mission_filename +#Upload mission from file upload_mission(import_mission_filename) -time.sleep(1) - -print "\nSave mission from Vehicle to file: %s" % export_mission_filename +#Download mission we just uploaded and save to a file save_mission(export_mission_filename) #Close vehicle object before exiting script print "Close vehicle object" -vehicle.close() \ No newline at end of file +vehicle.close() + + + +print "\nShow original and uploaded/downloaded files:" +#Print original file (for demo purposes only) +printfile(import_mission_filename) +#Print exported file (for demo purposes only) +printfile(export_mission_filename) + diff --git a/examples/mission_import_export/mpmission.txt b/examples/mission_import_export/mpmission.txt index bd331abdd..2ca281d09 100644 --- a/examples/mission_import_export/mpmission.txt +++ b/examples/mission_import_export/mpmission.txt @@ -1,9 +1,8 @@ QGC WPL 110 -0 1 0 16 0 0 0 0 -35.360500 149.172363 747.000000 1 -1 0 3 22 0.000000 0.000000 0.000000 0.000000 -35.359831 149.166334 100.000000 1 -2 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.363489 149.167213 100.000000 1 -3 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.355491 149.169595 100.000000 1 -4 0 3 16 0.000000 0.000000 0.000000 0.000000 -35.355071 149.175839 100.000000 1 -5 0 3 113 0.000000 0.000000 0.000000 0.000000 -35.362666 149.178715 22222.000000 1 -6 0 3 115 2.000000 22.000000 1.000000 3.000000 0.000000 0.000000 0.000000 1 -7 0 3 16 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1 +0 1 0 16 0 0 0 0 -35.363262 149.165237 584.000000 1 +1 0 0 22 0.000000 0.000000 0.000000 0.000000 -35.361988 149.163753 100.000000 1 +2 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.361992 149.163593 100.000000 1 +3 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.363812 149.163609 100.000000 1 +4 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.363768 149.166055 100.000000 1 +5 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.361835 149.166012 100.000000 1 +6 0 0 16 0.000000 0.000000 0.000000 0.000000 -35.362150 149.165046 100.000000 1 From cc408fa04b62990846d4f37c0f33ca01f38eaeeb Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Mon, 2 Nov 2015 21:12:04 +1100 Subject: [PATCH 09/13] Further fixes to correct use vehicle.home_location and other minor changes --- docs/examples/channel_overrides.rst | 4 +- docs/examples/create_attribute.rst | 4 +- docs/examples/drone_delivery.rst | 4 +- docs/examples/flight_replay.rst | 39 +++++------- docs/examples/guided-set-speed-yaw-demo.rst | 29 +++++---- docs/examples/mission_basic.rst | 4 +- docs/examples/mission_import_export.rst | 4 +- docs/examples/simple_goto.rst | 4 +- docs/examples/vehicle_state.rst | 30 +++++----- docs/guide/copter/guided_mode.rst | 22 +++++-- docs/guide/vehicle_state_and_parameters.rst | 60 +++++++++++-------- dronekit/lib/__init__.py | 22 +++---- examples/flight_replay/flight_replay.py | 8 ++- .../guided_set_speed_yaw.py | 2 +- examples/vehicle_state/vehicle_state.py | 19 +++--- 15 files changed, 140 insertions(+), 115 deletions(-) diff --git a/docs/examples/channel_overrides.rst b/docs/examples/channel_overrides.rst index abd09fba3..827b6fda1 100644 --- a/docs/examples/channel_overrides.rst +++ b/docs/examples/channel_overrides.rst @@ -43,8 +43,8 @@ In summary, after cloning the repository: .. note:: - The examples uses the ``--connect`` parameter to pass the :ref:`connection string ` into the script. - The command above would be used to connect to :ref:`SITL ` running on the local machine via UDP port 14550. + The ``--connect`` parameter above connects to SITL on udp port 127.0.0.1:14550. + This is the default value for the parameter, and may be omitted. diff --git a/docs/examples/create_attribute.rst b/docs/examples/create_attribute.rst index 91657a2b0..1c35d2408 100644 --- a/docs/examples/create_attribute.rst +++ b/docs/examples/create_attribute.rst @@ -42,8 +42,8 @@ In summary, after cloning the repository: .. note:: - The command parameter above is the default, and may be omitted. This - connects to SITL on udp port 127.0.0.1:14550. + The ``--connect`` parameter above connects to SITL on udp port 127.0.0.1:14550. + This is the default value for the parameter, and may be omitted. diff --git a/docs/examples/drone_delivery.rst b/docs/examples/drone_delivery.rst index 581021f35..88f781287 100644 --- a/docs/examples/drone_delivery.rst +++ b/docs/examples/drone_delivery.rst @@ -53,8 +53,8 @@ In summary, after cloning the repository: .. note:: - The command parameter above is the default, and may be omitted. This - connects to SITL on udp port 127.0.0.1:14550. + The ``--connect`` parameter above connects to SITL on udp port 127.0.0.1:14550. + This is the default value for the parameter, and may be omitted. #. After a short while you should be able to reach your new webserver at http://localhost:8080. diff --git a/docs/examples/flight_replay.rst b/docs/examples/flight_replay.rst index 942dde5a7..5ce47375c 100644 --- a/docs/examples/flight_replay.rst +++ b/docs/examples/flight_replay.rst @@ -2,17 +2,17 @@ Example: Flight Replay ========================= -This example requests a past flight from Droneshare, and then "replays" the mission -by sending waypoints to a vehicle. For safety reasons, the vehicle is replayed at a height of 30 meters. +This example requests a past flight from Droneshare, and then writes the recorded path to the vehicle as mission waypoints. +For safety reasons, the altitude for the waypoints is set to 30 meters (irrespective of the recorded height). -.. warning:: +.. note:: - At time of writing this example fails with an exception in DKYP2: `#355 DKPY2 Can't clear waypoints `_. + The mission is not actually run by this code - though it easily could be by taking off and putting the vehicle into + AUTO mode. -.. todo:: Check if `#355 DKPY2 Can't clear waypoints `_ is fixed and re-review example. You can specify which mission to replay using a parameter when starting the script (for example, to replay your own local flights). -By default the code gets (and replays) the public `Droneshare mission with ID 101 `_. +By default the code gets the public `Droneshare mission with ID 101 `_. .. figure:: flight_replay_example.png @@ -47,8 +47,9 @@ In summary, after cloning the repository: .. note:: - The command parameters above are the defaults, and may be omitted. These - connect to SITL on udp port 127.0.0.1:14550 and replay the mission with id 101. + The ``--connect`` parameter above connects to SITL on udp port 127.0.0.1:14550, while + ``--mission_id`` specifies we're replaying mission 101. Both of these are the default + values for the parameters, and may be omitted. .. tip:: @@ -60,22 +61,20 @@ On the command prompt you should see (something like): .. code-block:: bash - - \dronekit-python\examples\flight_replay>flight_replay.py Connecting to vehicle on: 127.0.0.1:14550 - >>> APM:Copter V3.4-dev (e0810c2e) + >>> APM:Copter V3.3 (d6053245) >>> Frame: QUAD JSON downloaded... Generating 95 waypoints from replay... - ... + Close vehicle object + Completed... How it works ============ The example requests the web server for representative points from the flight, parses the JSON response -and uses that data to generate 100 waypoints. These are then sent to the vehicle. - +and uses that data to generate 100 waypoints. These are then sent to the vehicle. Getting the points @@ -111,7 +110,6 @@ shown in :ref:`example_mission_basic`): print "Generating %s waypoints from replay..." % len(messages) cmds = vehicle.commands cmds.clear() - vehicle.flush() for i in xrange(0, len(messages)): pt = messages[i] lat = pt['lat'] @@ -127,19 +125,14 @@ shown in :ref:`example_mission_basic`): 0, 0, 0, 0, 0, 0, lat, lon, altitude) cmds.add(cmd) - vehicle.flush() + #Upload clear message and command messages to vehicle. + cmds.upload() Known issues ============ -At time of writing this example fails with an exception. See `#355 DKPY2 Can't clear waypoints `_ for more information. - -.. todo:: - - When example is fixed replace above text with - "This example works around the :ref:`known issues in the API `. - Provided that the vehicle is connected and able to arm, it should run through to completion." +There are no known issues with this example. diff --git a/docs/examples/guided-set-speed-yaw-demo.rst b/docs/examples/guided-set-speed-yaw-demo.rst index f76961d8c..dff4cd12a 100644 --- a/docs/examples/guided-set-speed-yaw-demo.rst +++ b/docs/examples/guided-set-speed-yaw-demo.rst @@ -4,9 +4,14 @@ Example: Guided Mode Movement and Commands (Copter) =================================================== -This example shows how to control Copter movement and send immediate commands in :ref:`GUIDED mode `. It demonstrates three methods for explicitly specifying a target position and two commands for controlling movement by setting the vehicle's velocity vectors. It also shows how to send commands to control the yaw (direction that the front of the vehicle is pointing), region of interest, speed and home position, along with some useful functions for converting between frames of reference. +This example shows how to control Copter movement and send immediate commands in :ref:`GUIDED mode `. +It demonstrates three methods for explicitly specifying a target position and two commands for controlling movement by +setting the vehicle's velocity vectors. It also shows how to send commands to control the yaw (direction that the front +of the vehicle is pointing), region of interest, speed and home location, along with some useful functions for +converting between frames of reference. -The example is :ref:`documented in the source code `. More detailed information about using GUIDED mode can be found in the guide: :ref:`guided_mode_copter`. +The example is :ref:`documented in the source code `. +More detailed information about using GUIDED mode can be found in the guide: :ref:`guided_mode_copter`. .. figure:: GuidedModeExample_FlyByPosition.png @@ -50,8 +55,8 @@ In summary, after cloning the repository: .. note:: - The command parameter above is the default, and may be omitted. This - connects to SITL on udp port 127.0.0.1:14550. + The ``--connect`` parameter above connects to SITL on udp port 127.0.0.1:14550. + This is the default value for the parameter, and may be omitted. .. tip:: @@ -152,8 +157,7 @@ On the command prompt you should see (something like): Yaw 90 relative (to previous yaw heading) Set new Home location to current location Get new home location - Home WP: MISSION_ITEM {target_system : 255, target_component : 0, seq : 0, frame : 0, command : 16, current : 0, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : - -35.3632583618, y : 149.164352417, z : 593.91998291} + Home Location: LocationGlobal:lat=-35.3639335632,lon=149.165328979,alt=628.679992676,is_relative=False Velocity South and West Yaw 90 relative (to previous yaw heading) Velocity North and West @@ -266,8 +270,9 @@ which is used to directly specify the speed components of the vehicle. The funct goto_position_target_global_int() --------------------------------- -The function ``goto_position_target_global_int()`` generates a `SET_POSITION_TARGET_GLOBAL_INT `_ MAVLink message -which is used to directly specify the target location of the vehicle. When used with ``MAV_FRAME_GLOBAL_RELATIVE_ALT_INT`` as shown below, this method is effectively the same as :ref:`Vehicle.commands.goto `. +The function ``goto_position_target_global_int()`` generates a `SET_POSITION_TARGET_GLOBAL_INT `_ +MAVLink message which is used to directly specify the target location of the vehicle. When used with ``MAV_FRAME_GLOBAL_RELATIVE_ALT_INT`` as shown below, +this method is effectively the same as :ref:`Vehicle.commands.goto `. .. code-block:: python @@ -310,7 +315,8 @@ which is used to directly specify the target location in the North, East, Down f .. note:: - The `documentation `_ lists a number of possible frames of reference. At time of writing experimentation indicates that the actual frame use is always relative to the home location (not the vehicle, as indicated by MAV_FRAME_BODY_NED). + The `documentation `_ lists a number of possible frames of reference. + Up until Copter 3.2.1 the actual frame use is always relative to the home location (not the vehicle, as indicated by MAV_FRAME_BODY_NED). .. code-block:: python @@ -333,7 +339,7 @@ which is used to directly specify the target location in the North, East, Down f vehicle.send_mavlink(msg) -At time of writing, acceleration and yaw bits are ignored. +At time of writing, acceleration and yaw bits are ignored. Testbed settings @@ -359,7 +365,8 @@ ArduPilot version: Source code =========== -The full source code at documentation build-time is listed below (`current version on github `_): +The full source code at documentation build-time is listed below +(`current version on github `_): .. literalinclude:: ../../examples/guided_set_speed_yaw/guided_set_speed_yaw.py :language: python diff --git a/docs/examples/mission_basic.rst b/docs/examples/mission_basic.rst index 8c3794ef2..ee29857c4 100644 --- a/docs/examples/mission_basic.rst +++ b/docs/examples/mission_basic.rst @@ -45,8 +45,8 @@ In summary, after cloning the repository: .. note:: - The ``--connect`` parameter above specifies the default value, and may be omitted. - This connects to SITL on udp port 127.0.0.1:14550. + The ``--connect`` parameter above connects to SITL on udp port 127.0.0.1:14550. + This is the default value for the parameter, and may be omitted. .. tip:: diff --git a/docs/examples/mission_import_export.rst b/docs/examples/mission_import_export.rst index bf2bc8be0..760b0eae3 100644 --- a/docs/examples/mission_import_export.rst +++ b/docs/examples/mission_import_export.rst @@ -43,8 +43,8 @@ In summary, after cloning the repository: .. note:: - The ``--connect`` parameter above specifies the default value, and may be omitted. - This connects to SITL on udp port 127.0.0.1:14550. + The ``--connect`` parameter above connects to SITL on udp port 127.0.0.1:14550. + This is the default value for the parameter, and may be omitted. On the command prompt you should see (something like): diff --git a/docs/examples/simple_goto.rst b/docs/examples/simple_goto.rst index 0440eef39..1b72ce8b3 100644 --- a/docs/examples/simple_goto.rst +++ b/docs/examples/simple_goto.rst @@ -53,8 +53,8 @@ In summary, after cloning the repository: .. note:: - The command parameter above is the default, and may be omitted. This - connects to SITL on udp port 127.0.0.1:14550. + The ``--connect`` parameter above connects to SITL on udp port 127.0.0.1:14550. + This is the default value for this example, and may be omitted. .. tip:: diff --git a/docs/examples/vehicle_state.rst b/docs/examples/vehicle_state.rst index 6f4c5bacf..07a513ee3 100644 --- a/docs/examples/vehicle_state.rst +++ b/docs/examples/vehicle_state.rst @@ -40,8 +40,8 @@ In summary, after cloning the repository: .. note:: - The examples uses the ``--connect`` parameter to pass the :ref:`connection string ` into the script. - The command above would be used to connect to :ref:`SITL ` running on the local machine via UDP port 14550. + The ``--connect`` parameter above connects to SITL on udp port 127.0.0.1:14550. + This is the default value for the parameter, and may be omitted. @@ -50,35 +50,37 @@ On the command prompt you should see (something like): .. code:: bash Connecting to vehicle on: 127.0.0.1:14550 - >>> APM:Copter V3.3-rc1 (d66eec53) + >>> APM:Copter V3.3 (d6053245) >>> Frame: QUAD - Accumulating vehicle attribute messages (2s) + Accumulating vehicle attribute messages Get all vehicle attribute values: - Global Location: LocationGlobal:lat=-35.363261,lon=149.1652299,alt=0.0,is_relative=False + Global Location: LocationGlobal:lat=-35.3632615,lon=149.1652301,alt=0.0,is_relative=False Local Location: LocationLocal:north=None,east=None,down=None - Attitude: Attitude:pitch=0.00486609805375,yaw=0.489637970924,roll=0.00645932834595 - Velocity: [-0.12, 0.06, 0.0] + Attitude: Attitude:pitch=0.00589594058692,yaw=-0.0884591862559,roll=0.000426373298978 + Velocity: [-0.02, 0.02, 0.0] GPS: GPSInfo:fix=3,num_sat=10 Groundspeed: 0.0 Airspeed: 0.0 Mount status: [None, None, None] - Battery: Battery:voltage=0.0,current=None,level=None + Battery: Battery:voltage=12.587,current=0.0,level=99 Rangefinder: Rangefinder: distance=None, voltage=None Rangefinder distance: None Rangefinder voltage: None Mode: STABILIZE Armed: False + Home Location (before downloading waypoints): None + Home Location (after downloading waypoints): LocationGlobal:lat=-35.3632621765,lon=149.165237427,alt=583.989990234,is_relative=False + Set Vehicle.mode=GUIDED (currently: STABILIZE) Waiting for mode change ... Set Vehicle.armed=True (currently: False) Waiting for arming... - >>> ☺ARMING MOTORS - >>> ☺Initialising APM... - Waiting for arming... + >>> ARMING MOTORS + >>> Initialising APM... Add mode attribute observer for Vehicle.mode Set mode=STABILIZE (currently: GUIDED) @@ -86,17 +88,15 @@ On the command prompt you should see (something like): CALLBACK: Mode changed to: STABILIZE CALLBACK: Mode changed to: STABILIZE - Get home location - Home WP: MISSION_ITEM {target_system : 255, target_component : 0, seq : 0, frame : 0, command : 16, current : 0, autocontinue : 1, param1 : 0.0, param2 : 0.0, param3 : 0.0, param4 : 0.0, x : -35.3632583618, y : 149.165222168, z : 583.729980469} - Read vehicle param 'THR_MIN': 130.0 Write vehicle param 'THR_MIN' : 10 Read new value of param 'THR_MIN': 10.0 Reset vehicle attributes/parameters and exit - >>> ☺DISARMING MOTORS + >>> DISARMING MOTORS Close vehicle object + Completed diff --git a/docs/guide/copter/guided_mode.rst b/docs/guide/copter/guided_mode.rst index 861d4950b..335e1dab2 100644 --- a/docs/guide/copter/guided_mode.rst +++ b/docs/guide/copter/guided_mode.rst @@ -37,7 +37,10 @@ Position control Controlling the vehicle by explicitly setting the target position is useful when the final position is known/fixed. -The recommended method for position control is :py:func:`Vehicle.commands.goto() `. This takes a :py:class:`LocationGlobal ` argument for the target position in the global `WGS84 coordinate system `_, but with altitude relative to the home location (home altitude = 0). +The recommended method for position control is :py:func:`Vehicle.commands.goto() `. +This takes a :py:class:`LocationGlobal ` argument for the target position in the +global `WGS84 coordinate system `_, but with altitude +relative to the home location (home altitude = 0). The method is used as shown below: @@ -51,13 +54,23 @@ The method is used as shown below: vehicle.commands.goto(a_location) -``Vehicle.commands.goto()`` can be interrupted by a later command, and does not provide any functionality to indicate when the vehicle has reached its destination. Developers can use either a time delay or :ref:`measure proximity to the target ` to give the vehicle an opportunity to reach its destination. The :ref:`example-guided-mode-setting-speed-yaw` shows both approaches. +``Vehicle.commands.goto()`` can be interrupted by a later command, and does not provide any functionality +to indicate when the vehicle has reached its destination. Developers can use either a time delay or +:ref:`measure proximity to the target ` to give the vehicle an +opportunity to reach its destination. The :ref:`example-guided-mode-setting-speed-yaw` shows both approaches. When moving the vehicle you can send a separate command to :ref:`control the speed ` (and other vehicle behaviour). .. tip:: - You can also set the position by sending the MAVLink commands `SET_POSITION_TARGET_GLOBAL_INT `_ or `SET_POSITION_TARGET_LOCAL_NED `_, specifying a ``type_mask`` bitmask that enables the position parameters. The main difference between these commands is that the former allows you to specify the location relative to the "global" frames (like ``Vehicle.commands.goto()``), while the later lets you specify the location in NED co-ordinates relative to the home location. For more information on these options see the example code: :ref:`example_guided_mode_goto_position_target_global_int` and :ref:`example_guided_mode_goto_position_target_local_ned`. + You can also set the position by sending the MAVLink commands + `SET_POSITION_TARGET_GLOBAL_INT `_ or + `SET_POSITION_TARGET_LOCAL_NED `_, specifying + a ``type_mask`` bitmask that enables the position parameters. The main difference between these commands is + that the former allows you to specify the location relative to the "global" frames (like + ``Vehicle.commands.goto()``), while the later lets you specify the location in NED co-ordinates relative + to the home location. For more information on these options see the example code: + :ref:`example_guided_mode_goto_position_target_global_int` and :ref:`example_guided_mode_goto_position_target_local_ned`. @@ -313,7 +326,8 @@ The ROI (and yaw) is also reset when the mode, or the command used to control mo Setting the home location ------------------------- -Send the `MAV_CMD_DO_SET_HOME `_ command to set the *home location* to either the current location or a specified location. +Send the `MAV_CMD_DO_SET_HOME `_ +command to set the *home location* to either the current location or a specified location. .. code-block:: python diff --git a/docs/guide/vehicle_state_and_parameters.rst b/docs/guide/vehicle_state_and_parameters.rst index d5e08606e..74cee15d6 100644 --- a/docs/guide/vehicle_state_and_parameters.rst +++ b/docs/guide/vehicle_state_and_parameters.rst @@ -30,6 +30,7 @@ Vehicle state information is exposed through vehicle *attributes*. DroneKit-Pyth :py:attr:`Vehicle.mount_status `, :py:attr:`Vehicle.battery `, :py:attr:`Vehicle.rangefinder `, +:py:attr:`Vehicle.home_location ` :py:attr:`Vehicle.armed `, :py:attr:`Vehicle.mode `. @@ -44,7 +45,7 @@ status can be :ref:`written `. Getting attributes ------------------ -The code fragment below shows how to read and print all the attributes. The values are retrieved from the remote device +The code fragment below shows how to read and print almost the attributes. The values are retrieved from the remote device (not cached). .. code:: python @@ -72,6 +73,9 @@ If an attribute cannot be retrieved then the returned object will contain with ``None`` values for ``eph``, ``satellites_visible`` etc.) Attributes will also return ``None`` if the associated hardware is not present on the connected device. +The behaviour of :py:attr:`Vehicle.home_location ` is different, +:ref:`as discussed below `. + .. tip:: If you're using a :ref:`simulated vehicle ` you can add support for optional hardware including @@ -79,7 +83,7 @@ Attributes will also return ``None`` if the associated hardware is not present and `optical flow sensors `_. - + .. todo:: we need to be able to verify mount_status works/setup. @@ -127,7 +131,7 @@ to confirm they have changed before proceeding. Observing attribute changes --------------------------- -You can observe any of the attributes and will receive notification every time a value is received from the connected vehicle. +You can observe any of the attributes (except the ``home_location``) and will receive notification every time a value is received from the connected vehicle. This allows you to monitor changes to velocity and other vehicle state without the need for polling. Observers are added using :py:func:`Vehicle.add_attribute_observer() `, @@ -175,6 +179,33 @@ For example, the following code can be used in the callback to only print output +.. _vehicle_state_home_location: + +Home location +------------- + +The *Home location* is set when a vehicle is armed and first gets a good location fix from the GPS. The location is used +as the target when the vehicle does a "return to launch". In Copter missions (and often Plane) missions, the altitude of +waypoints is set relative to this position. + +The behaviour of :py:attr:`Vehicle.home_location ` is slightly different than other attributes: + +* In order to get the current value you must first download :py:attr:`Vehicle.commands `, as shown: + + .. code:: python + + cmds = vehicle.commands + cmds.download() + cmds.wait_valid() + print " Home Location: %s" % vehicle.home_location + + The returned value is a :py:class:`LocationGlobal ` object + (or ``None`` before you download the commands). +* The attribute is not observable. +* While you cannot directly set the attribute it can be :ref:`set using a message `. + + + .. _vehicle_state_parameters: Parameters @@ -235,28 +266,6 @@ At time of writing :py:class:`Parameters ` does `not su -.. _vehicle_state_home_location: - -Home location -============= - -The *Home location* is set when a vehicle is armed and first gets a good location fix from the GPS. The location is used -as the target when the vehicle does a "return to launch". In Copter missions (and most Plane) missions, the altitude of -waypoints is set relative to this position. - -Unlike other vehicle state information, the home location is accessed as the 0 index value of -:py:attr:`Vehicle.commands `: - -.. code:: python - - cmds = vehicle.commands - cmds.download() - cmds.wait_valid() - print " Home WP: %s" % cmds[0] - -The returned value is a :py:class:`Command ` object. - - .. _api-information-known-issues: @@ -268,6 +277,7 @@ Below are a number of bugs and known issues related to vehicle state and setting * `#60 Attribute observer callbacks are called with heartbeat until disabled - after first called `_ * `#107 Add implementation for observer methods in Parameter class `_ * `#114 DroneKit has no method for detecting command failure `_ +* `#392 vehicle.home_location should be settable `_ Other API issues and improvement suggestions can viewed on `github here `_. \ No newline at end of file diff --git a/dronekit/lib/__init__.py b/dronekit/lib/__init__.py index f2481f5dd..451d4daab 100644 --- a/dronekit/lib/__init__.py +++ b/dronekit/lib/__init__.py @@ -573,7 +573,7 @@ def flush(self): After the return from ``flush()`` any writes are guaranteed to have completed (or thrown an exception) and future reads will see their effects. - .. deprecated: In 2.x. + .. deprecated: This has been replaced by :py:func:`Vehicle.commands.upload() `. """ if self.wpts_dirty: self.__module.send_all_waypoints() @@ -708,6 +708,8 @@ def home_location(self): # Get the home location home = vehicle.home_location + + The attribute is not writeable or observable. .. warning:: @@ -969,13 +971,12 @@ class CommandSequence(object): cmds.wait_valid() The set of commands can be changed and uploaded to the client. The changes are not guaranteed to be complete until - :py:func:`flush() ` is called on the parent :py:class:`Vehicle` object. + :py:func:`upload() ` is called. .. code:: python cmds = vehicle.commands cmds.clear() - vehicle.flush() lat = -34.364114, lon = 149.166022 altitude = 30.0 @@ -983,7 +984,7 @@ class CommandSequence(object): 0, 0, 0, 0, 0, 0, lat, lon, altitude) cmds.add(cmd) - vehicle.flush() + cmds.upload() .. py:function:: takeoff(altitude) @@ -1071,14 +1072,9 @@ def goto(self, l): 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/dronekit/dronekit-python/issues/132 fixed + Clear the command list. + + This command will be sent to the vehicleonly after you call :py:func:`upload() `. ''' # Add home point again. @@ -1093,7 +1089,7 @@ def add(self, cmd): ''' Add a new command (waypoint) at the end of the command list. - .. note:: Commands are sent to the vehicle only after you call :py:func:`Vehicle.flush`. + .. note:: Commands are sent to the vehicle only after you call ::py:func:`upload() `. :param Command cmd: The command to be added. ''' diff --git a/examples/flight_replay/flight_replay.py b/examples/flight_replay/flight_replay.py index c48c73607..e4ce156b6 100644 --- a/examples/flight_replay/flight_replay.py +++ b/examples/flight_replay/flight_replay.py @@ -90,7 +90,6 @@ def replay_mission(payload): print "Generating %s waypoints from replay..." % len(messages) cmds = vehicle.commands cmds.clear() - vehicle.flush() for i in xrange(0, len(messages)): pt = messages[i] lat = pt['lat'] @@ -106,7 +105,8 @@ def replay_mission(payload): 0, 0, 0, 0, 0, 0, lat, lon, altitude) cmds.add(cmd) - vehicle.flush() + #Upload clear message and command messages to vehicle. + cmds.upload() # Now download the vehicle waypoints @@ -119,6 +119,10 @@ def replay_mission(payload): replay_mission(json) +#Here you could actually replay the mission by +#taking off and changing to AUTO mode. + + #Close vehicle object before exiting script print "Close vehicle object" vehicle.close() diff --git a/examples/guided_set_speed_yaw/guided_set_speed_yaw.py b/examples/guided_set_speed_yaw/guided_set_speed_yaw.py index f658dd275..87534979b 100644 --- a/examples/guided_set_speed_yaw/guided_set_speed_yaw.py +++ b/examples/guided_set_speed_yaw/guided_set_speed_yaw.py @@ -612,7 +612,7 @@ def send_global_velocity(velocity_x, velocity_y, velocity_z): cmds = vehicle.commands cmds.download() cmds.wait_valid() -print " Home WP: %s" % cmds[0] +print " Home Location: %s" % vehicle.home_location print("Velocity South and West") send_global_velocity(NORTH,EAST,0) diff --git a/examples/vehicle_state/vehicle_state.py b/examples/vehicle_state/vehicle_state.py index f0cba15ae..1dc987aba 100644 --- a/examples/vehicle_state/vehicle_state.py +++ b/examples/vehicle_state/vehicle_state.py @@ -50,6 +50,15 @@ print " Armed: %s" % vehicle.armed # settable +# Get Vehicle Home location +print "\n Home Location (before downloading waypoints): %s" % vehicle.home_location + +cmds = vehicle.commands +cmds.download() +cmds.wait_valid() +print " Home Location (after downloading waypoints): %s" % vehicle.home_location + + # Set vehicle mode and armed attributes (the only settable attributes) print "\nSet Vehicle.mode=GUIDED (currently: %s)" % vehicle.mode.name vehicle.mode = VehicleMode("GUIDED") @@ -76,7 +85,7 @@ def mode_callback(attribute): print " CALLBACK: Mode changed to: ", vehicle.mode.name print "\nAdd mode attribute observer for Vehicle.mode" -vehicle.add_attribute_observer('mode', mode_callback) +vehicle.add_attribute_observer('mode', mode_callback) print " Set mode=STABILIZE (currently: %s)" % vehicle.mode.name vehicle.mode = VehicleMode("STABILIZE") @@ -88,14 +97,6 @@ def mode_callback(attribute): vehicle.remove_attribute_observer('mode', mode_callback) -# Get Vehicle Home location ((0 index in Vehicle.commands) -print "\nGet home location" -cmds = vehicle.commands -cmds.download() -cmds.wait_valid() -print " Home WP: %s" % cmds[0] - - # Get/Set Vehicle Parameters print "\nRead vehicle param 'THR_MIN': %s" % vehicle.parameters['THR_MIN'] print "Write vehicle param 'THR_MIN' : 10" From 45ec6deaf2d9dc0769e78c0c73dc69810a9beff1 Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Mon, 2 Nov 2015 12:39:28 -0800 Subject: [PATCH 10/13] Corrects last_waypoint and .next setting. Closes #390. --- dronekit/__init__.py | 2 +- tests/sitl/test_waypoints.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dronekit/__init__.py b/dronekit/__init__.py index 17475ddc5..bebee0537 100644 --- a/dronekit/__init__.py +++ b/dronekit/__init__.py @@ -195,7 +195,7 @@ def listener(self, name, m): @message_default(['WAYPOINT_CURRENT', 'MISSION_CURRENT']) def listener(self, name, m): - self.last_waypoint = m.seq + self.last_waypoint = max(m.seq - 1, 0) self.rc_readback = {} diff --git a/tests/sitl/test_waypoints.py b/tests/sitl/test_waypoints.py index 06dbd0565..8bd8919ef 100644 --- a/tests/sitl/test_waypoints.py +++ b/tests/sitl/test_waypoints.py @@ -75,6 +75,13 @@ def test_parameter(connpath): count += 1 assert_equals(count, 6) + # Test next property + assert_equals(vehicle.commands.next, 0) + vehicle.commands.next = 3 + while vehicle.commands.next != 3: + time.sleep(0.1) + assert_equals(vehicle.commands.next, 3) + # Home should be preserved assert_equals(home.lat, vehicle.home_location.lat) assert_equals(home.lon, vehicle.home_location.lon) From 3f355175f893693ce3369f0b6a6b33cb0ea2a5fd Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Mon, 2 Nov 2015 14:18:49 -0800 Subject: [PATCH 11/13] Adds ability to set home_location. --- dronekit/lib/__init__.py | 18 ++++++++++++++++++ tests/sitl/test_waypoints.py | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/dronekit/lib/__init__.py b/dronekit/lib/__init__.py index 451d4daab..f9437c22e 100644 --- a/dronekit/lib/__init__.py +++ b/dronekit/lib/__init__.py @@ -720,6 +720,24 @@ def home_location(self): loc = self.__module.wploader.wp(0) if loc: return LocationGlobal(loc.x, loc.y, loc.z, is_relative=False) + + @home_location.setter + def home_location(self, pos): + """ + Sets the home location to that of a LocationGlobal object. + + .. note:: If the GPS values differ heavily from EKF values, setting this value will fail silently. + """ + self.send_mavlink(self.message_factory.command_long_encode( + 0, 0, # target system, target component + mavutil.mavlink.MAV_CMD_DO_SET_HOME, # command + 0, # confirmation + 2, # param 1: 1 to use current position, 2 to use the entered values. + 0, 0, 0, # params 2-4 + pos.lat, + pos.lon, + pos.alt + )) @property def commands(self): diff --git a/tests/sitl/test_waypoints.py b/tests/sitl/test_waypoints.py index 8bd8919ef..a3d4cf044 100644 --- a/tests/sitl/test_waypoints.py +++ b/tests/sitl/test_waypoints.py @@ -14,6 +14,28 @@ def test_empty_clear(connpath): assert_equals(len(vehicle.commands), 0) +@with_sitl +def test_set_home(connpath): + vehicle = connect(connpath, await_params=True) + + # Wait for home position to be real and not 0, 0, 0 + # once we request it via cmds.download() + time.sleep(10) + vehicle.commands.download() + vehicle.commands.wait_valid() + assert_not_equals(vehicle.home_location, None) + + # Note: If the GPS values differ heavily from EKF values, this command + # will basically fail silently. This GPS coordinate is tailored for that + # the with_sitl initializer uses to not fail. + vehicle.home_location = LocationGlobal(-35, 149, 600) + vehicle.commands.download() + vehicle.commands.wait_valid() + + assert_equals(vehicle.home_location.lat, -35) + assert_equals(vehicle.home_location.lon, 149) + assert_equals(vehicle.home_location.alt, 600) + @with_sitl def test_parameter(connpath): vehicle = connect(connpath, await_params=True) From 3497ac1d884707774b127d2199a4a3adb4cf0e5e Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Tue, 3 Nov 2015 11:03:48 +1100 Subject: [PATCH 12/13] Add note about rounding errors in returned values --- docs/examples/mission_import_export.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/examples/mission_import_export.rst b/docs/examples/mission_import_export.rst index 760b0eae3..cd00b68c7 100644 --- a/docs/examples/mission_import_export.rst +++ b/docs/examples/mission_import_export.rst @@ -91,6 +91,15 @@ On the command prompt you should see (something like): 6 0 0 16 0.0 0.0 0.0 0.0 -35.3621482849 149.165039062 100.0 1 +.. note:: + + The position values uploaded and then downloaded above do not match exactly. This rounding error can be ignored + because the difference is much smaller than the precision provided by GPS. + + The error occurs because all the params are encoded as 32-bit floats rather than 64-bit doubles (Python's native datatype). + + + How does it work? ================= From 1c7f4852d0d0f5f3952569680e159ad94f269fb2 Mon Sep 17 00:00:00 2001 From: Hamish Willee Date: Tue, 3 Nov 2015 11:04:42 +1100 Subject: [PATCH 13/13] Add doc for clear(). Fix up warning/deprecated for flush() --- dronekit/lib/__init__.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/dronekit/lib/__init__.py b/dronekit/lib/__init__.py index f9437c22e..3b5b85aeb 100644 --- a/dronekit/lib/__init__.py +++ b/dronekit/lib/__init__.py @@ -564,6 +564,14 @@ def __init__(self, module): self.wpts_dirty = False def close(self): + """ + Call ``Vehicle.close()`` before exiting scripts to ensure that all messages have been uploaded/sent: + + .. code:: python + + # About to exit script + vehicle.close() + """ return self.__module.close() def flush(self): @@ -573,7 +581,9 @@ def flush(self): After the return from ``flush()`` any writes are guaranteed to have completed (or thrown an exception) and future reads will see their effects. - .. deprecated: This has been replaced by :py:func:`Vehicle.commands.upload() `. + .. warning:: + + This has been replaced by :py:func:`Vehicle.commands.upload() `. """ if self.wpts_dirty: self.__module.send_all_waypoints() @@ -693,8 +703,12 @@ def channel_readback(self): @property def home_location(self): """ - The current home location in a :py:class:`LocationGlobal`. This value is typically the - GPS location of the vehicle at the point it is armed. + The current home location in a :py:class:`LocationGlobal`. + + This value is initially set by the autopilot as the location of first GPS Lock. + The attribute has a value of ``None`` until :py:func:`Vehicle.commands` has been downloaded. + If the attribute is queried before the home location is set the returned `LocationGlobal` + will have zero values for its member attributes. .. code-block:: python @@ -711,11 +725,6 @@ def home_location(self): The attribute is not writeable or observable. - .. warning:: - - The home location will have a value of ``None`` until :py:func:`Vehicle.commands` has been - downloaded. If no home position has been set the returned location will have - zero values for its member attributes. """ loc = self.__module.wploader.wp(0) if loc: @@ -724,9 +733,11 @@ def home_location(self): @home_location.setter def home_location(self, pos): """ - Sets the home location to that of a LocationGlobal object. + Sets the home location to that of a ``LocationGlobal`` object. - .. note:: If the GPS values differ heavily from EKF values, setting this value will fail silently. + .. note:: + + If the GPS values differ heavily from EKF values, setting this value will fail silently. """ self.send_mavlink(self.message_factory.command_long_encode( 0, 0, # target system, target component