mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-05 21:52:10 +01:00
small fix to baro state filter - more init cycles
This commit is contained in:
parent
5cc8dedadf
commit
66b0ffd682
@ -37,6 +37,7 @@
|
|||||||
// Private constants
|
// Private constants
|
||||||
|
|
||||||
#define STACK_REQUIRED 64
|
#define STACK_REQUIRED 64
|
||||||
|
#define INIT_CYCLES 1000
|
||||||
|
|
||||||
// Private types
|
// Private types
|
||||||
struct data {
|
struct data {
|
||||||
@ -67,7 +68,7 @@ static int32_t init(stateFilter *self)
|
|||||||
struct data *this = (struct data *)self->localdata;
|
struct data *this = (struct data *)self->localdata;
|
||||||
|
|
||||||
this->baroOffset = 0.0f;
|
this->baroOffset = 0.0f;
|
||||||
this->first_run = 100;
|
this->first_run = INIT_CYCLES;
|
||||||
|
|
||||||
RevoSettingsInitialize();
|
RevoSettingsInitialize();
|
||||||
RevoSettingsBaroGPSOffsetCorrectionAlphaGet(&this->baroGPSOffsetCorrectionAlpha);
|
RevoSettingsBaroGPSOffsetCorrectionAlphaGet(&this->baroGPSOffsetCorrectionAlpha);
|
||||||
@ -82,7 +83,7 @@ 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 = (100.f - this->first_run) / 100.f * this->baroOffset + (this->first_run / 100.f) * state->baro[0];
|
this->baroOffset = (INIT_CYCLES - this->first_run) / INIT_CYCLES * this->baroOffset + (this->first_run / INIT_CYCLES) * state->baro[0];
|
||||||
this->baroAlt = this->baroOffset;
|
this->baroAlt = this->baroOffset;
|
||||||
this->first_run--;
|
this->first_run--;
|
||||||
UNSET_MASK(state->updated, SENSORUPDATES_baro);
|
UNSET_MASK(state->updated, SENSORUPDATES_baro);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user