From 6d264497e91c8eb7a863acc30f463bd70098cc78 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 2 May 2022 08:21:51 +1000 Subject: [PATCH] AP_Compass: fixed custom orientation in 3 compass drivers this prevents an internal error and mag failure with DroneCAN, MSP or ExternalAHRS compasses --- libraries/AP_Compass/AP_Compass_ExternalAHRS.cpp | 1 + libraries/AP_Compass/AP_Compass_MSP.cpp | 1 + libraries/AP_Compass/AP_Compass_UAVCAN.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/libraries/AP_Compass/AP_Compass_ExternalAHRS.cpp b/libraries/AP_Compass/AP_Compass_ExternalAHRS.cpp index f28e2df55d..68a801f14a 100644 --- a/libraries/AP_Compass/AP_Compass_ExternalAHRS.cpp +++ b/libraries/AP_Compass/AP_Compass_ExternalAHRS.cpp @@ -25,6 +25,7 @@ AP_Compass_ExternalAHRS::AP_Compass_ExternalAHRS(uint8_t port) set_dev_id(instance, devid); set_external(instance, true); + set_rotation(instance, ROTATION_NONE); } void AP_Compass_ExternalAHRS::handle_external(const AP_ExternalAHRS::mag_data_message_t &pkt) diff --git a/libraries/AP_Compass/AP_Compass_MSP.cpp b/libraries/AP_Compass/AP_Compass_MSP.cpp index cc85bb9676..ea900b5ec7 100644 --- a/libraries/AP_Compass/AP_Compass_MSP.cpp +++ b/libraries/AP_Compass/AP_Compass_MSP.cpp @@ -27,6 +27,7 @@ AP_Compass_MSP::AP_Compass_MSP(uint8_t _msp_instance) set_dev_id(instance, devid); set_external(instance, true); + set_rotation(instance, ROTATION_NONE); } void AP_Compass_MSP::handle_msp(const MSP::msp_compass_data_message_t &pkt) diff --git a/libraries/AP_Compass/AP_Compass_UAVCAN.cpp b/libraries/AP_Compass/AP_Compass_UAVCAN.cpp index e80f48a75d..ef51eb7830 100644 --- a/libraries/AP_Compass/AP_Compass_UAVCAN.cpp +++ b/libraries/AP_Compass/AP_Compass_UAVCAN.cpp @@ -101,6 +101,7 @@ bool AP_Compass_UAVCAN::init() set_dev_id(_instance, _devid); set_external(_instance, true); + set_rotation(_instance, ROTATION_NONE); AP::can().log_text(AP_CANManager::LOG_INFO, LOG_TAG, "AP_Compass_UAVCAN loaded\n\r"); return true;