]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGTrim.h
JSBSim updates. This update changes the file format, so an update of the base
[flightgear.git] / src / FDM / JSBSim / FGTrim.h
index 810e385d853407469958afe95365936b760daef3..0b207ec2033b279a122e445805ddb5b0c3d0f2ae 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
@@ -50,16 +52,6 @@ INCLUDES
 
 #include "FGFDMExec.h"
 #include "FGJSBBase.h"
-#include "FGRotation.h"
-#include "FGAtmosphere.h"
-#include "FGState.h"
-#include "FGFCS.h"
-#include "FGAircraft.h"
-#include "FGTranslation.h"
-#include "FGPosition.h"
-#include "FGAuxiliary.h"
-#include "FGOutput.h"
-#include "FGTrim.h"
 #include "FGTrimAxis.h"
 
 #include <vector>
@@ -70,9 +62,11 @@ DEFINITIONS
 
 #define ID_TRIM "$Id$"
 
-typedef enum { tLongitudinal, tFull, tGround, tCustom, tNone } TrimMode;
+typedef enum { tLongitudinal, tFull, tGround, tPullup, 
+               tCustom, tNone, tTurn 
+             } TrimMode;
 
-#ifdef _MSC_VER
+#ifdef _WIN32
 #define snprintf _snprintf
 #endif
 
@@ -105,12 +99,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 
@@ -134,6 +130,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>
 */       
   
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -145,10 +145,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;
@@ -161,9 +161,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;
@@ -180,15 +184,20 @@ private:
   bool findInterval(void);
 
   bool checkLimits(void);
+  
+  void setupPullup(void);
+  void setupTurn(void);
+  
+  void updateRates(void);
+
+  void setDebug(void);
 
 public:
   /** Initializes the trimming class
       @param FDMExec pointer to a JSBSim executive object.
       @param FGIC pointer to a FGInitialCondition object
-      @param TrimMode the set of axes to trim. Can be:
-             tLongitudinal, tFull, tGround, tCustom, or tNone
   */
-  FGTrim(FGFDMExec *FDMExec, FGInitialCondition *FGIC, TrimMode tt);
+  FGTrim(FGFDMExec *FDMExec, TrimMode tt=tGround );
 
     ~FGTrim(void);
 
@@ -206,6 +215,12 @@ public:
   /** Iteration statistics
   */
   void TrimStats();
+  
+  /** Clear all state-control pairs and set a predefined trim mode
+      @param TrimMode the set of axes to trim. Can be:
+             tLongitudinal, tFull, tGround, tCustom, or tNone
+  */
+  void SetMode(TrimMode tt);
 
   /** Clear all state-control pairs from the current configuration.
       The trimming routine must have at least one state-control pair
@@ -239,7 +254,7 @@ public:
       is not enough/too much thrust.
       @param gamma_fallback true to enable fallback
   */     
-  inline void SetGammaFallback(bool bb) { gamma_fallback=true; }
+  inline void SetGammaFallback(bool bb) { gamma_fallback=bb; }
   
   /** query the fallback state
       @return true if fallback is enabled.
@@ -270,10 +285,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; }
 
 };