]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/flight_control/FGPID.h
sync with JSB JSBSim CVS
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGPID.h
index b31e984f4bc13ee2a9607037f4ced011043aa279..74d9aeae9badb9beb9da61e1f1e3a793ac32e09d 100755 (executable)
@@ -4,7 +4,7 @@
  Author:       Jon Berndt
  Date started: 6/17/2006
 
- ------------- Copyright (C) 2006 by Jon S. Berndt, jsb@hal-pc.org -------------
+ ------------- Copyright (C) 2006 by Jon S. Berndt, jon@jsbsim.org -------------
 
  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU Lesser General Public License as published by the Free Software
@@ -39,18 +39,12 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGFCSComponent.h"
-#include <input_output/FGXMLElement.h>
-#include <string>
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_PID "$Id$"
-
-using std::string;
-
-using std::string;
+#define ID_PID "$Id: FGPID.h,v 1.13 2012/05/10 12:10:48 jberndt Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -59,6 +53,7 @@ FORWARD DECLARATIONS
 namespace JSBSim {
 
 class FGFCS;
+class Element;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DOCUMENTATION
@@ -69,26 +64,59 @@ CLASS DOCUMENTATION
 <h3>Configuration Format:</h3>
 
 @code
-<pid name="{string}">
-  <kp> {number} </kp>
-  <ki> {number} </ki>
-  <kd> {number} </kd>
-  <trigger> {string} </trigger>
+<pid name="{string}" [type="standard"]>
+  <kp> {number|property} </kp>
+  <ki> {number|property} </ki>
+  <kd> {number|property} </kd>
+  <trigger> {property} </trigger>
+</pid>
+@endcode
+
+For the integration constant element, one can also supply the type attribute for
+what kind of integrator to be used, one of:
+
+- rect, for a rectangular integrator
+- trap, for a trapezoidal integrator
+- ab2, for a second order Adams Bashforth integrator
+- ab3, for a third order Adams Bashforth integrator
+
+For example,
+
+@code
+<pid name="fcs/heading-control">
+  <kp> 3 </kp>
+  <ki type="ab3"> 1 </ki>
+  <kd> 1 </kd>
 </pid>
 @endcode
 
+
+
 <h3>Configuration Parameters:</h3>
 <pre>
 
+  The values of kp, ki, and kd have slightly different interpretations depending on
+  whether the PID controller is a standard one, or an ideal/parallel one - with the latter
+  being the default.
+  
   kp      - Proportional constant, default value 0.
   ki      - Integrative constant, default value 0.
   kd      - Derivative constant, default value 0.
-  trigger - Property which is used to sense wind-up, optional.
+  trigger - Property which is used to sense wind-up, optional. Most often, the trigger
+            will be driven by the "saturated" property of a particular actuator. When
+            the relevant actuator has reached it's limits (if there are any, specified
+            by the <clipto> element) the automatically generated saturated property will
+            be greater than zero (true). If this property is used as the trigger for the
+            integrator, the integrator will not continue to integrate while the property
+            is still true (> 1), preventing wind-up.
+  pvdot   - The property to be used as the process variable time derivative. 
+
+
 
 </pre>
 
     @author Jon S. Berndt
-    @version $Revision$
+    @version $Revision: 1.13 $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -104,18 +132,26 @@ public:
   bool Run (void);
   void ResetPastStates(void) {Input_prev = Input_prev2 = Output = I_out_total = 0.0;}
 
+    /// These define the indices use to select the various integrators.
+  enum eIntegrateType {eNone = 0, eRectEuler, eTrapezoidal, eAdamsBashforth2, eAdamsBashforth3};
+
 private:
-  double dt;
-  FGPropertyManager *Trigger;
   double Kp, Ki, Kd;
   double I_out_total;
   double Input_prev, Input_prev2;
   double KpPropertySign;
   double KiPropertySign;
   double KdPropertySign;
+
+  bool IsStandard;
+
+  eIntegrateType IntType;
+
+  FGPropertyManager *Trigger;
   FGPropertyManager* KpPropertyNode;
   FGPropertyManager* KiPropertyNode;
   FGPropertyManager* KdPropertyNode;
+  FGPropertyManager* ProcessVariableDot;
 
   void Debug(int from);
 };