mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Fix an erroneous constant in the calculation of altitude from
barometric pressure. The commit which introduced the error was:
35f0a8e4b0
It transposed (inadvertently, I believe) the last two digits of the
constant 0.190259f. A nearby comment references code in Ardupilot,
in which the constant is 0.190259f.
This commit is contained in:
parent
06f682757d
commit
cc1b8e3e39
1 changed files with 2 additions and 2 deletions
|
@ -425,7 +425,7 @@ int32_t baroCalculateAltitude(void)
|
|||
// calculates height from ground via baro readings
|
||||
// see: https://github.com/diydrones/ardupilot/blob/master/libraries/AP_Baro/AP_Baro.cpp#L140
|
||||
if (isBaroCalibrationComplete()) {
|
||||
BaroAlt_tmp = lrintf((1.0f - pow_approx((float)(baroPressureSum / PRESSURE_SAMPLE_COUNT) / 101325.0f, 0.190295f)) * 4433000.0f); // in cm
|
||||
BaroAlt_tmp = lrintf((1.0f - pow_approx((float)(baroPressureSum / PRESSURE_SAMPLE_COUNT) / 101325.0f, 0.190259f)) * 4433000.0f); // in cm
|
||||
BaroAlt_tmp -= baroGroundAltitude;
|
||||
baro.BaroAlt = lrintf((float)baro.BaroAlt * CONVERT_PARAMETER_TO_FLOAT(barometerConfig()->baro_noise_lpf) + (float)BaroAlt_tmp * (1.0f - CONVERT_PARAMETER_TO_FLOAT(barometerConfig()->baro_noise_lpf))); // additional LPF to reduce baro noise
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ void performBaroCalibrationCycle(void)
|
|||
|
||||
baroGroundPressure -= baroGroundPressure / 8;
|
||||
baroGroundPressure += baroPressureSum / PRESSURE_SAMPLE_COUNT;
|
||||
baroGroundAltitude = (1.0f - pow_approx((baroGroundPressure / 8) / 101325.0f, 0.190295f)) * 4433000.0f;
|
||||
baroGroundAltitude = (1.0f - pow_approx((baroGroundPressure / 8) / 101325.0f, 0.190259f)) * 4433000.0f;
|
||||
|
||||
if (baroGroundPressure == savedGroundPressure)
|
||||
calibratingB = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue