From bed3f0c34442a60ae9bc8a4651a8f38b96672088 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 16 Mar 2018 14:57:18 +1100 Subject: [PATCH] GCS_MAVLink: move handling of get_home_position up --- libraries/GCS_MAVLink/GCS.h | 1 + libraries/GCS_MAVLink/GCS_Common.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 1b2ddb6f1a..7eca35ee6e 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -301,6 +301,7 @@ protected: MAV_RESULT handle_command_camera(const mavlink_command_long_t &packet); MAV_RESULT handle_command_do_send_banner(const mavlink_command_long_t &packet); MAV_RESULT handle_command_do_set_mode(const mavlink_command_long_t &packet); + MAV_RESULT handle_command_get_home_position(const mavlink_command_long_t &packet); // vehicle-overridable message send function virtual bool try_send_message(enum ap_message id); diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index 4a62a65d1f..b90d2ce5b7 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -2124,6 +2124,20 @@ MAV_RESULT GCS_MAVLINK::handle_command_do_set_mode(const mavlink_command_long_t return _set_mode_common(base_mode, custom_mode); } +MAV_RESULT GCS_MAVLINK::handle_command_get_home_position(const mavlink_command_long_t &packet) +{ + if (!AP::ahrs().home_is_set()) { + return MAV_RESULT_FAILED; + } + send_home(AP::ahrs().get_home()); + + Location ekf_origin; + if (AP::ahrs().get_origin(ekf_origin)) { + send_ekf_origin(ekf_origin); + } + return MAV_RESULT_ACCEPTED; +} + MAV_RESULT GCS_MAVLINK::handle_command_long_message(mavlink_command_long_t &packet) { MAV_RESULT result = MAV_RESULT_FAILED; @@ -2167,6 +2181,10 @@ MAV_RESULT GCS_MAVLINK::handle_command_long_message(mavlink_command_long_t &pack break; } + case MAV_CMD_GET_HOME_POSITION: + result = handle_command_get_home_position(packet); + break; + case MAV_CMD_PREFLIGHT_STORAGE: if (is_equal(packet.param1, 2.0f)) { AP_Param::erase_all();