Debian Codegraph @

src/Autopilot/predictor.hxx

raw symbols SCIP
1 // predictor.hxx - predict future values
2 //
3 // Written by Torsten Dreyer
4 // Based heavily on work created by Curtis Olson, started January 2004.
5 //
6 // Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
7 // Copyright (C) 2010 Torsten Dreyer - Torsten (at) t3r (dot) de
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 #ifndef __PREDICTOR_HXX
24 #define __PREDICTOR_HXX 1
25
26 #ifdef HAVE_CONFIG_H
27 # include <config.h>
28 #endif
29
30 #include "analogcomponent.hxx"
31
32 #include <simgear/props/props.hxx>
33
34 namespace FGXMLAutopilot {
35
36 /**
37 * @brief Simple moving average filter converts input value to predicted value "seconds".
38 *
39 * Smoothing as described by Curt Olson:
40 * gain would be valid in the range of 0 - 1.0
41 * 1.0 would mean no filtering.
42 * 0.0 would mean no input.
43 * 0.5 would mean (1 part past value + 1 part current value) / 2
44 * 0.1 would mean (9 parts past value + 1 part current value) / 10
45 * 0.25 would mean (3 parts past value + 1 part current value) / 4
46 */
47 class Predictor : public AnalogComponent
48 {
49 private:
50 double _last_value;
51 double _average;
52 simgear::ValueList _seconds;
53 simgear::ValueList _filter_gain;
54
55 protected:
56 virtual bool configure( SGPropertyNode& cfg_node,
57 const std::string& cfg_name,
58 SGPropertyNode& prop_root );
59
60 public:
61 Predictor();
62 ~Predictor() {}
63
64 // Subsystem identification.
65 static const char* staticSubsystemClassId() { return "predict-simple"; }
66
67 void update( bool firstTime, double dt );
68 };
69
70 } // namespace FGXMLAutopilot
71
72 #endif