]> git.mxchange.org Git - flightgear.git/blobdiff - src/Autopilot/xmlauto.hxx
Make FlightGear work with 16bpp:
[flightgear.git] / src / Autopilot / xmlauto.hxx
index 1e840d82446d65d8e90d148120d6cb0273e82996..8cf764ae942ae2b7314cb98b5b7406175d5fc26c 100644 (file)
 
 #include STL_STRING
 #include <vector>
+#include <deque>
 
 SG_USING_STD(string);
 SG_USING_STD(vector);
+SG_USING_STD(deque);
 
 #include <simgear/props/props.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
@@ -83,36 +85,21 @@ public:
 
 
 /**
- * A simple proportional controler
+ * Roy Ovesen's PID controller
  */
 
 class FGPIDController : public FGXMLAutoComponent {
 
 private:
 
-    // proportional component data
-    bool proportional;
-    double factor;
-    SGPropertyNode *offset_prop;
-    double offset_value;
-
-    // integral component data
-    bool integral;
-    double gain;
-    double int_sum;
-
-    // prep functions for error term
-    bool one_eighty;
-
-    // post functions for output
-    bool clamp;
-
     // debug flag
     bool debug;
 
     // Input values
     double y_n;                 // measured process value
     double r_n;                 // reference (set point) value
+    double y_scale;             // scale process input from property system
+    double r_scale;             // scale reference input from property system
 
     // Configuration values
     double Kp;                  // proportional gain
@@ -150,6 +137,110 @@ public:
 };
 
 
+/**
+ * A simplistic P [ + I ] PID controller
+ */
+
+class FGPISimpleController : public FGXMLAutoComponent {
+
+private:
+
+    // proportional component data
+    bool proportional;
+    double Kp;
+    SGPropertyNode *offset_prop;
+    double offset_value;
+
+    // integral component data
+    bool integral;
+    double Ki;
+    double int_sum;
+
+    // post functions for output
+    bool clamp;
+
+    // debug flag
+    bool debug;
+
+    // Input values
+    double y_n;                 // measured process value
+    double r_n;                 // reference (set point) value
+    double y_scale;             // scale process input from property system
+    double r_scale;             // scale reference input from property system
+
+    double u_min;               // Minimum output clamp
+    double u_max;               // Maximum output clamp
+
+    
+public:
+
+    FGPISimpleController( SGPropertyNode *node );
+    ~FGPISimpleController() {}
+
+    void update( double dt );
+};
+
+
+/**
+ * Predictor - calculates value in x seconds future.
+ */
+
+class FGPredictor : public FGXMLAutoComponent {
+
+private:
+
+    // proportional component data
+    double last_value;
+    double average;
+    double seconds;
+    double filter_gain;
+
+    // debug flag
+    bool debug;
+
+    // Input values
+    double ivalue;                 // input value
+    
+public:
+
+    FGPredictor( SGPropertyNode *node );
+    ~FGPredictor() {}
+
+    void update( double dt );
+};
+
+
+/**
+ * FGDigitalFilter - a selection of digital filters
+ *
+ * Exponential filter
+ * Double exponential filter
+ * Moving average filter
+ * Noise spike filter
+ *
+ * All these filters are low-pass filters.
+ *
+ */
+
+class FGDigitalFilter : public FGXMLAutoComponent
+{
+private:
+    double Tf;            // Filter time [s]
+    unsigned int samples; // Number of input samples to average
+    double rateOfChange;  // The maximum allowable rate of change [1/s]
+    deque <double> output;
+    deque <double> input;
+    string filterType;
+
+    bool debug;
+
+public:
+    FGDigitalFilter(SGPropertyNode *node);
+    ~FGDigitalFilter() {}
+
+    void update(double dt);
+};
+
 /**
  * Model an autopilot system.
  *