From 786c10a69ee5e8301fac500fdbd5f350503c8fdd Mon Sep 17 00:00:00 2001 From: torsten Date: Sat, 27 Jun 2009 09:29:31 +0000 Subject: [PATCH] fix self initialized of average variable in FGPredictor --- src/Autopilot/xmlauto.cxx | 5 +++-- src/Autopilot/xmlauto.hxx | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Autopilot/xmlauto.cxx b/src/Autopilot/xmlauto.cxx index e971201c4..1d6e81361 100644 --- a/src/Autopilot/xmlauto.cxx +++ b/src/Autopilot/xmlauto.cxx @@ -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 + diff --git a/src/Autopilot/xmlauto.hxx b/src/Autopilot/xmlauto.hxx index df2f9d95c..570e30251 100644 --- a/src/Autopilot/xmlauto.hxx +++ b/src/Autopilot/xmlauto.hxx @@ -297,6 +297,7 @@ class FGPredictor : public FGXMLAutoComponent { private: double last_value; + double average; FGXMLAutoInputList seconds; FGXMLAutoInputList filter_gain; -- 2.39.5