Skip to content

Commit

Permalink
Add back check for bounding wind updates
Browse files Browse the repository at this point in the history
Allow either updates which lower the total wind speed or increase
it slightly. Arduplane uses a similar algorithm, so let's fly
test this and see what happens.
  • Loading branch information
fiam committed Nov 5, 2017
1 parent f5db778 commit 96a0a70
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/flight/wind_estimator.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,15 @@ void updateWindEstimator(timeUs_t currentTimeUs)
wind[Y] = (groundVelocitySum[Y] - V * (sintheta * fuselageDirectionSum[X] + costheta * fuselageDirectionSum[Y])) * 0.5f;// equation 11
wind[Z] = (groundVelocitySum[Z] - V * fuselageDirectionSum[Z]) * 0.5f;// equation 12

float prev_wind_length = sqrtf(sq(estimatedWind[X]) + sq(estimatedWind[Y]) + sq(estimatedWind[Z]));
float wind_length = sqrtf(sq(wind[X]) + sq(wind[Y]) + sq(wind[Z]));

// TODO: Better filtering
estimatedWind[X] = estimatedWind[X] * 0.95f + wind[X] * 0.05f;
estimatedWind[Y] = estimatedWind[Y] * 0.95f + wind[Y] * 0.05f;
estimatedWind[Z] = estimatedWind[Z] * 0.95f + wind[Z] * 0.05f;
if (wind_length < prev_wind_length + 20) {
estimatedWind[X] = estimatedWind[X] * 0.95f + wind[X] * 0.05f;
estimatedWind[Y] = estimatedWind[Y] * 0.95f + wind[Y] * 0.05f;
estimatedWind[Z] = estimatedWind[Z] * 0.95f + wind[Z] * 0.05f;
}

lastUpdateUs = currentTimeUs;
hasValidWindEstimate = true;
Expand Down

0 comments on commit 96a0a70

Please sign in to comment.