From 514bc5c21d7209fcf35b115f0b7323ab6cacd695 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 2 May 2018 16:50:28 +1000 Subject: [PATCH] GCS_MAVLink: move send_attitude up to GCS_MAVLINK --- libraries/GCS_MAVLink/GCS.h | 1 + libraries/GCS_MAVLink/GCS_Common.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index caa3efbf0d..d9fc9f0fb7 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -181,6 +181,7 @@ public: #if AP_AHRS_NAVEKF_AVAILABLE void send_opticalflow(const OpticalFlow &optflow); #endif + virtual void send_attitude() const; void send_autopilot_version() const; void send_local_position() const; void send_vibration() const; diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index a2d933dc4c..12fdeee343 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -2693,6 +2693,21 @@ bool GCS_MAVLINK::try_send_camera_message(const enum ap_message id) return ret; } +void GCS_MAVLINK::send_attitude() const +{ + const AP_AHRS &ahrs = AP::ahrs(); + const Vector3f omega = ahrs.get_gyro(); + mavlink_msg_attitude_send( + chan, + AP_HAL::millis(), + ahrs.roll, + ahrs.pitch, + ahrs.yaw, + omega.x, + omega.y, + omega.z); +} + bool GCS_MAVLINK::try_send_message(const enum ap_message id) { if (telemetry_delayed()) { @@ -2703,6 +2718,11 @@ bool GCS_MAVLINK::try_send_message(const enum ap_message id) switch(id) { + case MSG_ATTITUDE: + CHECK_PAYLOAD_SIZE(ATTITUDE); + send_attitude(); + break; + case MSG_NEXT_PARAM: CHECK_PAYLOAD_SIZE(PARAM_VALUE); queued_param_send();