]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAircraft.h
Initial revision
[flightgear.git] / src / FDM / JSBSim / FGAircraft.h
1 /*******************************************************************************
2
3  Header:       FGAircraft.h
4  Author:       Jon S. Berndt
5  Date started: 12/12/98
6
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
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 HISTORY
27 --------------------------------------------------------------------------------
28 12/12/98   JSB   Created
29
30 ********************************************************************************
31 SENTRY
32 *******************************************************************************/
33
34 #ifndef FGAIRCRAFT_H
35 #define FGAIRCRAFT_H
36
37 /*******************************************************************************
38 COMMENTS, REFERENCES,  and NOTES
39 *******************************************************************************/
40 /**
41 The aerodynamic coefficients used in this model typically are:
42 <PRE>
43 <b>Longitudinal</b>
44   CL0 - Reference lift at zero alpha
45   CD0 - Reference drag at zero alpha
46   CDM - Drag due to Mach
47   CLa - Lift curve slope (w.r.t. alpha)
48   CDa - Drag curve slope (w.r.t. alpha)
49   CLq - Lift due to pitch rate
50   CLM - Lift due to Mach
51   CLadt - Lift due to alpha rate
52
53   Cmadt - Pitching Moment due to alpha rate
54   Cm0 - Reference Pitching moment at zero alpha
55   Cma - Pitching moment slope (w.r.t. alpha)
56   Cmq - Pitch damping (pitch moment due to pitch rate)
57   CmM - Pitch Moment due to Mach
58
59 <b>Lateral</b>
60   Cyb - Side force due to sideslip
61   Cyr - Side force due to yaw rate
62
63   Clb - Dihedral effect (roll moment due to sideslip)
64   Clp - Roll damping (roll moment due to roll rate)
65   Clr - Roll moment due to yaw rate
66   Cnb - Weathercocking stability (yaw moment due to sideslip)
67   Cnp - Rudder adverse yaw (yaw moment due to roll rate)
68   Cnr - Yaw damping (yaw moment due to yaw rate)
69
70 <b>Control</b>
71   CLDe - Lift due to elevator
72   CDDe - Drag due to elevator
73   CyDr - Side force due to rudder
74   CyDa - Side force due to aileron
75
76   CmDe - Pitch moment due to elevator
77   ClDa - Roll moment due to aileron
78   ClDr - Roll moment due to rudder
79   CnDr - Yaw moment due to rudder
80   CnDa - Yaw moment due to aileron
81 </PRE>
82 This class expects to be run in a directory which contains the subdirectory
83 structure shown below (where example aircraft X-15 is shown):
84
85 <PRE>
86 aircraft/
87   X-15/
88     X-15.dat reset00 reset01 reset02 ...
89       CDRAG/
90         a0 a M De
91       CSIDE/
92         b r Dr Da
93       CLIFT/
94         a0 a M adt De
95       CROLL/
96         b p r Da Dr
97       CPITCH/
98         a0 a adt q M De
99       CYAW/
100         b p r Dr Da
101   F-16/
102     F-16.dat reset00 reset01 ...
103       CDRAG/
104         a0 a M De
105       ...
106 </PRE>
107
108 The General Idea
109
110 The file structure is arranged so that various modeled aircraft are stored in
111 their own subdirectory. Each aircraft subdirectory is named after the aircraft.
112 There should be a file present in the specific aircraft subdirectory (e.g.
113 aircraft/X-15) with the same name as the directory with a .dat appended. This
114 file contains mass properties information, name of aircraft, etc. for the
115 aircraft. In that same directory are reset files numbered starting from 0 (two
116 digit numbers), e.g. reset03. Within each reset file are values for important
117 state variables for specific flight conditions (altitude, airspeed, etc.). Also
118 within this directory are the directories containing lookup tables for the
119 stability derivatives for the aircraft.
120 @author Jon S. Berndt
121 @memo  Encompasses all aircraft functionality and objects
122 @see <ll>
123 <li>[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
124          Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
125          School, January 1994</li>
126 <li>[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
127          JSC 12960, July 1977</li>
128 <li>[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
129          NASA-Ames", NASA CR-2497, January 1975</li>
130 <li>[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
131          Wiley & Sons, 1979 ISBN 0-471-03032-5</li>
132 <li>[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
133          1982 ISBN 0-471-08936-2</li>
134 </ll>
135 */
136
137 /*******************************************************************************
138 INCLUDES
139 *******************************************************************************/
140
141 #ifdef FGFS
142 #  include <Include/compiler.h>
143 #  ifdef FG_HAVE_STD_INCLUDES
144 #    include <fstream>
145 #  else
146 #    include <fstream.h>
147 #  endif
148 #  include STL_STRING
149    FG_USING_STD(string);
150 #else
151 #  include <fstream>
152 #endif
153
154 #include "FGModel.h"
155 #include "FGCoefficient.h"
156 #include "FGEngine.h"
157 #include "FGTank.h"
158
159 /*******************************************************************************
160 DEFINITIONS
161 *******************************************************************************/
162
163 #ifndef FGFS
164 using namespace std;
165 #endif
166
167 /*******************************************************************************
168 CLASS DECLARATION
169 *******************************************************************************/
170
171 class FGAircraft : public FGModel
172 {
173 public:
174   // ***************************************************************************
175   /** @memo Constructor
176       @param FGFDMExec* - a pointer to the "owning" FDM Executive
177   */
178   FGAircraft(FGFDMExec*);
179   
180   // ***************************************************************************
181   /** Destructor */
182   ~FGAircraft(void);
183
184   // ***************************************************************************
185   /** This must be called for each dt to execute the model algorithm */
186   bool Run(void);
187
188   // ***************************************************************************
189   /** This function must be called with the name of an aircraft which
190       has an associated .dat file in the appropriate subdirectory. The paths
191       to the appropriate subdirectories are given as the first two parameters.
192       @memo Loads the given aircraft.
193       @param string Path to the aircraft files
194       @param string Path to the engine files
195       @param string The name of the aircraft to be loaded, e.g. "X15".
196       @return True - if successful
197   */
198   bool LoadAircraft(string, string, string);
199
200   // ***************************************************************************
201   /** This function must be called with the name of an aircraft which
202       has an associated .dat file in the appropriate subdirectory. The paths
203       to the appropriate subdirectories are given as the first two parameters.
204       @memo Loads the given aircraft.
205       @param string Path to the aircraft files
206       @param string Path to the engine files
207       @param string The name of the aircraft to be loaded, e.g. "X15".
208       @return True - if successful
209   */
210   bool LoadAircraftEx(string, string, string);
211
212   // ***************************************************************************
213   /** @memo Gets the aircraft name as defined in the aircraft config file.
214       @param
215       @return string Aircraft name.
216   */
217   inline string GetAircraftName(void) {return AircraftName;}
218
219   // ***************************************************************************
220   /** @memo Sets the GearUp flag
221       @param boolean true or false
222       @return
223   */
224   inline void SetGearUp(bool tt) {GearUp = tt;}
225
226   // ***************************************************************************
227   /** @memo Returns the state of the GearUp flag
228       @param
229       @return boolean true or false
230   */
231   inline bool GetGearUp(void) {return GearUp;}
232
233   // ***************************************************************************
234   /** @memo Returns the area of the wing
235       @param
236       @return float wing area S, in square feet
237   */
238   inline float GetWingArea(void) {return WingArea;}
239
240   // ***************************************************************************
241   /** @memo Returns the wing span
242       @param
243       @return float wing span in feet
244   */
245   inline float GetWingSpan(void) {return WingSpan;}
246
247   // ***************************************************************************
248   /** @memo Returns the average wing chord
249       @param
250       @return float wing chord in feet
251   */
252   inline float Getcbar(void) {return cbar;}
253
254   // ***************************************************************************
255   /** @memo Returns an engine object
256       @param int The engine number
257       @return FGEengine* The pointer to the requested engine object.
258   */
259   inline FGEngine* GetEngine(int tt) {return Engine[tt];}
260
261   // ***************************************************************************
262   /** @memo
263       @param
264       @return
265   */
266   inline FGTank* GetTank(int tt) {return Tank[tt];}
267
268   // ***************************************************************************
269   /** @memo
270       @param
271       @return
272   */
273   inline float GetWeight(void) {return Weight;}
274
275   // ***************************************************************************
276   /** @memo
277       @param
278       @return
279   */
280   inline float GetMass(void) {return Mass;}
281
282   // ***************************************************************************
283   /** @memo
284       @param
285       @return
286   */
287   inline float GetL(void) {return Moments[0];}
288
289   // ***************************************************************************
290   /** @memo
291       @param
292       @return
293   */
294   inline float GetM(void) {return Moments[1];}
295
296   // ***************************************************************************
297   /** @memo
298       @param
299       @return
300   */
301   inline float GetN(void) {return Moments[2];}
302
303   // ***************************************************************************
304   /** @memo
305       @param
306       @return
307   */
308   inline float GetFx(void) {return Forces[0];}
309
310   // ***************************************************************************
311   /** @memo
312       @param
313       @return
314   */
315   inline float GetFy(void) {return Forces[1];}
316
317   // ***************************************************************************
318   /** @memo
319       @param
320       @return
321   */
322   inline float GetFz(void) {return Forces[2];}
323
324   // ***************************************************************************
325   /** @memo
326       @param
327       @return
328   */
329   inline float GetIxx(void) {return Ixx;}
330
331   // ***************************************************************************
332   /** @memo
333       @param
334       @return
335   */
336   inline float GetIyy(void) {return Iyy;}
337
338   // ***************************************************************************
339   /** @memo
340       @param
341       @return
342   */
343   inline float GetIzz(void) {return Izz;}
344
345   // ***************************************************************************
346   /** @memo
347       @param
348       @return
349   */
350   inline float GetIxz(void) {return Ixz;}
351
352 private:
353   // ***************************************************************************
354   /** @memo
355       @param
356       @return
357   */
358   void GetState(void);
359
360   // ***************************************************************************
361   /** @memo
362       @param
363       @return
364   */
365   void PutState(void);
366
367   // ***************************************************************************
368   /** @memo
369       @param
370       @return
371   */
372   void FAero(void);
373
374   // ***************************************************************************
375   /** @memo
376       @param
377       @return
378   */
379   void FGear(void);
380
381   // ***************************************************************************
382   /** @memo
383       @param
384       @return
385   */
386   void FMass(void);
387
388   // ***************************************************************************
389   /** @memo
390       @param
391       @return
392   */
393   void FProp(void);
394
395   // ***************************************************************************
396   /** @memo
397       @param
398       @return
399   */
400   void MAero(void);
401
402   // ***************************************************************************
403   /** @memo
404       @param
405       @return
406   */
407   void MGear(void);
408
409   // ***************************************************************************
410   /** @memo
411       @param
412       @return
413   */
414   void MMass(void);
415
416   // ***************************************************************************
417   /** @memo
418       @param
419       @return
420   */
421   void MProp(void);
422
423   // ***************************************************************************
424   /** @memo
425       @param
426       @return
427   */
428   void MassChange(void);
429
430   // ***************************************************************************
431   /** @memo
432       @param
433       @return
434   */
435   float Moments[3];
436
437   // ***************************************************************************
438   /** @memo
439       @param
440       @return
441   */
442   float Forces[3];
443
444   // ***************************************************************************
445   /** @memo
446       @param
447       @return
448   */
449   string AircraftName;
450
451   // ***************************************************************************
452   ///
453   float Ixx, Iyy, Izz, Ixz, EmptyMass, Mass;
454   ///
455   float Xcg, Ycg, Zcg;
456   ///
457   float Xep, Yep, Zep;
458   ///
459   float rho, qbar, Vt;
460   ///
461   float alpha, beta;
462   ///
463   float WingArea, WingSpan, cbar;
464   ///
465   float phi, tht, psi;
466   ///
467   float Weight, EmptyWeight;
468   ///
469   float dt;
470
471   ///
472   int numTanks;
473   ///
474   int numEngines;
475   ///
476   int numSelectedOxiTanks;
477   ///
478   int numSelectedFuelTanks;
479   ///
480   FGTank* Tank[MAX_TANKS];
481   ///
482   FGEngine *Engine[MAX_ENGINES];
483
484   ///
485   FGCoefficient *Coeff[6][10];
486   ///
487   int coeff_ctr[6];
488
489   ///
490   bool GearUp;
491
492   ///
493   enum Param {LiftCoeff,
494               DragCoeff,
495               SideCoeff,
496               RollCoeff,
497               PitchCoeff,
498               YawCoeff,
499               numCoeffs};
500
501   ///
502   string Axis[6];
503
504 protected:
505
506 };
507
508 /******************************************************************************/
509 #endif