]> git.mxchange.org Git - flightgear.git/commitdiff
Optionally disable the lowpass for the static system
authorTorsten Dreyer <Torsten@t3r.de>
Wed, 10 Sep 2014 19:07:57 +0000 (21:07 +0200)
committerTorsten Dreyer <Torsten@t3r.de>
Wed, 10 Sep 2014 19:07:57 +0000 (21:07 +0200)
the static system has an optional "tau" parameter to
define the rate at which the output value changes.

Setting this value to zero now disables the filter.

This prevents wrong airspeed indications on rapid
altitude changes. No functional changes if tau has
other-than-zero values (e.g. the default systems).

src/Systems/static.cxx

index a6e14bb689457d6c3fe62f866ef8315114d4b1f6..f8dc2add63d97a452610a1ab241029d0789018f6 100644 (file)
@@ -15,6 +15,9 @@
 #include <Main/fg_props.hxx>
 #include <Main/util.hxx>
 #include <simgear/constants.h>
+#include <simgear/math/SGMisc.hxx>
+#include <simgear/math/SGLimits.hxx>
+#include <simgear/math/SGMathFwd.hxx>
 #include <simgear/sg_inlines.h>
 
 
@@ -22,7 +25,7 @@ StaticSystem::StaticSystem ( SGPropertyNode *node )
     :
     _name(node->getStringValue("name", "static")),
     _num(node->getIntValue("number", 0)),
-    _tau(node->getDoubleValue("tau", 1)),
+    _tau(SGMiscd::max(.0,node->getDoubleValue("tau", 1))),
     _error_factor(node->getDoubleValue("error-factor", 0)),
     _type(node->getIntValue("type", 0))
 {
@@ -76,7 +79,7 @@ StaticSystem::update (double dt)
         double beta;
         double alpha;
         double mach;
-        double trat = _tau ? dt/_tau : 100;
+        double trat = _tau ? dt/_tau : SGLimitsd::max();
 
         double proj_factor = 0;
         double pt;
@@ -100,7 +103,9 @@ StaticSystem::update (double dt)
             p_new = p_new + qc_part;
         }
 
-        _pressure_out_node->setDoubleValue(fgGetLowPass(p, p_new, trat));           //setting new pressure in static system
+        _pressure_out_node->setDoubleValue(
+            _tau > .0 ? fgGetLowPass(p, p_new, trat) : p_new
+        );           //setting new pressure in static system
 
     }
 }