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 [1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
83 Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
85 [2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
87 [3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
88 NASA-Ames", NASA CR-2497, January 1975
89 [4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
90 Wiley & Sons, 1979 ISBN 0-471-03032-5
91 [5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
92 1982 ISBN 0-471-08936-2
95 /*******************************************************************************
97 *******************************************************************************/
100 # include <simgear/compiler.h>
101 # ifdef FG_HAVE_STD_INCLUDES
107 # include <iterator.h>
117 #include "FGCoefficient.h"
118 #include "FGEngine.h"
121 #include "FGConfigFile.h"
122 #include "FGMatrix.h"
124 #define ID_AIRCRAFT "$Header$"
126 /*******************************************************************************
128 *******************************************************************************/
130 /** Encapsulates an Aircraft and its systems.
131 Owns all the parts (other classes) which make
132 up this aircraft. This includes the Engines, Tanks, Propellers, Nozzles,
133 aerodynamic and mass properties, landing gear, etc.
134 @author Jon S. Berndt
137 [1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
138 Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
140 [2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
142 [3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
143 NASA-Ames", NASA CR-2497, January 1975
144 [4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
145 Wiley & Sons, 1979 ISBN 0-471-03032-5
146 [5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
147 1982 ISBN 0-471-08936-2
150 /*******************************************************************************
152 *******************************************************************************/
154 class FGAircraft : public FGModel {
158 enum {ePhi=1, eTht, ePsi};
162 @param Executive a pointer to the parent executive object
164 FGAircraft(FGFDMExec *Executive);
169 /** Runs the model; called by the Executive
170 @see JSBSim.cpp documentation
171 @return bool returns false if no error
175 /** Loads the aircraft.
176 The executive calls this method to load the aircraft into JSBSim.
177 @param apath path to the aircraft files (e.g. "aircraft/X15/")
178 @param epath path to engine files (e.g. "engine/")
179 @param acname name of aircraft (e.g. "X15")
180 @return true if succesful
182 bool LoadAircraft(string apath, string epath, string acname);
184 /** Retrieves the aircraft name
185 @return the name of the aircraft as a string type
187 inline string GetAircraftName(void) { return AircraftName; }
189 inline void SetGearUp(bool tt) { GearUp = tt; }
190 inline bool GetGearUp(void) { return GearUp; }
191 inline int GetNumGearUnits(void) { return lGear.size(); }
192 inline FGLGear* GetGearUnit(int ii) { return &(lGear[ii]); }
193 inline float GetWingArea(void) { return WingArea; }
194 inline float GetWingSpan(void) { return WingSpan; }
195 inline float Getcbar(void) { return cbar; }
196 inline FGEngine* GetEngine(int tt) { return Engine[tt]; }
197 inline FGTank* GetTank(int tt) { return Tank[tt]; }
198 inline float GetWeight(void) { return Weight; }
199 inline float GetMass(void) { return Mass; }
200 inline FGColumnVector GetMoments(void) { return vMoments; }
201 inline FGColumnVector GetForces(void) { return vForces; }
202 inline FGColumnVector GetvFs(void) { return vFs; }
203 inline float GetIxx(void) { return Ixx; }
204 inline float GetIyy(void) { return Iyy; }
205 inline float GetIzz(void) { return Izz; }
206 inline float GetIxz(void) { return Ixz; }
207 inline unsigned int GetNumEngines(void) { return numEngines; }
208 inline FGColumnVector GetXYZcg(void) { return vXYZcg; }
209 inline FGColumnVector GetXYZrp(void) { return vXYZrp; }
210 inline FGColumnVector GetXYZep(void) { return vXYZep; }
211 inline float GetNlf(void) { return nlf; }
212 inline float GetAlphaCLMax(void) { return alphaclmax; }
213 inline float GetAlphaCLMin(void) { return alphaclmin; }
215 inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
216 inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
218 inline FGCoefficient* GetCoeff(int axis, int idx) { return Coeff[axis][idx]; }
219 string GetCoefficientStrings(void);
220 string GetCoefficientValues(void);
221 string GetGroundReactionStrings(void);
222 string GetGroundReactionValues(void);
224 enum { ssSimulation = 1,
232 ssCoefficients = 256,
234 ssGroundReactions = 1024 } subsystems;
242 void MassChange(void);
243 FGColumnVector vMoments;
244 FGColumnVector vForces;
246 FGColumnVector vXYZrp;
247 FGColumnVector vbaseXYZcg;
248 FGColumnVector vXYZcg;
249 FGColumnVector vXYZep;
250 FGColumnVector vEuler;
251 float baseIxx, baseIyy, baseIzz, baseIxz, EmptyMass, Mass;
252 float Ixx, Iyy, Izz, Ixz;
254 float WingArea, WingSpan, cbar;
255 float Weight, EmptyWeight;
256 float nlf,alphaclmax,alphaclmin;
261 unsigned int numTanks;
262 unsigned int numEngines;
263 unsigned int numSelectedOxiTanks;
264 unsigned int numSelectedFuelTanks;
265 FGTank* Tank[MAX_TANKS]; // need to make a vector
266 FGEngine *Engine[MAX_ENGINES]; // need to make a vector
268 typedef map<string,int> AxisIndex;
271 typedef vector<FGCoefficient*> CoeffArray;
275 void DisplayCoeffFactors(vector <eParam> multipliers);
280 vector <FGLGear> lGear;
284 void ReadMetrics(FGConfigFile*);
285 void ReadPropulsion(FGConfigFile*);
286 void ReadFlightControls(FGConfigFile*);
287 void ReadAerodynamics(FGConfigFile*);
288 void ReadUndercarriage(FGConfigFile*);
289 void ReadPrologue(FGConfigFile*);
290 void ReadOutput(FGConfigFile*);
293 /******************************************************************************/