From 90db9785ea2ca474497abbbf9c7e18a4edd16f3a Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 24 Mar 2023 15:18:52 +0100 Subject: [PATCH] fixes --- mission/acsDefs.h | 12 ++++++------ mission/controller/AcsController.cpp | 13 ++++++++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/mission/acsDefs.h b/mission/acsDefs.h index 6af803ab..6097db32 100644 --- a/mission/acsDefs.h +++ b/mission/acsDefs.h @@ -21,7 +21,7 @@ enum SafeSubmode : Submode_t { DEFAULT = 0, DETUMBLE = 1 }; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::ACS_SUBSYSTEM; //! [EXPORT] : [COMMENT] The limits for the rotation in safe mode were violated. -static const Event SAFE_RATE_VIOLATION = MAKE_EVENT(0, severity::MEDIUM); +static constexpr Event SAFE_RATE_VIOLATION = MAKE_EVENT(0, severity::MEDIUM); //! [EXPORT] : [COMMENT] The system has recovered from a safe rate rotation violation. static constexpr Event SAFE_RATE_RECOVERY = MAKE_EVENT(1, severity::MEDIUM); //! [EXPORT] : [COMMENT] Multiple RWs are invalid, uncommandable and therefore higher ACS modes @@ -30,17 +30,17 @@ static constexpr Event MULTIPLE_RW_INVALID = MAKE_EVENT(2, severity::HIGH); //! [EXPORT] : [COMMENT] MEKF was not able to compute a solution. //! P1: MEKF state on exit static constexpr Event MEKF_INVALID_INFO = MAKE_EVENT(3, severity::INFO); -//!< MEKF is able to compute a solution again. +//! [EXPORT] : [COMMENT] MEKF is able to compute a solution again. static constexpr Event MEKF_RECOVERY = MAKE_EVENT(4, severity::INFO); -//! [EXPORT] : [COMMENT] MEKF performed an automatic recovery after detection of nonfinite values. -static constexpr Event MEKF_AUTOMATIC_RECOVERY = MAKE_EVENT(4, severity::INFO); +//! [EXPORT] : [COMMENT] MEKF performed an automatic reset after detection of nonfinite values. +static constexpr Event MEKF_AUTOMATIC_RESET = MAKE_EVENT(5, severity::INFO); //! [EXPORT] : [COMMENT] MEKF was not able to compute a solution during any pointing ACS mode for a //! prolonged time. -static constexpr Event MEKF_INVALID_MODE_VIOLATION = MAKE_EVENT(5, severity::HIGH); +static constexpr Event MEKF_INVALID_MODE_VIOLATION = MAKE_EVENT(6, severity::HIGH); //! [EXPORT] : [COMMENT] The ACS safe mode controller was not able to compute a solution and has //! failed. //! P1: Missing information about magnetic field, P2: Missing information about rotational rate -static constexpr Event SAFE_MODE_CONTROLLER_FAILURE = MAKE_EVENT(6, severity::HIGH); +static constexpr Event SAFE_MODE_CONTROLLER_FAILURE = MAKE_EVENT(7, severity::HIGH); extern const char* getModeStr(AcsMode mode); diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 62bf82b1..a5fd470d 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -154,13 +154,15 @@ void AcsController::performSafe() { mekfInvalidFlag = true; } if (result == MultiplicativeKalmanFilter::MEKF_NOT_FINITE && !mekfLost) { - triggerEvent(acs::MEKF_AUTOMATIC_RECOVERY); + triggerEvent(acs::MEKF_AUTOMATIC_RESET); navigation.resetMekf(&mekfData); mekfLost = true; } - } else { + } else if (mekfInvalidFlag) { + triggerEvent(acs::MEKF_RECOVERY); mekfInvalidFlag = false; } + // get desired satellite rate, sun direction to align to and inertia double satRateSafe[3] = {0, 0, 0}, sunTargetDir[3] = {0, 0, 0}, inertiaEive[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; @@ -260,11 +262,12 @@ void AcsController::performDetumble() { mekfInvalidFlag = true; } if (result == MultiplicativeKalmanFilter::MEKF_NOT_FINITE && !mekfLost) { - triggerEvent(acs::MEKF_AUTOMATIC_RECOVERY); + triggerEvent(acs::MEKF_AUTOMATIC_RESET); navigation.resetMekf(&mekfData); mekfLost = true; } - } else { + } else if (mekfInvalidFlag) { + triggerEvent(acs::MEKF_RECOVERY); mekfInvalidFlag = false; } double magMomMtq[3] = {0, 0, 0}; @@ -317,7 +320,7 @@ void AcsController::performPointingCtrl() { mekfInvalidFlag = true; } if (result == MultiplicativeKalmanFilter::MEKF_NOT_FINITE && !mekfLost) { - triggerEvent(acs::MEKF_AUTOMATIC_RECOVERY); + triggerEvent(acs::MEKF_AUTOMATIC_RESET); navigation.resetMekf(&mekfData); mekfLost = true; }