From b4379775477c00e91bc7372d4ac210d4fba941ab Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 15 Oct 2014 09:16:31 +1100 Subject: [PATCH] AP_Compass: added set_offsets() interface this will be used by Replay to prevent the need for saving parameters --- libraries/AP_Compass/Compass.cpp | 9 +++++++++ libraries/AP_Compass/Compass.h | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/libraries/AP_Compass/Compass.cpp b/libraries/AP_Compass/Compass.cpp index b3d2a7c6a1..5d035ac843 100644 --- a/libraries/AP_Compass/Compass.cpp +++ b/libraries/AP_Compass/Compass.cpp @@ -289,6 +289,15 @@ Compass::init() return true; } +void +Compass::set_offsets(uint8_t i, const Vector3f &offsets) +{ + // sanity check compass instance provided + if (i < COMPASS_MAX_INSTANCES) { + _offset[i].set(offsets); + } +} + void Compass::set_and_save_offsets(uint8_t i, const Vector3f &offsets) { diff --git a/libraries/AP_Compass/Compass.h b/libraries/AP_Compass/Compass.h index 2cc64cdd65..1a6e76227a 100644 --- a/libraries/AP_Compass/Compass.h +++ b/libraries/AP_Compass/Compass.h @@ -87,6 +87,13 @@ public: /// float calculate_heading(const Matrix3f &dcm_matrix) const; + /// Sets offset x/y/z values. + /// + /// @param i compass instance + /// @param offsets Offsets to the raw mag_ values. + /// + void set_offsets(uint8_t i, const Vector3f &offsets); + /// Sets and saves the compass offset x/y/z values. /// /// @param i compass instance