]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGTrim.h
Sync with current JSBSim devel code.
[flightgear.git] / src / FDM / JSBSim / FGTrim.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2  
3  Header:       FGTrim.h
4  Author:       Tony Peden
5  Date started: 7/1/99
6  
7  ------------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) -------------
8  
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13  
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  details.
18  
19  You should have received a copy of the GNU General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22  
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25  
26  
27  HISTORY
28 --------------------------------------------------------------------------------
29 9/8/99   TP   Created
30  
31  
32 FUNCTIONAL DESCRIPTION
33 --------------------------------------------------------------------------------
34  
35 This class takes the given set of IC's and finds the angle of attack, elevator,
36 and throttle setting required to fly steady level. This is currently for in-air
37 conditions only.  It is implemented using an iterative, one-axis-at-a-time 
38 scheme.  
39  
40  
41  
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 SENTRY
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45
46 #ifndef FGTRIM_H
47 #define FGTRIM_H
48
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 INCLUDES
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53 #include "FGFDMExec.h"
54 #include "FGRotation.h"
55 #include "FGAtmosphere.h"
56 #include "FGState.h"
57 #include "FGFCS.h"
58 #include "FGAircraft.h"
59 #include "FGTranslation.h"
60 #include "FGPosition.h"
61 #include "FGAuxiliary.h"
62 #include "FGOutput.h"
63 #include "FGTrim.h"
64 #include "FGTrimAxis.h"
65
66 #include <vector.h>
67
68 #define ID_TRIM "$Header"
69
70 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 CLASS DECLARATION
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
73
74 typedef enum { tLongitudinal, tFull, tGround } TrimMode;
75
76 class FGTrim {
77 private:
78
79   vector<FGTrimAxis*> TrimAxes;
80   int current_axis;
81   int N, Nsub;
82   int NumAxes;
83   TrimMode mode;
84   int Debug;
85   float Tolerance, A_Tolerance;
86   float wdot,udot,qdot;
87   float dth;
88   float *sub_iterations;
89   float *successful;
90   bool *solution;
91   int max_sub_iterations;
92   int max_iterations;
93   int total_its;
94   bool trimudot;
95   bool gamma_fallback;
96   bool trim_failed;
97   int axis_count;
98   int solutionDomain;
99   float xlo,xhi,alo,ahi;
100
101
102   FGFDMExec* fdmex;
103   FGInitialCondition* fgic;
104
105   // returns false if there is no change in the current axis accel
106   // between accel(control_min) and accel(control_max). if there is a
107   // change, sets solutionDomain to:
108   // 0 for no sign change,
109   // -1 if sign change between accel(control_min) and accel(0)
110   // 1 if sign between accel(0) and accel(control_max)
111   bool solve(void);
112   bool findInterval(void);
113   bool checkLimits(void);
114
115 public:
116   FGTrim(FGFDMExec *FDMExec, FGInitialCondition *FGIC, TrimMode tt);
117   ~FGTrim(void);
118
119   bool DoTrim(void);
120
121   void Report(void);
122   void ReportState(void);
123   void TrimStats();
124
125   inline void SetUdotTrim(bool bb) { trimudot=bb; }
126   inline bool GetUdotTrim(void) { return trimudot; }
127
128   inline void SetGammaFallback(bool bb) { gamma_fallback=true; }
129   inline bool GetGammaFallback(void) { return gamma_fallback; }
130
131   inline void SetMaxCycles(int ii) { max_iterations = ii; }
132   inline void SetMaxCyclesPerAxis(int ii) { max_sub_iterations = ii; }
133   inline void SetTolerance(float tt) {
134     Tolerance = tt;
135     A_Tolerance = tt / 10;
136   }
137   //Debug level 1 shows results of each top-level iteration
138   //Debug level 2 shows level 1 & results of each per-axis iteration
139   inline void SetDebug(int level) { Debug = level; }
140   inline void ClearDebug(void) { Debug = 0; }
141
142 };
143
144
145 #endif
146
147
148
149
150
151
152
153
154