Fix NaNs in the VSI when pressure reading is invalid
Detect zero/very low pressure reading and avoid generating NaNs in the main update code. Thanks to Johnathan Redpath for the report.
This commit is contained in:
parent
dee1998979
commit
df7988fb49
2 changed files with 21 additions and 8 deletions
|
@ -71,8 +71,21 @@ void
|
||||||
VerticalSpeedIndicator::update (double dt)
|
VerticalSpeedIndicator::update (double dt)
|
||||||
{
|
{
|
||||||
if (_serviceable_node->getBoolValue()) {
|
if (_serviceable_node->getBoolValue()) {
|
||||||
double pressure_inHg = _pressure_node->getDoubleValue() ;
|
const double pressure_inHg = _pressure_node->getDoubleValue() ;
|
||||||
double pressure_Pa = pressure_inHg * SG_INHG_TO_PA;
|
const double pressure_Pa = pressure_inHg * SG_INHG_TO_PA;
|
||||||
|
|
||||||
|
// this occurs if the static pressure source didn't report valid data
|
||||||
|
// yet. Don't continue processing here since we will generate NaNs
|
||||||
|
// when dividing by zero
|
||||||
|
if (_casing_pressure_Pa < 1e-3) {
|
||||||
|
if (pressure_Pa > 1e3) {
|
||||||
|
// once the pressure becomes valid, reinit
|
||||||
|
reinit();
|
||||||
|
} else {
|
||||||
|
return; // no more processing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double Fsign = 0.;
|
double Fsign = 0.;
|
||||||
double orifice_mach = 0.0;
|
double orifice_mach = 0.0;
|
||||||
|
|
||||||
|
|
|
@ -45,13 +45,13 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
double _casing_pressure_Pa;
|
double _casing_pressure_Pa = 0.0;
|
||||||
double _casing_airmass_kg;
|
double _casing_airmass_kg = 0.0;
|
||||||
double _casing_density_kgpm3;
|
double _casing_density_kgpm3 = 0.0;
|
||||||
double _orifice_massflow_kgps;
|
double _orifice_massflow_kgps = 0.0;
|
||||||
|
|
||||||
std::string _name;
|
const std::string _name;
|
||||||
int _num;
|
const int _num;
|
||||||
std::string _static_pressure;
|
std::string _static_pressure;
|
||||||
std::string _static_temperature;
|
std::string _static_temperature;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue