AP_AHRS: DCM: tidy variable creation

This commit is contained in:
Peter Barker 2024-10-05 11:09:18 +10:00 committed by Peter Barker
parent 6c1a5bf3d0
commit 56de7243f5
1 changed files with 6 additions and 6 deletions

View File

@ -1001,11 +1001,10 @@ void AP_AHRS_DCM::estimate_wind(void)
if (diff_length > 0.2f) { if (diff_length > 0.2f) {
// when turning, use the attitude response to estimate // when turning, use the attitude response to estimate
// wind speed // wind speed
float V;
const Vector3f velocityDiff = velocity - _last_vel; const Vector3f velocityDiff = velocity - _last_vel;
// estimate airspeed it using equation 6 // 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 fuselageDirectionSum = fuselageDirection + _last_fuse;
const Vector3f velocitySum = velocity + _last_vel; const Vector3f velocitySum = velocity + _last_vel;
@ -1017,10 +1016,11 @@ void AP_AHRS_DCM::estimate_wind(void)
const float sintheta = sinf(theta); const float sintheta = sinf(theta);
const float costheta = cosf(theta); const float costheta = cosf(theta);
Vector3f wind = Vector3f(); Vector3f wind{
wind.x = velocitySum.x - V * (costheta * fuselageDirectionSum.x - sintheta * fuselageDirectionSum.y); velocitySum.x - V * (costheta * fuselageDirectionSum.x - sintheta * fuselageDirectionSum.y),
wind.y = velocitySum.y - V * (sintheta * fuselageDirectionSum.x + costheta * fuselageDirectionSum.y); velocitySum.y - V * (sintheta * fuselageDirectionSum.x + costheta * fuselageDirectionSum.y),
wind.z = velocitySum.z - V * fuselageDirectionSum.z; velocitySum.z - V * fuselageDirectionSum.z
};
wind *= 0.5f; wind *= 0.5f;
if (wind.length() < _wind.length() + 20) { if (wind.length() < _wind.length() + 20) {