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 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 # include <simgear/compiler.h>
43 # ifdef SG_HAVE_STD_INCLUDES
48 # include <iterator.h>
56 #include "FGPropulsion.h"
57 #include "FGConfigFile.h"
58 #include "FGMatrix33.h"
59 #include "FGColumnVector3.h"
60 #include "FGColumnVector4.h"
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 #define ID_AIRCRAFT "$Id$"
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
73 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 CL0 - Reference lift at zero alpha
79 CD0 - Reference drag at zero alpha
80 CDM - Drag due to Mach
81 CLa - Lift curve slope (w.r.t. alpha)
82 CDa - Drag curve slope (w.r.t. alpha)
83 CLq - Lift due to pitch rate
84 CLM - Lift due to Mach
85 CLadt - Lift due to alpha rate
87 Cmadt - Pitching Moment due to alpha rate
88 Cm0 - Reference Pitching moment at zero alpha
89 Cma - Pitching moment slope (w.r.t. alpha)
90 Cmq - Pitch damping (pitch moment due to pitch rate)
91 CmM - Pitch Moment due to Mach
94 Cyb - Side force due to sideslip
95 Cyr - Side force due to yaw rate
97 Clb - Dihedral effect (roll moment due to sideslip)
98 Clp - Roll damping (roll moment due to roll rate)
99 Clr - Roll moment due to yaw rate
100 Cnb - Weathercocking stability (yaw moment due to sideslip)
101 Cnp - Rudder adverse yaw (yaw moment due to roll rate)
102 Cnr - Yaw damping (yaw moment due to yaw rate)
105 CLDe - Lift due to elevator
106 CDDe - Drag due to elevator
107 CyDr - Side force due to rudder
108 CyDa - Side force due to aileron
110 CmDe - Pitch moment due to elevator
111 ClDa - Roll moment due to aileron
112 ClDr - Roll moment due to rudder
113 CnDr - Yaw moment due to rudder
114 CnDa - Yaw moment due to aileron
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
120 /** Encapsulates an Aircraft and its systems.
121 Owns all the parts (other classes) which make up this aircraft. This includes
122 the Engines, Tanks, Propellers, Nozzles, Aerodynamic and Mass properties,
123 landing gear, etc. These constituent parts may actually run as separate
124 JSBSim models themselves, but the responsibility for initializing them and
125 for retrieving their force and moment contributions falls to FGAircraft.<br>
126 When an aircraft model is loaded the config file is parsed and for each of the
127 sections of the config file (propulsion, flight control, etc.) the
128 corresponding "ReadXXX()" method is called. From within this method the
129 "Load()" method of that system is called (e.g. LoadFCS).
130 @author Jon S. Berndt
133 <ol><li>Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
134 Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
135 School, January 1994</li>
136 <li>D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
137 JSC 12960, July 1977</li>
138 <li>Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
139 NASA-Ames", NASA CR-2497, January 1975</li>
140 <li>Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
141 Wiley & Sons, 1979 ISBN 0-471-03032-5</li>
142 <li>Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
143 1982 ISBN 0-471-08936-2</li></ol>
146 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
150 class FGAircraft : public FGModel {
153 @param Executive a pointer to the parent executive object */
154 FGAircraft(FGFDMExec *Executive);
159 /** Runs the Aircraft model; called by the Executive
160 @see JSBSim.cpp documentation
161 @return false if no error */
164 /** Loads the aircraft.
165 The executive calls this method to load the aircraft into JSBSim.
166 @param AC_cfg a pointer to the config file instance
167 @return true if successful */
168 bool Load(FGConfigFile* AC_cfg);
170 /** Gets the aircraft name
171 @return the name of the aircraft as a string type */
172 inline string GetAircraftName(void) { return AircraftName; }
174 /// Gets the wing area
175 inline double GetWingArea(void) { return WingArea; }
176 /// Gets the wing span
177 inline double GetWingSpan(void) { return WingSpan; }
178 /// Gets the average wing chord
179 inline double Getcbar(void) { return cbar; }
180 inline double GetWingIncidence(void) { return WingIncidence; }
181 inline double GetHTailArea(void) { return HTailArea; }
182 inline double GetHTailArm(void) { return HTailArm; }
183 inline double GetVTailArea(void) { return VTailArea; }
184 inline double GetVTailArm(void) { return VTailArm; }
185 inline double Getlbarh(void) { return lbarh; } // HTailArm / cbar
186 inline double Getlbarv(void) { return lbarv; } // VTailArm / cbar
187 inline double Getvbarh(void) { return vbarh; } // H. Tail Volume
188 inline double Getvbarv(void) { return vbarv; } // V. Tail Volume
189 inline FGColumnVector3& GetMoments(void) { return vMoments; }
190 inline FGColumnVector3& GetForces(void) { return vForces; }
191 inline FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; }
192 inline FGColumnVector3& GetNcg (void) { return vNcg; }
193 inline FGColumnVector3& GetXYZrp(void) { return vXYZrp; }
194 inline FGColumnVector3& GetXYZep(void) { return vXYZep; }
195 inline double GetXYZrp(int idx) { return vXYZrp(idx); }
196 inline double GetXYZep(int idx) { return vXYZep(idx); }
197 inline double GetAlphaCLMax(void) { return alphaclmax; }
198 inline double GetAlphaCLMin(void) { return alphaclmin; }
200 inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
201 inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
203 inline bool GetStallWarn(void) { return impending_stall; }
206 FGColumnVector3 vMoments;
207 FGColumnVector3 vForces;
208 FGColumnVector3 vXYZrp;
209 FGColumnVector3 vXYZep;
210 FGColumnVector3 vEuler;
211 FGColumnVector3 vDXYZcg;
212 FGColumnVector3 vBodyAccel;
213 FGColumnVector3 vNcg;
215 double WingArea, WingSpan, cbar, WingIncidence;
216 double HTailArea, VTailArea, HTailArm, VTailArm;
217 double lbarh,lbarv,vbarh,vbarv;
218 double alphaclmax,alphaclmin;
219 double impending_stall;
223 void ReadMetrics(FGConfigFile*);
224 void ReadPropulsion(FGConfigFile*);
225 void ReadFlightControls(FGConfigFile*);
226 void ReadAerodynamics(FGConfigFile*);
227 void ReadUndercarriage(FGConfigFile*);
228 void ReadPrologue(FGConfigFile*);
229 void ReadOutput(FGConfigFile*);
233 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%