From 288f4bfbb4af70de2374375740317484a9566a73 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Dec 2021 09:07:02 +1100 Subject: [PATCH] AP_NavEKF3: fixed gaps in EKF logging timestamps should not be static as otherwise some lanes will not be logged --- libraries/AP_NavEKF3/AP_NavEKF3_Logging.cpp | 5 +---- libraries/AP_NavEKF3/AP_NavEKF3_core.cpp | 1 - libraries/AP_NavEKF3/AP_NavEKF3_core.h | 8 +++++++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/AP_NavEKF3/AP_NavEKF3_Logging.cpp b/libraries/AP_NavEKF3/AP_NavEKF3_Logging.cpp index 307b3bf5c8..df2dae4901 100644 --- a/libraries/AP_NavEKF3/AP_NavEKF3_Logging.cpp +++ b/libraries/AP_NavEKF3/AP_NavEKF3_Logging.cpp @@ -273,7 +273,6 @@ void NavEKF3_core::Log_Write_BodyOdom(uint64_t time_us) return; } - static uint32_t lastUpdateTime_ms = 0; const uint32_t updateTime_ms = MAX(bodyOdmDataDelayed.time_ms,wheelOdmDataDelayed.time_ms); if (updateTime_ms > lastUpdateTime_ms) { const struct log_XKFD pkt11{ @@ -293,14 +292,13 @@ void NavEKF3_core::Log_Write_BodyOdom(uint64_t time_us) } #endif -void NavEKF3_core::Log_Write_State_Variances(uint64_t time_us) const +void NavEKF3_core::Log_Write_State_Variances(uint64_t time_us) { if (core_index != frontend->primary) { // log only primary instance for now return; } - static uint32_t lastEkfStateVarLogTime_ms = 0; if (AP::dal().millis() - lastEkfStateVarLogTime_ms > 490) { lastEkfStateVarLogTime_ms = AP::dal().millis(); const struct log_XKV pktv1{ @@ -394,7 +392,6 @@ void NavEKF3_core::Log_Write(uint64_t time_us) void NavEKF3_core::Log_Write_Timing(uint64_t time_us) { // log EKF timing statistics every 5s - static uint32_t lastTimingLogTime_ms = 0; if (AP::dal().millis() - lastTimingLogTime_ms <= 5000) { return; } diff --git a/libraries/AP_NavEKF3/AP_NavEKF3_core.cpp b/libraries/AP_NavEKF3/AP_NavEKF3_core.cpp index 13d9eed5ba..6893a28435 100644 --- a/libraries/AP_NavEKF3/AP_NavEKF3_core.cpp +++ b/libraries/AP_NavEKF3/AP_NavEKF3_core.cpp @@ -2182,7 +2182,6 @@ void NavEKF3_core::verifyTiltErrorVariance() } tiltErrorVarianceAlt = MIN(tiltErrorVarianceAlt, sq(radians(30.0f))); - static uint32_t lastLogTime_ms = 0; if (imuSampleTime_ms - lastLogTime_ms > 500) { lastLogTime_ms = imuSampleTime_ms; const struct log_XKTV msg { diff --git a/libraries/AP_NavEKF3/AP_NavEKF3_core.h b/libraries/AP_NavEKF3/AP_NavEKF3_core.h index b0c6da6aec..822c22b969 100644 --- a/libraries/AP_NavEKF3/AP_NavEKF3_core.h +++ b/libraries/AP_NavEKF3/AP_NavEKF3_core.h @@ -1479,6 +1479,12 @@ private: bool EKFGSF_run_filterbank; // true when the filter bank is active uint8_t EKFGSF_yaw_valid_count; // number of updates since the last invalid yaw estimate + // logging timestamps + uint32_t lastLogTime_ms; + uint32_t lastUpdateTime_ms; + uint32_t lastEkfStateVarLogTime_ms; + uint32_t lastTimingLogTime_ms; + // bits in EK3_AFFINITY enum ekf_affinity { EKF_AFFINITY_GPS = (1U<<0), @@ -1519,7 +1525,7 @@ private: void Log_Write_Quaternion(uint64_t time_us) const; void Log_Write_Beacon(uint64_t time_us); void Log_Write_BodyOdom(uint64_t time_us); - void Log_Write_State_Variances(uint64_t time_us) const; + void Log_Write_State_Variances(uint64_t time_us); void Log_Write_Timing(uint64_t time_us); void Log_Write_GSF(uint64_t time_us); };