From ed934c19990b274e02136ae1ee5dd801409e9686 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Wed, 15 Feb 2012 14:59:10 +0100 Subject: [PATCH] Some xml-autopilot tuning - Add update-interval-secs to the entire autopilot - cache min/max values in InputValue - a little more relaxed "equals zero" checking in the NoiseSpikeFilter --- src/Autopilot/autopilotgroup.cxx | 4 +++- src/Autopilot/digitalfilter.cxx | 2 +- src/Autopilot/inputvalue.cxx | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Autopilot/autopilotgroup.cxx b/src/Autopilot/autopilotgroup.cxx index a856c342f..8cf389f8e 100644 --- a/src/Autopilot/autopilotgroup.cxx +++ b/src/Autopilot/autopilotgroup.cxx @@ -65,7 +65,9 @@ void FGXMLAutopilotGroupImplementation::addAutopilot( const std::string & name, } FGXMLAutopilot::Autopilot * ap = new FGXMLAutopilot::Autopilot( apNode, config ); ap->set_name( name ); - set_subsystem( name, ap ); + + double updateInterval = config->getDoubleValue( "update-interval-secs", 0.0 ); + set_subsystem( name, ap, updateInterval ); _autopilotNames.push_back( name ); } diff --git a/src/Autopilot/digitalfilter.cxx b/src/Autopilot/digitalfilter.cxx index d73a2585e..d3b55cb4d 100644 --- a/src/Autopilot/digitalfilter.cxx +++ b/src/Autopilot/digitalfilter.cxx @@ -251,7 +251,7 @@ void NoiseSpikeFilterImplementation::initialize( double output ) double NoiseSpikeFilterImplementation::compute( double dt, double input ) { double delta = input - _output_1; - if( delta == 0.0 ) return input; // trivial + if( fabs(delta) <= SGLimitsd::min() ) return input; // trivial double maxChange = _rateOfChangeInput.get_value() * dt; const PeriodicalValue * periodical = _digitalFilter->getPeriodicalValue(); diff --git a/src/Autopilot/inputvalue.cxx b/src/Autopilot/inputvalue.cxx index d097cef91..6fd686b33 100644 --- a/src/Autopilot/inputvalue.cxx +++ b/src/Autopilot/inputvalue.cxx @@ -41,8 +41,11 @@ double PeriodicalValue::normalize( double value ) const double PeriodicalValue::normalizeSymmetric( double value ) const { - value = SGMiscd::normalizePeriodic( minPeriod->get_value(), maxPeriod->get_value(), value ); - double width_2 = (maxPeriod->get_value() - minPeriod->get_value())/2; + double minValue = minPeriod->get_value(); + double maxValue = maxPeriod->get_value(); + + value = SGMiscd::normalizePeriodic( minValue, maxValue, value ); + double width_2 = (maxValue - minValue)/2; return value > width_2 ? width_2 - value : value; }