X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2FFGTrim.h;h=6d8069813705b390642b406414e2d1ab678930a3;hb=fbee3d10f0aafd4178fc1313edb8593c156b2874;hp=810e385d853407469958afe95365936b760daef3;hpb=ac50500e80decf3053526dd6538173203f54d61b;p=flightgear.git diff --git a/src/FDM/JSBSim/FGTrim.h b/src/FDM/JSBSim/FGTrim.h index 810e385d8..6d8069813 100644 --- a/src/FDM/JSBSim/FGTrim.h +++ b/src/FDM/JSBSim/FGTrim.h @@ -32,10 +32,12 @@ 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 @@ -70,19 +62,19 @@ DEFINITIONS #define ID_TRIM "$Id$" -typedef enum { tLongitudinal, tFull, tGround, tCustom, tNone } TrimMode; - -#ifdef _MSC_VER -#define snprintf _snprintf +#if defined(_WIN32) && !defined(__CYGWIN__) + #define snprintf _snprintf #endif /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FORWARD DECLARATIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs] -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +namespace JSBSim { + +typedef enum { tLongitudinal, tFull, tGround, tPullup, + tCustom, tNone, tTurn + } TrimMode; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLASS DOCUMENTATION @@ -101,28 +93,25 @@ CLASS DOCUMENTATION last three are used for on-ground trimming. The state-control pairs used in a given trim are completely user configurable and several pre-defined modes are provided as well. They are: - - 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 initial conditions: is the model capable of steady state flight at those conditions? Check the speed, altitude, configuration (flaps, gear, etc.), weight, cg, and anything else that may be relevant. - Example usage: + Example usage:
     FGFDMExec* FDMExec = new FGFDMExec();
-    .
-    .
-    .
+
     FGInitialCondition* fgic = new FGInitialCondition(FDMExec);
     FGTrim *fgt(FDMExec,fgic,tFull);
     fgic->SetVcaibratedKtsIC(100);
@@ -131,9 +120,9 @@ CLASS DOCUMENTATION
     if( !fgt->DoTrim() ) {
       cout << "Trim Failed" << endl;
     }
-    fgt->ReportState();  
+    fgt->ReportState(); 
@author Tony Peden - @version $Id$ + @version "$Id$" */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -145,10 +134,10 @@ class FGTrim : public FGJSBBase private: vector 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 +150,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,17 +173,22 @@ 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 + @param tm trim mode */ - FGTrim(FGFDMExec *FDMExec, FGInitialCondition *FGIC, TrimMode tt); + FGTrim(FGFDMExec *FDMExec, TrimMode tm=tGround ); - ~FGTrim(void); + ~FGTrim(void); /** Execute the trim */ @@ -206,6 +204,12 @@ public: /** Iteration statistics */ void TrimStats(); + + /** Clear all state-control pairs and set a predefined trim mode + @param tm the set of axes to trim. Can be: + tLongitudinal, tFull, tGround, tCustom, or tNone + */ + void SetMode(TrimMode tm); /** Clear all state-control pairs from the current configuration. The trimming routine must have at least one state-control pair @@ -230,16 +234,16 @@ public: /** Change the control used to zero a state previously configured @param state the accel or other condition to zero - @param control the control used to zero the state + @param new_control the control used to zero the state */ bool EditState( State state, Control new_control ); /** automatically switch to trimming longitudinal acceleration with flight path angle (gamma) once it becomes apparent that there is not enough/too much thrust. - @param gamma_fallback true to enable fallback + @param bb 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,21 +274,23 @@ 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; } }; - +} #endif - - - - - - - - -