]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/UFO.hxx
Merge branch 'next' into comm-subsystem
[flightgear.git] / src / FDM / UFO.hxx
index 4e2c123f153d107ea7f4e05cd9d3418ca0e03ac8..d22832f70d56f25f12eb88ad692566b58eb8ab02 100644 (file)
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 
 
 #ifndef _UFO_HXX
 #define _UFO_HXX
 
-
 #include "flight.hxx"
 
 
 class FGUFO: public FGInterface {
-    double Throttle;
-    double Aileron;
-    double Elevator;
-    double Elevator_Trim;
-    double Rudder;
+private:
+
+    class lowpass {
+    private:
+        static double _dt;
+        double _coeff;
+        double _last;
+        bool _initialized;
+    public:
+        lowpass(double coeff) : _coeff(coeff), _initialized(false) {}
+        static inline void set_delta(double dt) { _dt = dt; }
+        double filter(double value) {
+            if (!_initialized) {
+                _initialized = true;
+                return _last = value;
+            }
+            double c = _dt / (_coeff + _dt);
+            return _last = value * c + _last * (1.0 - c);
+        }
+    };
+
+    lowpass *Throttle;
+    lowpass *Aileron;
+    lowpass *Elevator;
+    lowpass *Rudder;
+    lowpass *Aileron_Trim;
+    lowpass *Elevator_Trim;
+    lowpass *Rudder_Trim;
+    SGPropertyNode_ptr Speed_Max;
+
 public:
     FGUFO( double dt );
     ~FGUFO();
 
-    // reset flight params to a specific position 
+    // reset flight params to a specific position
     void init();
 
     // update position based on inputs, positions, velocities, etc.