From 420f80db75d17f2fe044b9c66fe254d4c2479fdd Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 3 Apr 2024 21:40:30 +1100 Subject: [PATCH] GCS_MAVLink: move handling of DO_SET_HOME up to GCS_MAVLink base class --- libraries/GCS_MAVLink/GCS.h | 4 ++-- libraries/GCS_MAVLink/GCS_Common.cpp | 17 +++++++++++++++++ libraries/GCS_MAVLink/GCS_Dummy.h | 3 --- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index bd26264667..abcdf00cbd 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -526,8 +526,8 @@ protected: virtual MAV_RESULT handle_command_int_packet(const mavlink_command_int_t &packet, const mavlink_message_t &msg); MAV_RESULT handle_command_int_external_position_estimate(const mavlink_command_int_t &packet); - virtual bool set_home_to_current_location(bool lock) = 0; - virtual bool set_home(const Location& loc, bool lock) = 0; + bool set_home_to_current_location(bool lock); + bool set_home(const Location& loc, bool lock); #if AP_ARMING_ENABLED virtual MAV_RESULT handle_command_component_arm_disarm(const mavlink_command_int_t &packet); diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index f7d17bd2d7..a473626b0b 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -5057,6 +5057,23 @@ void GCS_MAVLINK::handle_landing_target(const mavlink_message_t &msg) } +bool GCS_MAVLINK::set_home_to_current_location(bool _lock) +{ +#if AP_VEHICLE_ENABLED + return AP::vehicle()->set_home_to_current_location(_lock); +#else + return false; +#endif +} + +bool GCS_MAVLINK::set_home(const Location& loc, bool _lock) { +#if AP_VEHICLE_ENABLED + return AP::vehicle()->set_home(loc, _lock); +#else + return false; +#endif +} + MAV_RESULT GCS_MAVLINK::handle_command_do_set_home(const mavlink_command_int_t &packet) { if (is_equal(packet.param1, 1.0f) || (packet.x == 0 && packet.y == 0)) { diff --git a/libraries/GCS_MAVLink/GCS_Dummy.h b/libraries/GCS_MAVLink/GCS_Dummy.h index e40968ca82..723f927dcd 100644 --- a/libraries/GCS_MAVLink/GCS_Dummy.h +++ b/libraries/GCS_MAVLink/GCS_Dummy.h @@ -33,9 +33,6 @@ protected: MAV_MODE base_mode() const override { return (MAV_MODE)MAV_MODE_FLAG_CUSTOM_MODE_ENABLED; } MAV_STATE vehicle_system_status() const override { return MAV_STATE_CALIBRATING; } - bool set_home_to_current_location(bool _lock) override { return false; } - bool set_home(const Location& loc, bool _lock) override { return false; } - void send_nav_controller_output() const override {}; void send_pid_tuning() override {}; };