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"
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65 #define ID_AIRCRAFT "$Id$"
67 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
79 /** Encapsulates an Aircraft and its systems.
80 Owns all the parts (other classes) which make up this aircraft. This includes
81 the Engines, Tanks, Propellers, Nozzles, Aerodynamic and Mass properties,
82 landing gear, etc. These constituent parts may actually run as separate
83 JSBSim models themselves, but the responsibility for initializing them and
84 for retrieving their force and moment contributions falls to FGAircraft.<br>
85 When an aircraft model is loaded the config file is parsed and for each of the
86 sections of the config file (propulsion, flight control, etc.) the
87 corresponding "ReadXXX()" method is called. From within this method the
88 "Load()" method of that system is called (e.g. LoadFCS).
92 <ol><li>Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
93 Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
94 School, January 1994</li>
95 <li>D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
96 JSC 12960, July 1977</li>
97 <li>Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
98 NASA-Ames", NASA CR-2497, January 1975</li>
99 <li>Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
100 Wiley & Sons, 1979 ISBN 0-471-03032-5</li>
101 <li>Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
102 1982 ISBN 0-471-08936-2</li></ol>
105 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
109 class FGAircraft : public FGModel {
113 enum {ePhi=1, eTht, ePsi};
117 @param Executive a pointer to the parent executive object */
118 FGAircraft(FGFDMExec *Executive);
123 /** Runs the Aircraft model; called by the Executive
124 @see JSBSim.cpp documentation
125 @return false if no error */
128 /** Loads the aircraft.
129 The executive calls this method to load the aircraft into JSBSim.
130 @param AC_cfg a pointer to the config file instance
131 @return true if successful */
132 bool Load(FGConfigFile* AC_cfg);
134 /** Gets the aircraft name
135 @return the name of the aircraft as a string type */
136 inline string GetAircraftName(void) { return AircraftName; }
138 /** Gets the gear status
139 @return true if gear is not deployed */
140 inline bool GetGearUp(void) { return GearUp; }
141 /** Gets the number of gear units defined for the aircraft
142 @return number of gear units defined */
143 inline int GetNumGearUnits(void) { return lGear.size(); }
144 /** Gets a gear instance
145 @param gear index of gear instance
146 @return a pointer to the FGLGear instance of the gear unit requested */
147 inline FGLGear* GetGearUnit(int gear) { return &(lGear[gear]); }
148 /// Gets the wing area
149 inline float GetWingArea(void) { return WingArea; }
150 /// Gets the wing span
151 inline float GetWingSpan(void) { return WingSpan; }
152 /// Gets the average wing chord
153 inline float Getcbar(void) { return cbar; }
154 inline FGColumnVector GetMoments(void) { return vMoments; }
155 inline FGColumnVector GetForces(void) { return vForces; }
156 inline FGColumnVector GetAeroBodyForces(void) { return vAeroBodyForces; }
157 inline float GetAeroBodyForces(int axis) { return vAeroBodyForces(axis); }
158 inline FGColumnVector GetXYZrp(void) { return vXYZrp; }
159 inline FGColumnVector GetXYZep(void) { return vXYZep; }
160 inline float GetXYZrp(int idx) { return vXYZrp(idx); }
161 inline float GetXYZep(int idx) { return vXYZep(idx); }
162 inline float GetAlphaCLMax(void) { return alphaclmax; }
163 inline float GetAlphaCLMin(void) { return alphaclmin; }
165 inline void SetGear(bool tt) { GearUp = tt; }
166 inline void SetGearUp(void) { GearUp = true; }
167 inline void SetGearDown(bool tt) { GearUp = false; }
168 inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
169 inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
171 string GetGroundReactionStrings(void);
172 string GetGroundReactionValues(void);
174 /// Subsystem types for specifying which will be output in the FDM data logging
176 /** Subsystem: Simulation (= 1) */ ssSimulation = 1,
177 /** Subsystem: Aerosurfaces (= 2) */ ssAerosurfaces = 2,
178 /** Subsystem: Body rates (= 4) */ ssRates = 4,
179 /** Subsystem: Velocities (= 8) */ ssVelocities = 8,
180 /** Subsystem: Forces (= 16) */ ssForces = 16,
181 /** Subsystem: Moments (= 32) */ ssMoments = 32,
182 /** Subsystem: Atmosphere (= 64) */ ssAtmosphere = 64,
183 /** Subsystem: Mass Properties (= 128) */ ssMassProps = 128,
184 /** Subsystem: Coefficients (= 256) */ ssCoefficients = 256,
185 /** Subsystem: Position (= 512) */ ssPosition = 512,
186 /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
187 /** Subsystem: FCS (= 2048) */ ssFCS = 2048,
188 /** Subsystem: Propulsion (= 4096) */ ssPropulsion = 4096
197 FGColumnVector vMoments;
198 FGColumnVector vForces;
199 FGColumnVector vXYZrp;
200 FGColumnVector vXYZep;
201 FGColumnVector vEuler;
202 FGColumnVector vDXYZcg;
203 FGColumnVector vAeroBodyForces;
205 float WingArea, WingSpan, cbar;
206 float alphaclmax,alphaclmin;
213 vector <FGLGear> lGear;
215 void ReadMetrics(FGConfigFile*);
216 void ReadPropulsion(FGConfigFile*);
217 void ReadFlightControls(FGConfigFile*);
218 void ReadAerodynamics(FGConfigFile*);
219 void ReadUndercarriage(FGConfigFile*);
220 void ReadPrologue(FGConfigFile*);
221 void ReadOutput(FGConfigFile*);
225 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%