]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAircraft.h
b) FDM - ada.cxx, ada.hxx have been updated with the faux, daux and iaux arrays that...
[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 #  else
47 #    include <vector.h>
48 #    include <iterator.h>
49 #  endif
50 #else
51 #  include <vector>
52 #  include <iterator>
53 #endif
54
55 #include "FGModel.h"
56 #include "FGPropulsion.h"
57 #include "FGConfigFile.h"
58 #include "FGMatrix.h"
59 #include "FGLGear.h"
60
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 DEFINITIONS
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64
65 #define ID_AIRCRAFT "$Id$"
66
67 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 FORWARD DECLARATIONS
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
70
71 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
74
75 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 CLASS DOCUMENTATION
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
78
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).
89     @author Jon S. Berndt
90     @version $Id$
91     @see
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>
103 */
104
105 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106 CLASS DECLARATION
107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
108
109 class FGAircraft : public FGModel {
110   enum {eL=1, eM, eN};
111   enum {eX=1, eY, eZ};
112   enum {eP=1, eQ, eR};
113   enum {ePhi=1, eTht, ePsi};
114
115 public:
116   /** Constructor
117       @param Executive a pointer to the parent executive object */
118   FGAircraft(FGFDMExec *Executive);
119   
120   /// Destructor
121   ~FGAircraft();
122
123   /** Runs the Aircraft model; called by the Executive
124       @see JSBSim.cpp documentation
125       @return false if no error */
126   bool Run(void);
127   
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);
133   
134   /** Gets the aircraft name
135       @return the name of the aircraft as a string type */
136   inline string GetAircraftName(void) { return AircraftName; }
137   
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; }
164
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; }
170
171   string GetGroundReactionStrings(void);
172   string GetGroundReactionValues(void);
173
174   /// Subsystem types for specifying which will be output in the FDM data logging
175   enum  SubSystems {
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
189   } subsystems;
190
191 private:
192   void GetState(void);
193   void FMAero(void);
194   void FMGear(void);
195   void FMMass(void);
196   void FMProp(void);
197   FGColumnVector vMoments;
198   FGColumnVector vForces;
199   FGColumnVector vXYZrp;
200   FGColumnVector vXYZep;
201   FGColumnVector vEuler;
202   FGColumnVector vDXYZcg;
203   FGColumnVector vAeroBodyForces;
204   float alpha, beta;
205   float WingArea, WingSpan, cbar;
206   float alphaclmax,alphaclmin;
207   float dt;
208   string CFGVersion;
209   string AircraftName;
210
211   bool GearUp;
212
213   vector <FGLGear> lGear;
214
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*);
222   void Debug(void);
223 };
224
225 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226 #endif
227