]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAircraft.h
Sync with current JSBSim devel code.
[flightgear.git] / src / FDM / JSBSim / FGAircraft.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2  
3  Header:       FGAircraft.h
4  Author:       Jon S. Berndt
5  Date started: 12/12/98
6  
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
8  
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
12  version.
13  
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
17  details.
18  
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.
22  
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25  
26 HISTORY
27 --------------------------------------------------------------------------------
28 12/12/98   JSB   Created
29  
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGAIRCRAFT_H
35 #define FGAIRCRAFT_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #ifdef FGFS
42 #  include <simgear/compiler.h>
43 #  ifdef FG_HAVE_STD_INCLUDES
44 #    include <vector>
45 #    include <iterator>
46 #    include <map>
47 #  else
48 #    include <vector.h>
49 #    include <iterator.h>
50 #    include <map.h>
51 #  endif
52 #else
53 #  include <vector>
54 #  include <iterator>
55 #  include <map>
56 #endif
57
58 #include "FGModel.h"
59 #include "FGCoefficient.h"
60 #include "FGEngine.h"
61 #include "FGTank.h"
62 #include "FGLGear.h"
63 #include "FGConfigFile.h"
64 #include "FGMatrix.h"
65
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 DEFINITIONS
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69
70 #define ID_AIRCRAFT "$Header$"
71
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 FORWARD DECLARATIONS
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75
76 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
79
80 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 CLASS DOCUMENTATION
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
83
84 /** Encapsulates an Aircraft and its systems.
85     Owns all the parts (other classes) which make up this aircraft. This includes
86     the Engines, Tanks, Propellers, Nozzles, Aerodynamic and Mass properties,
87     landing gear, etc. These constituent parts may actually run as separate
88     JSBSim models themselves, but the responsibility for initializing them and
89     for retrieving their force and moment contributions falls to FGAircraft.
90     @author Jon S. Berndt
91     @version $Id$
92     @see
93      <ol><li>Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
94            Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
95            School, January 1994</li>
96      <li>D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
97      JSC 12960, July 1977</li>
98      <li>Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
99      NASA-Ames", NASA CR-2497, January 1975</li>
100      <li>Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
101      Wiley & Sons, 1979 ISBN 0-471-03032-5</li>
102      <li>Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
103      1982 ISBN 0-471-08936-2</li></ol>
104 */
105
106 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 CLASS DECLARATION
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
109
110 class FGAircraft : public FGModel {
111   enum {eL=1, eM, eN};
112   enum {eX=1, eY, eZ};
113   enum {eP=1, eQ, eR};
114   enum {ePhi=1, eTht, ePsi};
115
116 public:
117   /** Constructor
118       @param Executive a pointer to the parent executive object */
119   FGAircraft(FGFDMExec *Executive);
120   
121   /// Destructor
122   ~FGAircraft(void);
123
124   /** Runs the Aircraft model; called by the Executive
125       @see JSBSim.cpp documentation
126       @return false if no error */
127   bool Run(void);
128   
129   /** Loads the aircraft.
130       The executive calls this method to load the aircraft into JSBSim.
131       @param apath path to the aircraft files (e.g. "aircraft/X15/")
132       @param epath path to engine files (e.g. "engine/")
133       @param acname name of aircraft (e.g. "X15")
134       @return true if succesful */
135   bool LoadAircraft(string apath, string epath, string acname);
136   
137   /** Gets the aircraft name
138       @return the name of the aircraft as a string type */
139   inline string GetAircraftName(void) { return AircraftName; }
140   
141   /** Gets the gear status
142       @return true if gear is not deployed */
143   inline bool GetGearUp(void) { return GearUp; }
144   /** Gets the number of gear units defined for the aircraft
145       @return number of gear units defined */
146   inline int GetNumGearUnits(void) { return lGear.size(); }
147   /** Gets a gear instance
148       @param gear index of gear instance
149       @return a pointer to the FGLGear instance of the gear unit requested */
150   inline FGLGear* GetGearUnit(int gear) { return &(lGear[gear]); }
151   /// Gets the wing area
152   inline float GetWingArea(void) { return WingArea; }
153   /// Gets the wing span
154   inline float GetWingSpan(void) { return WingSpan; }
155   /// Gets the average wing chord
156   inline float Getcbar(void) { return cbar; }
157   /** Gets an engine instance.
158       @param engine index of the engine instance
159       @return a pointer to the FGEngine instance of the requested engine */
160   inline FGEngine* GetEngine(int engine) { return Engine[engine]; }
161   /** Gets a tank instance.
162       @param tank index of the tank instance
163       @return a pointer to the FGTank instance of the requested tank */
164   inline FGTank* GetTank(int tank) { return Tank[tank]; }
165   inline float GetWeight(void) { return Weight; }
166   inline float GetMass(void) { return Mass; }
167   inline FGColumnVector GetMoments(void) { return vMoments; }
168   inline FGColumnVector GetForces(void) { return vForces; }
169   inline FGColumnVector GetvFs(void) { return vFs; }
170   inline float GetIxx(void) { return Ixx; }
171   inline float GetIyy(void) { return Iyy; }
172   inline float GetIzz(void) { return Izz; }
173   inline float GetIxz(void) { return Ixz; }
174   inline unsigned int GetNumEngines(void) { return numEngines; }
175   inline FGColumnVector GetXYZcg(void) { return vXYZcg; }
176   inline FGColumnVector GetXYZrp(void) { return vXYZrp; }
177   inline FGColumnVector GetXYZep(void) { return vXYZep; }
178   inline float GetNlf(void) { return nlf; }
179   inline float GetAlphaCLMax(void) { return alphaclmax; }
180   inline float GetAlphaCLMin(void) { return alphaclmin; }
181
182   inline void SetGearUp(bool tt) { GearUp = tt; }
183   inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
184   inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
185
186   inline FGCoefficient* GetCoeff(int axis, int idx) { return Coeff[axis][idx]; }
187   string GetCoefficientStrings(void);
188   string GetCoefficientValues(void);
189   string GetGroundReactionStrings(void);
190   string GetGroundReactionValues(void);
191
192   /// Subsystem types for specifying which will be output in the FDM data logging
193   enum  SubSystems {
194     /** Subsystem: Simulation (= 1)          */ ssSimulation      = 1,
195     /** Subsystem: Aerosurfaces (= 2)        */ ssAerosurfaces    = 2,
196     /** Subsystem: Body rates (= 4)          */ ssRates           = 4,
197     /** Subsystem: Velocities (= 8)          */ ssVelocities      = 8,
198     /** Subsystem: Forces (= 16)             */ ssForces          = 16,
199     /** Subsystem: Moments (= 32)            */ ssMoments         = 32,
200     /** Subsystem: Atmosphere (= 64)         */ ssAtmosphere      = 64,
201     /** Subsystem: Mass Properties (= 128)   */ ssMassProps       = 128,
202     /** Subsystem: Coefficients (= 256)      */ ssCoefficients    = 256,
203     /** Subsystem: Position (= 512)          */ ssPosition        = 512,
204     /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024
205   } subsystems;
206
207 private:
208   void GetState(void);
209   void FMAero(void);
210   void FMGear(void);
211   void FMMass(void);
212   void FMProp(void);
213   void MassChange(void);
214   FGColumnVector vMoments;
215   FGColumnVector vForces;
216   FGColumnVector vFs;
217   FGColumnVector vXYZrp;
218   FGColumnVector vbaseXYZcg;
219   FGColumnVector vXYZcg;
220   FGColumnVector vXYZep;
221   FGColumnVector vEuler;
222   float baseIxx, baseIyy, baseIzz, baseIxz, EmptyMass, Mass;
223   float Ixx, Iyy, Izz, Ixz;
224   float alpha, beta;
225   float WingArea, WingSpan, cbar;
226   float Weight, EmptyWeight;
227   float nlf,alphaclmax,alphaclmin;
228   float dt;
229   string CFGVersion;
230   string AircraftName;
231
232   unsigned int numTanks;
233   unsigned int numEngines;
234   unsigned int numSelectedOxiTanks;
235   unsigned int numSelectedFuelTanks;
236   FGTank* Tank[MAX_TANKS];           // need to make a vector
237   FGEngine *Engine[MAX_ENGINES];     // need to make a vector
238
239   typedef map<string,int> AxisIndex;
240   AxisIndex AxisIdx;
241
242   typedef vector<FGCoefficient*> CoeffArray;
243   
244   CoeffArray* Coeff;
245
246   void DisplayCoeffFactors(vector <eParam> multipliers);
247
248   bool GearUp;
249
250   string Axis[6];
251   vector <FGLGear> lGear;
252
253   string AircraftPath;
254   string EnginePath;
255   void ReadMetrics(FGConfigFile*);
256   void ReadPropulsion(FGConfigFile*);
257   void ReadFlightControls(FGConfigFile*);
258   void ReadAerodynamics(FGConfigFile*);
259   void ReadUndercarriage(FGConfigFile*);
260   void ReadPrologue(FGConfigFile*);
261   void ReadOutput(FGConfigFile*);
262 };
263
264 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
265 #endif