From 41fc0d23b11b81aa0bef22b624701e13dd4c2431 Mon Sep 17 00:00:00 2001 From: George Hines Date: Thu, 14 Jul 2016 13:01:21 -0700 Subject: [PATCH 1/2] add listener to set home location when a HOME_POSITION message is received from the vehicle --- dronekit/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dronekit/__init__.py b/dronekit/__init__.py index c24746fb6..336a830f0 100644 --- a/dronekit/__init__.py +++ b/dronekit/__init__.py @@ -1200,6 +1200,11 @@ def listener(self, name, msg): self._wploader.expected_count = msg.count self._master.waypoint_request_send(0) + + @self.on_message(['HOME_POSITION']) + def listener(self, name, msg): + self._home_location = LocationGlobal(msg.latitude/1.0e7, msg.longitude/1.0e7, msg.altitude/1000.0); + @self.on_message(['WAYPOINT', 'MISSION_ITEM']) def listener(self, name, msg): if not self._wp_loaded: @@ -1904,7 +1909,7 @@ def home_location(self, pos): # Send MAVLink update. self.send_mavlink(self.message_factory.command_long_encode( 0, 0, # target system, target component - mavutil.mavlink.MAV_CMD_DO_SET_HOME, # command + mavutil.mavlink.MAV_CMD_DO_SETH_OME, # command 0, # confirmation 2, # param 1: 1 to use current position, 2 to use the entered values. 0, 0, 0, # params 2-4 From e733072a7a5b16326b7f8a0630e267298dfe5eb1 Mon Sep 17 00:00:00 2001 From: George Hines Date: Thu, 14 Jul 2016 13:04:39 -0700 Subject: [PATCH 2/2] correct a typo from messing up an emacs shortcut --- dronekit/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dronekit/__init__.py b/dronekit/__init__.py index 336a830f0..97bdcd9b2 100644 --- a/dronekit/__init__.py +++ b/dronekit/__init__.py @@ -1909,7 +1909,7 @@ def home_location(self, pos): # Send MAVLink update. self.send_mavlink(self.message_factory.command_long_encode( 0, 0, # target system, target component - mavutil.mavlink.MAV_CMD_DO_SETH_OME, # command + 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