Skip to content

Commit 77c12af

Browse files
Fixed dynamic IIR filter for air-density-factor.
No bug, there was just a bad definition for the filter-coefficient.
1 parent 7557892 commit 77c12af

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

NAV_Algorithms/air_density_observer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef uint64_t measurement_type;
3838
#define MINIMUM_ALTITUDE_RANGE 300.0f
3939
#define MAXIMUM_ALTITUDE_RANGE 800.0f
4040
#define USE_AIR_DENSITY_LETHARGY 1
41-
#define AIR_DENSITY_LETHARGY 0.7
41+
#define AIR_DENSITY_LETHARGY 0.7f
4242
#define AIR_DENSITY_DECIMATION 20
4343

4444
//! Maintains offset and slope of the air density measurement

NAV_Algorithms/atmosphere.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,19 @@ class atmosphere_t
138138
#if USE_AIR_DENSITY_LETHARGY
139139
bool first_measurement = (weight_sum == 0.0f);
140140

141-
weight_sum = weight_sum * AIR_DENSITY_LETHARGY + (AIR_DENSITY_LETHARGY -1) / result.density_variance;
142-
density_factor_weighed_sum = density_factor_weighed_sum * AIR_DENSITY_LETHARGY + (AIR_DENSITY_LETHARGY -1) * result.density_correction / result.density_variance;
141+
weight_sum = weight_sum * AIR_DENSITY_LETHARGY + (1.0f - AIR_DENSITY_LETHARGY) / result.density_variance;
142+
density_factor_weighed_sum = density_factor_weighed_sum * AIR_DENSITY_LETHARGY + (1.0f - AIR_DENSITY_LETHARGY) * result.density_correction / result.density_variance;
143143

144144
// postpone update unless we have two measurements
145145
if( ! first_measurement)
146146
density_correction = density_factor_weighed_sum / weight_sum;
147+
148+
extern void report_desity_parameters( float, float, float, float);
149+
report_desity_parameters( density_correction, density_factor_weighed_sum, weight_sum, result.density_variance);
150+
147151
#else
148152
density_correction = result.density_correction;
149153
#endif
150-
// todo patch: emergency-brake for implausible values
151-
if( density_correction > 1.15f || density_correction < 0.85f)
152-
density_correction = ONE;
153154
}
154155
}
155156

0 commit comments

Comments
 (0)