]> git.mxchange.org Git - flightgear.git/commitdiff
fix self initialized of average variable in FGPredictor
authortorsten <torsten>
Sat, 27 Jun 2009 09:29:31 +0000 (09:29 +0000)
committerTim Moore <timoore@redhat.com>
Thu, 2 Jul 2009 06:59:16 +0000 (08:59 +0200)
src/Autopilot/xmlauto.cxx
src/Autopilot/xmlauto.hxx

index e971201c4a68b2b5e8ac1759903c2c3e6a119f91..1d6e8136127d5d8c7aaca55a6ed29f6096f35a4b 100644 (file)
@@ -573,7 +573,8 @@ void FGPISimpleController::update( double dt ) {
 
 
 FGPredictor::FGPredictor ( SGPropertyNode *node ):
-    FGXMLAutoComponent( node )
+    FGXMLAutoComponent( node ),
+    average(0.0)
 {
     int i;
     for ( i = 0; i < node->nChildren(); ++i ) {
@@ -618,7 +619,7 @@ void FGPredictor::update( double dt ) {
 
         if ( dt > 0.0 ) {
             double current = (ivalue - last_value)/dt; // calculate current error change (per second)
-            double average = dt < 1.0 ? ((1.0 - dt) * average + current * dt) : current;
+            average = dt < 1.0 ? ((1.0 - dt) * average + current * dt) : current;
 
             // calculate output with filter gain adjustment
             double output = ivalue + 
index df2f9d95cba2ac5aa81a441a2c415f319bb07e36..570e3025178fc59fcaf22378e7aa9f6d7faf43a7 100644 (file)
@@ -297,6 +297,7 @@ class FGPredictor : public FGXMLAutoComponent {
 
 private:
     double last_value;
+    double average;
     FGXMLAutoInputList seconds;
     FGXMLAutoInputList filter_gain;