From 3f043dd933b9922a654e27b5d91a5c870d47bb21 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 13 Aug 2021 08:57:26 +1000 Subject: [PATCH] AP_AHRS: added get_view_rotation() --- libraries/AP_AHRS/AP_AHRS.cpp | 7 +++++++ libraries/AP_AHRS/AP_AHRS.h | 3 +++ libraries/AP_AHRS/AP_AHRS_View.h | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/libraries/AP_AHRS/AP_AHRS.cpp b/libraries/AP_AHRS/AP_AHRS.cpp index 18ce1af884..044d245cf7 100644 --- a/libraries/AP_AHRS/AP_AHRS.cpp +++ b/libraries/AP_AHRS/AP_AHRS.cpp @@ -3058,6 +3058,13 @@ void AP_AHRS::set_alt_measurement_noise(float noise) #endif } +/* + get the current views rotation, or ROTATION_NONE + */ +enum Rotation AP_AHRS::get_view_rotation(void) const +{ + return _view?_view->get_rotation():ROTATION_NONE; +} // singleton instance AP_AHRS *AP_AHRS::_singleton; diff --git a/libraries/AP_AHRS/AP_AHRS.h b/libraries/AP_AHRS/AP_AHRS.h index b1bcb3a094..046919bd95 100644 --- a/libraries/AP_AHRS/AP_AHRS.h +++ b/libraries/AP_AHRS/AP_AHRS.h @@ -457,6 +457,9 @@ public: _vehicle_class = vclass; } + // get the views rotation, or ROTATION_NONE + enum Rotation get_view_rotation(void) const; + protected: // optional view class AP_AHRS_View *_view; diff --git a/libraries/AP_AHRS/AP_AHRS_View.h b/libraries/AP_AHRS/AP_AHRS_View.h index 10df0a911d..a5c9440ef1 100644 --- a/libraries/AP_AHRS/AP_AHRS_View.h +++ b/libraries/AP_AHRS/AP_AHRS_View.h @@ -185,6 +185,12 @@ public: int32_t pitch_sensor; int32_t yaw_sensor; + + // get current rotation + enum Rotation get_rotation(void) const { + return rotation; + } + private: const enum Rotation rotation; AP_AHRS &ahrs;