1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

fixes to barofilter

This commit is contained in:
Corvus Corax 2013-12-08 14:00:09 +01:00
parent 66b0ffd682
commit 84af4b7651

View File

@ -37,7 +37,7 @@
// Private constants // Private constants
#define STACK_REQUIRED 64 #define STACK_REQUIRED 64
#define INIT_CYCLES 1000 #define INIT_CYCLES 100
// Private types // Private types
struct data { struct data {
@ -83,8 +83,8 @@ static int32_t filter(stateFilter *self, stateEstimation *state)
if (this->first_run) { if (this->first_run) {
// Initialize to current altitude reading at initial location // Initialize to current altitude reading at initial location
if (IS_SET(state->updated, SENSORUPDATES_baro)) { 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->baroOffset = ((float)(INIT_CYCLES)-this->first_run) / (float)(INIT_CYCLES)*this->baroOffset + (this->first_run / (float)(INIT_CYCLES)) * state->baro[0];
this->baroAlt = this->baroOffset; this->baroAlt = 0;
this->first_run--; this->first_run--;
UNSET_MASK(state->updated, SENSORUPDATES_baro); UNSET_MASK(state->updated, SENSORUPDATES_baro);
} }