From 84af4b7651683cc972e51bb30e1a82751577f11d Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 8 Dec 2013 14:00:09 +0100 Subject: [PATCH] fixes to barofilter --- flight/modules/StateEstimation/filterbaro.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flight/modules/StateEstimation/filterbaro.c b/flight/modules/StateEstimation/filterbaro.c index 18078efd1..a44927392 100644 --- a/flight/modules/StateEstimation/filterbaro.c +++ b/flight/modules/StateEstimation/filterbaro.c @@ -37,7 +37,7 @@ // Private constants #define STACK_REQUIRED 64 -#define INIT_CYCLES 1000 +#define INIT_CYCLES 100 // Private types struct data { @@ -83,8 +83,8 @@ static int32_t filter(stateFilter *self, stateEstimation *state) if (this->first_run) { // Initialize to current altitude reading at initial location if (IS_SET(state->updated, SENSORUPDATES_baro)) { - this->baroOffset = (INIT_CYCLES - this->first_run) / INIT_CYCLES * this->baroOffset + (this->first_run / INIT_CYCLES) * state->baro[0]; - this->baroAlt = this->baroOffset; + this->baroOffset = ((float)(INIT_CYCLES)-this->first_run) / (float)(INIT_CYCLES)*this->baroOffset + (this->first_run / (float)(INIT_CYCLES)) * state->baro[0]; + this->baroAlt = 0; this->first_run--; UNSET_MASK(state->updated, SENSORUPDATES_baro); }