From 26d4fbc000430f98b2156f284b83761a09e234fb Mon Sep 17 00:00:00 2001 From: bresch Date: Fri, 8 May 2020 15:44:13 +0200 Subject: [PATCH] EKF: reduce scope of variable and remove redeclaration of member --- EKF/EKFGSF_yaw.cpp | 3 +-- EKF/ekf.h | 1 - EKF/estimator_interface.h | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/EKF/EKFGSF_yaw.cpp b/EKF/EKFGSF_yaw.cpp index 0864ac4dda..8243a10508 100644 --- a/EKF/EKFGSF_yaw.cpp +++ b/EKF/EKFGSF_yaw.cpp @@ -588,9 +588,8 @@ Matrix3f EKFGSF_yaw::ahrsPredictRotMat(const Matrix3f &R, const Vector3f &g) ret(2,2) += R(2,0) * g(1) - R(2,1) * g(0); // Renormalise rows - float rowLengthSq; for (uint8_t r = 0; r < 3; r++) { - rowLengthSq = ret.row(r).norm_squared(); + const float rowLengthSq = ret.row(r).norm_squared(); if (rowLengthSq > FLT_EPSILON) { // Use linear approximation for inverse sqrt taking advantage of the row length being close to 1.0 const float rowLengthInv = 1.5f - 0.5f * rowLengthSq; diff --git a/EKF/ekf.h b/EKF/ekf.h index 27ad67d8df..9636897cc7 100644 --- a/EKF/ekf.h +++ b/EKF/ekf.h @@ -347,7 +347,6 @@ private: uint64_t _time_last_of_fuse{0}; ///< time the last fusion of optical flow measurements were performed (uSec) uint64_t _time_last_arsp_fuse{0}; ///< time the last fusion of airspeed measurements were performed (uSec) uint64_t _time_last_beta_fuse{0}; ///< time the last fusion of synthetic sideslip measurements were performed (uSec) - uint64_t _time_last_mag{0}; ///< measurement time of last magnetomter sample (uSec) uint64_t _time_last_fake_pos{0}; ///< last time we faked position measurements to constrain tilt errors during operation without external aiding (uSec) Vector2f _last_known_posNE; ///< last known local NE position vector (m) diff --git a/EKF/estimator_interface.h b/EKF/estimator_interface.h index 91f0c24ce5..5ec9656bca 100644 --- a/EKF/estimator_interface.h +++ b/EKF/estimator_interface.h @@ -540,7 +540,7 @@ protected: // timestamps of latest in buffer saved measurement in microseconds uint64_t _time_last_imu{0}; uint64_t _time_last_gps{0}; - uint64_t _time_last_mag{0}; + uint64_t _time_last_mag{0}; ///< measurement time of last magnetomter sample (uSec) uint64_t _time_last_baro{0}; uint64_t _time_last_range{0}; uint64_t _time_last_airspeed{0};