From 9989fbcf6c92b5b314f7496da8fc70eb7788b14d Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sat, 5 Oct 2024 11:09:18 +1000 Subject: [PATCH] AP_AHRS: DCM: tidy variable creation --- libraries/AP_AHRS/AP_AHRS_DCM.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/AP_AHRS/AP_AHRS_DCM.cpp b/libraries/AP_AHRS/AP_AHRS_DCM.cpp index fd0b8677561eb..f1ee8e29befc2 100644 --- a/libraries/AP_AHRS/AP_AHRS_DCM.cpp +++ b/libraries/AP_AHRS/AP_AHRS_DCM.cpp @@ -1001,11 +1001,10 @@ void AP_AHRS_DCM::estimate_wind(void) if (diff_length > 0.2f) { // when turning, use the attitude response to estimate // wind speed - float V; const Vector3f velocityDiff = velocity - _last_vel; // estimate airspeed it using equation 6 - V = velocityDiff.length() / diff_length; + const float V = velocityDiff.length() / diff_length; const Vector3f fuselageDirectionSum = fuselageDirection + _last_fuse; const Vector3f velocitySum = velocity + _last_vel; @@ -1017,10 +1016,11 @@ void AP_AHRS_DCM::estimate_wind(void) const float sintheta = sinf(theta); const float costheta = cosf(theta); - Vector3f wind = Vector3f(); - wind.x = velocitySum.x - V * (costheta * fuselageDirectionSum.x - sintheta * fuselageDirectionSum.y); - wind.y = velocitySum.y - V * (sintheta * fuselageDirectionSum.x + costheta * fuselageDirectionSum.y); - wind.z = velocitySum.z - V * fuselageDirectionSum.z; + Vector3f wind{ + velocitySum.x - V * (costheta * fuselageDirectionSum.x - sintheta * fuselageDirectionSum.y), + velocitySum.y - V * (sintheta * fuselageDirectionSum.x + costheta * fuselageDirectionSum.y), + velocitySum.z - V * fuselageDirectionSum.z + }; wind *= 0.5f; if (wind.length() < _wind.length() + 20) {