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 float GetWingArea(void) { return WingArea; }
176 /// Gets the wing span
177 inline float GetWingSpan(void) { return WingSpan; }
178 /// Gets the average wing chord
179 inline float Getcbar(void) { return cbar; }
180 inline float GetWingIncidence(void) { return WingIncidence; }
181 inline float GetHTailArea(void) { return HTailArea; }
182 inline float GetHTailArm(void) { return HTailArm; }
183 inline float GetVTailArea(void) { return VTailArea; }
184 inline float GetVTailArm(void) { return VTailArm; }
185 inline float Getlbarh(void) { return lbarh; } // HTailArm / cbar
186 inline float Getlbarv(void) { return lbarv; } // VTailArm / cbar
187 inline float Getvbarh(void) { return vbarh; } // H. Tail Volume
188 inline float 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 float GetXYZrp(int idx) { return vXYZrp(idx); }
196 inline float GetXYZep(int idx) { return vXYZep(idx); }
197 inline float GetAlphaCLMax(void) { return alphaclmax; }
198 inline float GetAlphaCLMin(void) { return alphaclmin; }
200 inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
201 inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
203 inline bool GetStallWarn(void) { return impending_stall; }
205 /// Subsystem types for specifying which will be output in the FDM data logging
207 /** Subsystem: Simulation (= 1) */ ssSimulation = 1,
208 /** Subsystem: Aerosurfaces (= 2) */ ssAerosurfaces = 2,
209 /** Subsystem: Body rates (= 4) */ ssRates = 4,
210 /** Subsystem: Velocities (= 8) */ ssVelocities = 8,
211 /** Subsystem: Forces (= 16) */ ssForces = 16,
212 /** Subsystem: Moments (= 32) */ ssMoments = 32,
213 /** Subsystem: Atmosphere (= 64) */ ssAtmosphere = 64,
214 /** Subsystem: Mass Properties (= 128) */ ssMassProps = 128,
215 /** Subsystem: Coefficients (= 256) */ ssCoefficients = 256,
216 /** Subsystem: Position (= 512) */ ssPosition = 512,
217 /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
218 /** Subsystem: FCS (= 2048) */ ssFCS = 2048,
219 /** Subsystem: Propulsion (= 4096) */ ssPropulsion = 4096
223 FGColumnVector3 vMoments;
224 FGColumnVector3 vForces;
225 FGColumnVector3 vXYZrp;
226 FGColumnVector3 vXYZep;
227 FGColumnVector3 vEuler;
228 FGColumnVector3 vDXYZcg;
229 FGColumnVector3 vBodyAccel;
230 FGColumnVector3 vNcg;
232 float WingArea, WingSpan, cbar, WingIncidence;
233 float HTailArea, VTailArea, HTailArm, VTailArm;
234 float lbarh,lbarv,vbarh,vbarv;
235 float alphaclmax,alphaclmin;
236 float impending_stall;
240 void ReadMetrics(FGConfigFile*);
241 void ReadPropulsion(FGConfigFile*);
242 void ReadFlightControls(FGConfigFile*);
243 void ReadAerodynamics(FGConfigFile*);
244 void ReadUndercarriage(FGConfigFile*);
245 void ReadPrologue(FGConfigFile*);
246 void ReadOutput(FGConfigFile*);
250 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%