]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAircraft.h
JSBSim tweaks.
[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 SG_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 "FGPropulsion.h"
60 #include "FGConfigFile.h"
61 #include "FGMatrix.h"
62 #include "FGLGear.h"
63
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 DEFINITIONS
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67
68 #define ID_AIRCRAFT "$Id$"
69
70 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 FORWARD DECLARATIONS
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
73
74 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
77
78 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 CLASS DOCUMENTATION
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
81
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).
92     @author Jon S. Berndt
93     @version $Id$
94     @see
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>
106 */
107
108 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109 CLASS DECLARATION
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
111
112 class FGAircraft : public FGModel {
113   enum {eL=1, eM, eN};
114   enum {eX=1, eY, eZ};
115   enum {eP=1, eQ, eR};
116   enum {ePhi=1, eTht, ePsi};
117
118 public:
119   /** Constructor
120       @param Executive a pointer to the parent executive object */
121   FGAircraft(FGFDMExec *Executive);
122   
123   /// Destructor
124   ~FGAircraft();
125
126   /** Runs the Aircraft model; called by the Executive
127       @see JSBSim.cpp documentation
128       @return false if no error */
129   bool Run(void);
130   
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);
138   
139   /** Gets the aircraft name
140       @return the name of the aircraft as a string type */
141   inline string GetAircraftName(void) { return AircraftName; }
142   
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; }
169
170   inline void SetGearUp(bool tt) { GearUp = tt; }
171   inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
172   inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
173
174   string GetGroundReactionStrings(void);
175   string GetGroundReactionValues(void);
176
177   float GetLoD(void);
178
179   /// Subsystem types for specifying which will be output in the FDM data logging
180   enum  SubSystems {
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
194   } subsystems;
195
196 private:
197   void GetState(void);
198   void FMAero(void);
199   void FMGear(void);
200   void FMMass(void);
201   void FMProp(void);
202   FGColumnVector vMoments;
203   FGColumnVector vForces;
204   FGColumnVector vXYZrp;
205   FGColumnVector vXYZep;
206   FGColumnVector vEuler;
207   FGColumnVector vDXYZcg;
208   FGColumnVector vAeroBodyForces;
209   float alpha, beta;
210   float WingArea, WingSpan, cbar;
211   float alphaclmax,alphaclmin;
212   float dt;
213   string CFGVersion;
214   string AircraftName;
215
216   bool GearUp;
217
218   vector <FGLGear> lGear;
219
220   string AircraftPath;
221   string EnginePath;
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*);
229   void Debug(void);
230 };
231
232 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
233 #endif
234