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 gear status
175 @return true if gear is not deployed */
176 inline bool GetGearUp(void) { return GearUp; }
177 /** Gets the number of gear units defined for the aircraft
178 @return number of gear units defined */
179 inline int GetNumGearUnits(void) { return lGear.size(); }
180 /** Gets a gear instance
181 @param gear index of gear instance
182 @return a pointer to the FGLGear instance of the gear unit requested */
183 inline FGLGear* GetGearUnit(int gear) { return &(lGear[gear]); }
184 /// Gets the wing area
185 inline float GetWingArea(void) { return WingArea; }
186 /// Gets the wing span
187 inline float GetWingSpan(void) { return WingSpan; }
188 /// Gets the average wing chord
189 inline float Getcbar(void) { return cbar; }
190 inline float GetWingIncidence(void) { return WingIncidence; }
191 inline float GetHTailArea(void) { return HTailArea; }
192 inline float GetHTailArm(void) { return HTailArm; }
193 inline float GetVTailArea(void) { return VTailArea; }
194 inline float GetVTailArm(void) { return VTailArm; }
195 inline float Getlbarh(void) { return lbarh; } // HTailArm / cbar
196 inline float Getlbarv(void) { return lbarv; } // VTailArm / cbar
197 inline float Getvbarh(void) { return vbarh; } // H. Tail Volume
198 inline float Getvbarv(void) { return vbarv; } // V. Tail Volume
199 inline FGColumnVector3& GetMoments(void) { return vMoments; }
200 inline FGColumnVector3& GetForces(void) { return vForces; }
201 inline FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; }
202 inline FGColumnVector3& GetXYZrp(void) { return vXYZrp; }
203 inline FGColumnVector3& GetXYZep(void) { return vXYZep; }
204 inline float GetXYZrp(int idx) { return vXYZrp(idx); }
205 inline float GetXYZep(int idx) { return vXYZep(idx); }
206 inline float GetAlphaCLMax(void) { return alphaclmax; }
207 inline float GetAlphaCLMin(void) { return alphaclmin; }
209 inline void SetGear(bool tt) { GearUp = tt; }
210 inline void SetGearUp(void) { GearUp = true; }
211 inline void SetGearDown(bool tt) { GearUp = false; }
212 inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
213 inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
215 /// Subsystem types for specifying which will be output in the FDM data logging
217 /** Subsystem: Simulation (= 1) */ ssSimulation = 1,
218 /** Subsystem: Aerosurfaces (= 2) */ ssAerosurfaces = 2,
219 /** Subsystem: Body rates (= 4) */ ssRates = 4,
220 /** Subsystem: Velocities (= 8) */ ssVelocities = 8,
221 /** Subsystem: Forces (= 16) */ ssForces = 16,
222 /** Subsystem: Moments (= 32) */ ssMoments = 32,
223 /** Subsystem: Atmosphere (= 64) */ ssAtmosphere = 64,
224 /** Subsystem: Mass Properties (= 128) */ ssMassProps = 128,
225 /** Subsystem: Coefficients (= 256) */ ssCoefficients = 256,
226 /** Subsystem: Position (= 512) */ ssPosition = 512,
227 /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
228 /** Subsystem: FCS (= 2048) */ ssFCS = 2048,
229 /** Subsystem: Propulsion (= 4096) */ ssPropulsion = 4096
233 FGColumnVector3 vMoments;
234 FGColumnVector3 vForces;
235 FGColumnVector3 vXYZrp;
236 FGColumnVector3 vXYZep;
237 FGColumnVector3 vEuler;
238 FGColumnVector3 vDXYZcg;
239 FGColumnVector3 vBodyAccel;
240 float WingArea, WingSpan, cbar, WingIncidence;
241 float HTailArea, VTailArea, HTailArm, VTailArm;
242 float lbarh,lbarv,vbarh,vbarv;
243 float alphaclmax,alphaclmin;
249 vector <FGLGear> lGear;
251 void ReadMetrics(FGConfigFile*);
252 void ReadPropulsion(FGConfigFile*);
253 void ReadFlightControls(FGConfigFile*);
254 void ReadAerodynamics(FGConfigFile*);
255 void ReadUndercarriage(FGConfigFile*);
256 void ReadPrologue(FGConfigFile*);
257 void ReadOutput(FGConfigFile*);
261 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%