]> git.mxchange.org Git - flightgear.git/blob - JSBsim/FGAircraft.h
9d403177d17c246f7f407850fa11489a33bbe1e1
[flightgear.git] / 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 #ifdef FGFS
141 #  include <Include/compiler.h>
142 #  ifdef FG_HAVE_STD_INCLUDES
143 #    include <fstream>
144 #  else
145 #    include <fstream.h>
146 #  endif
147 #else
148 #  include <fstream>
149 #endif
150
151 #include "FGModel.h"
152 #include "FGCoefficient.h"
153 #include "FGEngine.h"
154 #include "FGTank.h"
155
156 /*******************************************************************************
157 DEFINITIONS
158 *******************************************************************************/
159
160 /*******************************************************************************
161 CLASS DECLARATION
162 *******************************************************************************/
163
164 class FGAircraft : public FGModel
165 {
166 public:
167   // ***************************************************************************
168   /** @memo Constructor
169       @param FGFDMExec* - a pointer to the "owning" FDM Executive
170   */
171   FGAircraft(FGFDMExec*);
172   
173   // ***************************************************************************
174   /** Destructor */
175   ~FGAircraft(void);
176
177   // ***************************************************************************
178   /** This must be called for each dt to execute the model algorithm */
179   bool Run(void);
180
181   // ***************************************************************************
182   /** This function must be called with the name of an aircraft which
183       has an associated .dat file in the appropriate subdirectory. The
184       appropriate subdirectory is underneath the main fgfs binary directory
185       called "aircraft/{<i>aircraft</i>}/, where {<i>aircraft</i>} is the name of
186       specific aircraft you want to simulate.
187       @memo Loads the given aircraft.
188       @param string Path to the Aircraft files
189       @param string Path to the Engine files
190       @param string The name of the aircraft to be loaded, e.g. "X15".
191       @return True - if successful
192   */
193   bool LoadAircraft(string, string, string);
194
195   // ***************************************************************************
196   /** @memo Gets the aircraft name as defined in the aircraft config file.
197       @param
198       @return string Aircraft name.
199   */
200   inline string GetAircraftName(void) {return AircraftName;}
201
202   // ***************************************************************************
203   /** @memo Sets the GearUp flag
204       @param boolean true or false
205       @return
206   */
207   inline void SetGearUp(bool tt) {GearUp = tt;}
208
209   // ***************************************************************************
210   /** @memo Returns the state of the GearUp flag
211       @param
212       @return boolean true or false
213   */
214   inline bool GetGearUp(void) {return GearUp;}
215
216   // ***************************************************************************
217   /** @memo Returns the area of the wing
218       @param
219       @return float wing area S, in square feet
220   */
221   inline float GetWingArea(void) {return WingArea;}
222
223   // ***************************************************************************
224   /** @memo Returns the wing span
225       @param
226       @return float wing span in feet
227   */
228   inline float GetWingSpan(void) {return WingSpan;}
229
230   // ***************************************************************************
231   /** @memo Returns the average wing chord
232       @param
233       @return float wing chord in feet
234   */
235   inline float Getcbar(void) {return cbar;}
236
237   // ***************************************************************************
238   /** @memo Returns an engine object
239       @param int The engine number
240       @return FGEengine* The pointer to the requested engine object.
241   */
242   inline FGEngine* GetEngine(int tt) {return Engine[tt];}
243
244   // ***************************************************************************
245   /** @memo
246       @param
247       @return
248   */
249   inline FGTank* GetTank(int tt) {return Tank[tt];}
250
251   // ***************************************************************************
252   /** @memo
253       @param
254       @return
255   */
256   inline float GetWeight(void) {return Weight;}
257
258   // ***************************************************************************
259   /** @memo
260       @param
261       @return
262   */
263   inline float GetMass(void) {return Mass;}
264
265   // ***************************************************************************
266   /** @memo
267       @param
268       @return
269   */
270   inline float GetL(void) {return Moments[0];}
271
272   // ***************************************************************************
273   /** @memo
274       @param
275       @return
276   */
277   inline float GetM(void) {return Moments[1];}
278
279   // ***************************************************************************
280   /** @memo
281       @param
282       @return
283   */
284   inline float GetN(void) {return Moments[2];}
285
286   // ***************************************************************************
287   /** @memo
288       @param
289       @return
290   */
291   inline float GetFx(void) {return Forces[0];}
292
293   // ***************************************************************************
294   /** @memo
295       @param
296       @return
297   */
298   inline float GetFy(void) {return Forces[1];}
299
300   // ***************************************************************************
301   /** @memo
302       @param
303       @return
304   */
305   inline float GetFz(void) {return Forces[2];}
306
307   // ***************************************************************************
308   /** @memo
309       @param
310       @return
311   */
312   inline float GetIxx(void) {return Ixx;}
313
314   // ***************************************************************************
315   /** @memo
316       @param
317       @return
318   */
319   inline float GetIyy(void) {return Iyy;}
320
321   // ***************************************************************************
322   /** @memo
323       @param
324       @return
325   */
326   inline float GetIzz(void) {return Izz;}
327
328   // ***************************************************************************
329   /** @memo
330       @param
331       @return
332   */
333   inline float GetIxz(void) {return Ixz;}
334
335 private:
336   // ***************************************************************************
337   /** @memo
338       @param
339       @return
340   */
341   void GetState(void);
342
343   // ***************************************************************************
344   /** @memo
345       @param
346       @return
347   */
348   void PutState(void);
349
350   // ***************************************************************************
351   /** @memo
352       @param
353       @return
354   */
355   void FAero(void);
356
357   // ***************************************************************************
358   /** @memo
359       @param
360       @return
361   */
362   void FGear(void);
363
364   // ***************************************************************************
365   /** @memo
366       @param
367       @return
368   */
369   void FMass(void);
370
371   // ***************************************************************************
372   /** @memo
373       @param
374       @return
375   */
376   void FProp(void);
377
378   // ***************************************************************************
379   /** @memo
380       @param
381       @return
382   */
383   void MAero(void);
384
385   // ***************************************************************************
386   /** @memo
387       @param
388       @return
389   */
390   void MGear(void);
391
392   // ***************************************************************************
393   /** @memo
394       @param
395       @return
396   */
397   void MMass(void);
398
399   // ***************************************************************************
400   /** @memo
401       @param
402       @return
403   */
404   void MProp(void);
405
406   // ***************************************************************************
407   /** @memo
408       @param
409       @return
410   */
411   void MassChange(void);
412
413   // ***************************************************************************
414   /** @memo
415       @param
416       @return
417   */
418   float Moments[3];
419
420   // ***************************************************************************
421   /** @memo
422       @param
423       @return
424   */
425   float Forces[3];
426
427   // ***************************************************************************
428   /** @memo
429       @param
430       @return
431   */
432   string AircraftName;
433
434   // ***************************************************************************
435   ///
436   float Ixx, Iyy, Izz, Ixz, EmptyMass, Mass;
437   ///
438   float Xcg, Ycg, Zcg;
439   ///
440   float Xep, Yep, Zep;
441   ///
442   float rho, qbar, Vt;
443   ///
444   float alpha, beta;
445   ///
446   float WingArea, WingSpan, cbar;
447   ///
448   float phi, tht, psi;
449   ///
450   float Weight, EmptyWeight;
451   ///
452   float dt;
453
454   ///
455   int numTanks;
456   ///
457   int numEngines;
458   ///
459   int numSelectedOxiTanks;
460   ///
461   int numSelectedFuelTanks;
462   ///
463   FGTank* Tank[MAX_TANKS];
464   ///
465   FGEngine *Engine[MAX_ENGINES];
466
467   ///
468   FGCoefficient *Coeff[6][10];
469   ///
470   int coeff_ctr[6];
471
472   ///
473   bool GearUp;
474
475   ///
476   enum Param {LiftCoeff,
477               DragCoeff,
478               SideCoeff,
479               RollCoeff,
480               PitchCoeff,
481               YawCoeff,
482               numCoeffs};
483
484   ///
485   string Axis[6];
486
487 protected:
488
489 };
490
491 /******************************************************************************/
492 #endif