]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGTrim.h
Updated to match changes in radiostack.[ch]xx
[flightgear.git] / src / FDM / JSBSim / FGTrim.h
index acbff2fba9f3db3de5489906966c81d0574f08f3..105da8affa981001263d59642eb248132b3a3715 100644 (file)
 FUNCTIONAL DESCRIPTION
 --------------------------------------------------------------------------------
  
-This class takes the given set of IC's and finds the angle of attack, elevator,
-and throttle setting required to fly steady level. This is currently for in-air
-conditions only.  It is implemented using an iterative, one-axis-at-a-time 
-scheme.  
+This class takes the given set of IC's and finds the aircraft state required to
+maintain a specified flight condition.  This flight condition can be 
+steady-level with non-zero sideslip, a steady turn, a pull-up or pushover.
+On-ground conditions can be trimmed as well, but this is currently limited to
+adjusting altitude and pitch angle only. It is implemented using an iterative,
+one-axis-at-a-time scheme.  
  
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
@@ -70,7 +72,13 @@ DEFINITIONS
 
 #define ID_TRIM "$Id$"
 
-typedef enum { tLongitudinal, tFull, tGround, tCustom, tNone } TrimMode;
+typedef enum { tLongitudinal, tFull, tGround, tPullup, 
+               tCustom, tNone, tTurn 
+             } TrimMode;
+
+#ifdef _WIN32
+#define snprintf _snprintf
+#endif
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -101,12 +109,14 @@ CLASS DOCUMENTATION
     <li> tLongitudinal: Trim wdot with alpha, udot with thrust, qdot with elevator</li>
     <li> tFull: tLongitudinal + vdot with phi, pdot with aileron, rdot with rudder
                 and heading minus ground track (hmgt) with beta</li>
+    <li> tPullup: tLongitudinal but adjust alpha to achieve load factor input
+         with SetTargetNlf()
+
     <li> tGround: wdot with altitude, qdot with theta, and pdot with phi</li>
+    
     The remaining modes include <b>tCustom</b>, which is completely user defined and
     <b>tNone</b>.
     </ul>
-    Currently, this class cannot trim a non-1g condition and is limited to 
-    trimming for constant true airspeed in climbs and descents.
     
     Note that trims can (and do) fail for reasons that are completely outside
     the control of the trimming routine itself. The most common problem is the 
@@ -130,6 +140,10 @@ CLASS DOCUMENTATION
     fgt->ReportState();  
     @author Tony Peden
     @version $Id$
+    @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGTrim.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
+         Header File </a>
+    @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGTrim.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">
+         Source File </a>
 */       
   
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -141,10 +155,10 @@ class FGTrim : public FGJSBBase
 private:
 
   vector<FGTrimAxis*> TrimAxes;
-  int current_axis;
+  unsigned int current_axis;
   int N, Nsub;
   TrimMode mode;
-  int Debug;
+  int DebugLevel, Debug;
   double Tolerance, A_Tolerance;
   double wdot,udot,qdot;
   double dth;
@@ -157,9 +171,13 @@ private:
   bool trimudot;
   bool gamma_fallback;
   bool trim_failed;
-  int axis_count;
+  unsigned int axis_count;
   int solutionDomain;
   double xlo,xhi,alo,ahi;
+  double targetNlf;
+  int debug_axis;
+  
+  double psidot,thetadot;
 
   FGFDMExec* fdmex;
   FGInitialCondition* fgic;
@@ -176,6 +194,13 @@ private:
   bool findInterval(void);
 
   bool checkLimits(void);
+  
+  void setupPullup(void);
+  void setupTurn(void);
+  
+  void updateRates(void);
+
+  void setDebug(void);
 
 public:
   /** Initializes the trimming class
@@ -266,10 +291,21 @@ public:
     A_Tolerance = tt / 10;
   }
   
-  //Debug level 1 shows results of each top-level iteration
-  //Debug level 2 shows level 1 & results of each per-axis iteration
-  inline void SetDebug(int level) { Debug = level; }
-  inline void ClearDebug(void) { Debug = 0; }
+  /** 
+    Debug level 1 shows results of each top-level iteration
+    Debug level 2 shows level 1 & results of each per-axis iteration
+  */  
+  inline void SetDebug(int level) { DebugLevel = level; }
+  inline void ClearDebug(void) { DebugLevel = 0; }
+  
+  /**
+    Output debug data for one of the axes
+    The State enum is defined in FGTrimAxis.h
+  */  
+  inline void DebugState(State state) { debug_axis=state; }
+  
+  inline void SetTargetNlf(float nlf) { targetNlf=nlf; }
+  inline double GetTargetNlf(void) { return targetNlf; }
 
 };