From e74afdfcea1bfd2d7a2842c86c14ffc7ecd90f93 Mon Sep 17 00:00:00 2001 From: Andrii Fil Date: Tue, 3 Sep 2024 19:12:18 +0300 Subject: [PATCH] GCS_MAVLink: support MAV_CMD_EXTERNAL_WIND_ESTIMATE --- libraries/GCS_MAVLink/GCS.h | 1 + libraries/GCS_MAVLink/GCS_Common.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 71725275b3..4463ae1b1c 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -525,6 +525,7 @@ 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); + MAV_RESULT handle_command_int_external_wind_estimate(const mavlink_command_int_t &packet); #if AP_HOME_ENABLED MAV_RESULT handle_command_do_set_home(const mavlink_command_int_t &packet); diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index 4e22558349..e6318c9e2a 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -5233,6 +5233,21 @@ MAV_RESULT GCS_MAVLINK::handle_command_int_external_position_estimate(const mavl } #endif // AP_AHRS_POSITION_RESET_ENABLED +#if AP_AHRS_EXTERNAL_WIND_ESTIMATE_ENABLED +MAV_RESULT GCS_MAVLINK::handle_command_int_external_wind_estimate(const mavlink_command_int_t &packet) +{ + if (packet.param1 < 0) { + return MAV_RESULT_DENIED; + } + if (packet.param3 < 0 || packet.param3 > 360) { + return MAV_RESULT_DENIED; + } + + AP::ahrs().set_external_wind_estimate(packet.param1, packet.param3); + return MAV_RESULT_ACCEPTED; +} +#endif // AP_AHRS_EXTERNAL_WIND_ESTIMATE_ENABLED + MAV_RESULT GCS_MAVLINK::handle_command_do_set_roi(const mavlink_command_int_t &packet) { // be aware that this method is called for both MAV_CMD_DO_SET_ROI @@ -5415,6 +5430,10 @@ MAV_RESULT GCS_MAVLINK::handle_command_int_packet(const mavlink_command_int_t &p case MAV_CMD_EXTERNAL_POSITION_ESTIMATE: return handle_command_int_external_position_estimate(packet); #endif +#if AP_AHRS_EXTERNAL_WIND_ESTIMATE_ENABLED + case MAV_CMD_EXTERNAL_WIND_ESTIMATE: + return handle_command_int_external_wind_estimate(packet); +#endif #if AP_ARMING_ENABLED case MAV_CMD_COMPONENT_ARM_DISARM: return handle_command_component_arm_disarm(packet);