mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-27 16:54:15 +01:00
OP-1235 allows AccelBiasValue to quickly reach the target value at initialization
This commit is contained in:
parent
a2386f548b
commit
7f6175d817
@ -60,6 +60,7 @@ struct data {
|
|||||||
float accelLast;
|
float accelLast;
|
||||||
float baroLast;
|
float baroLast;
|
||||||
bool first_run;
|
bool first_run;
|
||||||
|
portTickType initTimer;
|
||||||
AltitudeFilterSettingsData settings;
|
AltitudeFilterSettingsData settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -119,6 +120,7 @@ static int32_t filter(stateFilter *self, stateEstimation *state)
|
|||||||
// 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->first_run = 0;
|
this->first_run = 0;
|
||||||
|
this->initTimer = xTaskGetTickCount();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// save existing position and velocity updates so GPS will still work
|
// save existing position and velocity updates so GPS will still work
|
||||||
@ -144,10 +146,13 @@ static int32_t filter(stateFilter *self, stateEstimation *state)
|
|||||||
|
|
||||||
// low pass filter accelerometers
|
// low pass filter accelerometers
|
||||||
this->accelState = (1.0f - this->settings.AccelLowPassKp) * this->accelState + this->settings.AccelLowPassKp * current;
|
this->accelState = (1.0f - this->settings.AccelLowPassKp) * this->accelState + this->settings.AccelLowPassKp * current;
|
||||||
|
if (((xTaskGetTickCount() - this->initTimer) / portTICK_RATE_MS) < 5000) {
|
||||||
|
// allow the offset to reach quickly the target value in case of small AccelDriftKi
|
||||||
|
this->accelBiasState = (1.0f - 0.2f) * this->accelBiasState + 0.2f * this->accelState;
|
||||||
|
} else {
|
||||||
// correct accel offset (low pass zeroing)
|
// correct accel offset (low pass zeroing)
|
||||||
this->accelBiasState = (1.0f - this->settings.AccelDriftKi) * this->accelBiasState + this->settings.AccelDriftKi * this->accelState;
|
this->accelBiasState = (1.0f - this->settings.AccelDriftKi) * this->accelBiasState + this->settings.AccelDriftKi * this->accelState;
|
||||||
|
}
|
||||||
// correct velocity and position state (integration)
|
// correct velocity and position state (integration)
|
||||||
// low pass for average dT, compensate timing jitter from scheduler
|
// low pass for average dT, compensate timing jitter from scheduler
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user