1 /*******************************************************************************
7 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
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
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
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.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
27 --------------------------------------------------------------------------------
30 ********************************************************************************
32 *******************************************************************************/
37 /*******************************************************************************
38 COMMENTS, REFERENCES, and NOTES
39 *******************************************************************************/
41 The aerodynamic coefficients used in this model typically are:
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
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
60 Cyb - Side force due to sideslip
61 Cyr - Side force due to yaw rate
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)
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
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
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):
88 X-15.dat reset00 reset01 reset02 ...
102 F-16.dat reset00 reset01 ...
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
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>
137 /*******************************************************************************
139 *******************************************************************************/
142 # include <Include/compiler.h>
143 # ifdef FG_HAVE_STD_INCLUDES
146 # include <fstream.h>
153 #include "FGCoefficient.h"
154 #include "FGEngine.h"
157 /*******************************************************************************
159 *******************************************************************************/
161 /*******************************************************************************
163 *******************************************************************************/
165 class FGAircraft : public FGModel
168 // ***************************************************************************
169 /** @memo Constructor
170 @param FGFDMExec* - a pointer to the "owning" FDM Executive
172 FGAircraft(FGFDMExec*);
174 // ***************************************************************************
178 // ***************************************************************************
179 /** This must be called for each dt to execute the model algorithm */
182 // ***************************************************************************
183 /** This function must be called with the name of an aircraft which
184 has an associated .dat file in the appropriate subdirectory. The paths
185 to the appropriate subdirectories are given as the first two parameters.
186 @memo Loads the given aircraft.
187 @param string Path to the aircraft files
188 @param string Path to the engine files
189 @param string The name of the aircraft to be loaded, e.g. "X15".
190 @return True - if successful
192 bool LoadAircraft(string, string, string);
194 // ***************************************************************************
195 /** @memo Gets the aircraft name as defined in the aircraft config file.
197 @return string Aircraft name.
199 inline string GetAircraftName(void) {return AircraftName;}
201 // ***************************************************************************
202 /** @memo Sets the GearUp flag
203 @param boolean true or false
206 inline void SetGearUp(bool tt) {GearUp = tt;}
208 // ***************************************************************************
209 /** @memo Returns the state of the GearUp flag
211 @return boolean true or false
213 inline bool GetGearUp(void) {return GearUp;}
215 // ***************************************************************************
216 /** @memo Returns the area of the wing
218 @return float wing area S, in square feet
220 inline float GetWingArea(void) {return WingArea;}
222 // ***************************************************************************
223 /** @memo Returns the wing span
225 @return float wing span in feet
227 inline float GetWingSpan(void) {return WingSpan;}
229 // ***************************************************************************
230 /** @memo Returns the average wing chord
232 @return float wing chord in feet
234 inline float Getcbar(void) {return cbar;}
236 // ***************************************************************************
237 /** @memo Returns an engine object
238 @param int The engine number
239 @return FGEengine* The pointer to the requested engine object.
241 inline FGEngine* GetEngine(int tt) {return Engine[tt];}
243 // ***************************************************************************
248 inline FGTank* GetTank(int tt) {return Tank[tt];}
250 // ***************************************************************************
255 inline float GetWeight(void) {return Weight;}
257 // ***************************************************************************
262 inline float GetMass(void) {return Mass;}
264 // ***************************************************************************
269 inline float GetL(void) {return Moments[0];}
271 // ***************************************************************************
276 inline float GetM(void) {return Moments[1];}
278 // ***************************************************************************
283 inline float GetN(void) {return Moments[2];}
285 // ***************************************************************************
290 inline float GetFx(void) {return Forces[0];}
292 // ***************************************************************************
297 inline float GetFy(void) {return Forces[1];}
299 // ***************************************************************************
304 inline float GetFz(void) {return Forces[2];}
306 // ***************************************************************************
311 inline float GetIxx(void) {return Ixx;}
313 // ***************************************************************************
318 inline float GetIyy(void) {return Iyy;}
320 // ***************************************************************************
325 inline float GetIzz(void) {return Izz;}
327 // ***************************************************************************
332 inline float GetIxz(void) {return Ixz;}
335 // ***************************************************************************
342 // ***************************************************************************
349 // ***************************************************************************
356 // ***************************************************************************
363 // ***************************************************************************
370 // ***************************************************************************
377 // ***************************************************************************
384 // ***************************************************************************
391 // ***************************************************************************
398 // ***************************************************************************
405 // ***************************************************************************
410 void MassChange(void);
412 // ***************************************************************************
419 // ***************************************************************************
426 // ***************************************************************************
433 // ***************************************************************************
435 float Ixx, Iyy, Izz, Ixz, EmptyMass, Mass;
445 float WingArea, WingSpan, cbar;
449 float Weight, EmptyWeight;
458 int numSelectedOxiTanks;
460 int numSelectedFuelTanks;
462 FGTank* Tank[MAX_TANKS];
464 FGEngine *Engine[MAX_ENGINES];
467 FGCoefficient *Coeff[6][10];
475 enum Param {LiftCoeff,
490 /******************************************************************************/