mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-30 08:24:11 +01:00
Attitude: Fixed calculation for baro offset adjustment time
This commit is contained in:
parent
8c4dc2be32
commit
a786c6e6b9
@ -78,7 +78,11 @@
|
||||
#define F_PI 3.14159265358979323846f
|
||||
#define PI_MOD(x) (fmodf(x + F_PI, F_PI * 2) - F_PI)
|
||||
|
||||
#define BaroOffsetLowPassTime 300 // low pass filter settle time aprox 5 minutes TODO: make a setting
|
||||
// low pass filter configuration to calculate offset
|
||||
// of barometric altitude sensor
|
||||
// reasoning: updates at: 10 Hz, tau= 300 s settle time
|
||||
// exp(-(1/f) / tau ) ~=~ 0.9997
|
||||
#define BARO_OFFSET_LOWPASS_ALPHA 0.9997f
|
||||
// Private types
|
||||
|
||||
// Private variables
|
||||
@ -582,7 +586,7 @@ static int32_t updateAttitudeINSGPS(bool first_run, bool outdoor_mode)
|
||||
float pos[3] = {0.0f, 0.0f, 0.0f};
|
||||
|
||||
// Initialize barometric offset to homelocation altitude
|
||||
baroOffset = -home.Altitude;
|
||||
baroOffset = -baroData.Altitude;
|
||||
pos[2] = -(baroData.Altitude + baroOffset);
|
||||
|
||||
// Reset the INS algorithm
|
||||
@ -743,10 +747,9 @@ static int32_t updateAttitudeINSGPS(bool first_run, bool outdoor_mode)
|
||||
getNED(&gpsData, NED);
|
||||
|
||||
// Track barometric altitude offset with a low pass filter
|
||||
if (baro_updated) {
|
||||
baroOffset = (1.0f - (dT/BaroOffsetLowPassTime)) * baroOffset + (dT/BaroOffsetLowPassTime) *
|
||||
( -NED[2] - baroData.Altitude );
|
||||
}
|
||||
baroOffset = BARO_OFFSET_LOWPASS_ALPHA * baroOffset +
|
||||
(1.0f - BARO_OFFSET_LOWPASS_ALPHA )
|
||||
* ( -NED[2] - baroData.Altitude );
|
||||
|
||||
// Store this for inspecting offline
|
||||
NEDPositionData nedPos;
|
||||
|
Loading…
Reference in New Issue
Block a user