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
49 # include <iterator.h>
59 #include "FGPropulsion.h"
60 #include "FGConfigFile.h"
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68 #define ID_AIRCRAFT "$Id$"
70 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
74 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
78 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
82 /** Encapsulates an Aircraft and its systems.
83 Owns all the parts (other classes) which make up this aircraft. This includes
84 the Engines, Tanks, Propellers, Nozzles, Aerodynamic and Mass properties,
85 landing gear, etc. These constituent parts may actually run as separate
86 JSBSim models themselves, but the responsibility for initializing them and
87 for retrieving their force and moment contributions falls to FGAircraft.<br>
88 When an aircraft model is loaded the config file is parsed and for each of the
89 sections of the config file (propulsion, flight control, etc.) the
90 corresponding "ReadXXX()" method is called. From within this method the
91 "Load()" method of that system is called (e.g. LoadFCS).
95 <ol><li>Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
96 Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
97 School, January 1994</li>
98 <li>D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
99 JSC 12960, July 1977</li>
100 <li>Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
101 NASA-Ames", NASA CR-2497, January 1975</li>
102 <li>Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
103 Wiley & Sons, 1979 ISBN 0-471-03032-5</li>
104 <li>Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
105 1982 ISBN 0-471-08936-2</li></ol>
108 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
112 class FGAircraft : public FGModel {
116 enum {ePhi=1, eTht, ePsi};
120 @param Executive a pointer to the parent executive object */
121 FGAircraft(FGFDMExec *Executive);
126 /** Runs the Aircraft model; called by the Executive
127 @see JSBSim.cpp documentation
128 @return false if no error */
131 /** Loads the aircraft.
132 The executive calls this method to load the aircraft into JSBSim.
133 @param apath path to the aircraft files (e.g. "aircraft/X15/")
134 @param epath path to engine files (e.g. "engine/")
135 @param acname name of aircraft (e.g. "X15")
136 @return true if succesful */
137 bool LoadAircraft(string apath, string epath, string acname);
139 /** Gets the aircraft name
140 @return the name of the aircraft as a string type */
141 inline string GetAircraftName(void) { return AircraftName; }
143 /** Gets the gear status
144 @return true if gear is not deployed */
145 inline bool GetGearUp(void) { return GearUp; }
146 /** Gets the number of gear units defined for the aircraft
147 @return number of gear units defined */
148 inline int GetNumGearUnits(void) { return lGear.size(); }
149 /** Gets a gear instance
150 @param gear index of gear instance
151 @return a pointer to the FGLGear instance of the gear unit requested */
152 inline FGLGear* GetGearUnit(int gear) { return &(lGear[gear]); }
153 /// Gets the wing area
154 inline float GetWingArea(void) { return WingArea; }
155 /// Gets the wing span
156 inline float GetWingSpan(void) { return WingSpan; }
157 /// Gets the average wing chord
158 inline float Getcbar(void) { return cbar; }
159 inline FGColumnVector GetMoments(void) { return vMoments; }
160 inline FGColumnVector GetForces(void) { return vForces; }
161 inline FGColumnVector GetAeroBodyForces(void) { return vAeroBodyForces; }
162 inline float GetAeroBodyForces(int axis) { return vAeroBodyForces(axis); }
163 inline FGColumnVector GetXYZrp(void) { return vXYZrp; }
164 inline FGColumnVector GetXYZep(void) { return vXYZep; }
165 inline float GetXYZrp(int idx) { return vXYZrp(idx); }
166 inline float GetXYZep(int idx) { return vXYZep(idx); }
167 inline float GetAlphaCLMax(void) { return alphaclmax; }
168 inline float GetAlphaCLMin(void) { return alphaclmin; }
170 inline void SetGearUp(bool tt) { GearUp = tt; }
171 inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
172 inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
174 string GetGroundReactionStrings(void);
175 string GetGroundReactionValues(void);
179 /// Subsystem types for specifying which will be output in the FDM data logging
181 /** Subsystem: Simulation (= 1) */ ssSimulation = 1,
182 /** Subsystem: Aerosurfaces (= 2) */ ssAerosurfaces = 2,
183 /** Subsystem: Body rates (= 4) */ ssRates = 4,
184 /** Subsystem: Velocities (= 8) */ ssVelocities = 8,
185 /** Subsystem: Forces (= 16) */ ssForces = 16,
186 /** Subsystem: Moments (= 32) */ ssMoments = 32,
187 /** Subsystem: Atmosphere (= 64) */ ssAtmosphere = 64,
188 /** Subsystem: Mass Properties (= 128) */ ssMassProps = 128,
189 /** Subsystem: Coefficients (= 256) */ ssCoefficients = 256,
190 /** Subsystem: Position (= 512) */ ssPosition = 512,
191 /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
192 /** Subsystem: FCS (= 2048) */ ssFCS = 2048,
193 /** Subsystem: Propulsion (= 4096) */ ssPropulsion = 4096
202 FGColumnVector vMoments;
203 FGColumnVector vForces;
204 FGColumnVector vXYZrp;
205 FGColumnVector vXYZep;
206 FGColumnVector vEuler;
207 FGColumnVector vDXYZcg;
208 FGColumnVector vAeroBodyForces;
210 float WingArea, WingSpan, cbar;
211 float alphaclmax,alphaclmin;
218 vector <FGLGear> lGear;
222 void ReadMetrics(FGConfigFile*);
223 void ReadPropulsion(FGConfigFile*);
224 void ReadFlightControls(FGConfigFile*);
225 void ReadAerodynamics(FGConfigFile*);
226 void ReadUndercarriage(FGConfigFile*);
227 void ReadPrologue(FGConfigFile*);
228 void ReadOutput(FGConfigFile*);
232 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%