]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGAircraft.h
Update to the latest version of JSBSim which supports Lighter Than Air craft
[flightgear.git] / src / FDM / JSBSim / models / 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 Lesser 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 Lesser General Public License for more
17  details.
18
19  You should have received a copy of the GNU Lesser 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 Lesser 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 #  else
46 #    include <vector.h>
47 #  endif
48 #else
49 #  include <vector>
50 #endif
51
52 #include "FGModel.h"
53 #include <input_output/FGXMLElement.h>
54 #include <math/FGColumnVector3.h>
55
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 DEFINITIONS
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59
60 #define ID_AIRCRAFT "$Id$"
61
62 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 FORWARD DECLARATIONS
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65
66 namespace JSBSim {
67
68 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 CLASS DOCUMENTATION
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71
72 /** Encapsulates an Aircraft and its systems.
73 <p> Owns all the parts (other classes) which make up this aircraft. This includes
74     the Engines, Tanks, Propellers, Nozzles, Aerodynamic and Mass properties,
75     landing gear, etc. These constituent parts may actually run as separate
76     JSBSim models themselves, but the responsibility for initializing them and
77     for retrieving their force and moment contributions falls to FGAircraft.
78 <p> The \<metrics> section of the aircraft configuration file is read here, and
79     the metrical information is held by this class.
80 <h3>Configuration File Format for \<metrics> Section:</h3>
81 @code
82     <metrics>
83         <wingarea unit="{FT2 | M2}"> {number} </wingarea>
84         <wingspan unit="{FT | M}"> {number} </wingspan>
85         <chord unit="{FT | M}"> {number} </chord>
86         <htailarea unit="{FT2 | M2}"> {number} </htailarea>
87         <htailarm unit="{FT | M}"> {number} </htailarm>
88         <vtailarea unit="{FT2 | M}"> {number} </vtailarea>
89         <vtailarm unit="{FT | M}"> {number} </vtailarm>
90         <wing_incidence unit="{RAD | DEG}"> {number} </wing_incidence>
91         <location name="{AERORP | EYEPOINT | VRP}" unit="{IN | M}">
92             <x> {number} </x>
93             <y> {number} </y>
94             <z> {number} </z>
95         </location>
96         {other location blocks}
97     </metrics>
98 @endcode
99
100     @author Jon S. Berndt
101     @version $Id$
102     @see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
103            Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
104            School, January 1994
105     @see D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
106      JSC 12960, July 1977
107     @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
108      NASA-Ames", NASA CR-2497, January 1975
109     @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
110      Wiley & Sons, 1979 ISBN 0-471-03032-5
111     @see Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
112      1982 ISBN 0-471-08936-2
113 */
114
115 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 CLASS DECLARATION
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
118
119 class FGAircraft : public FGModel {
120 public:
121   /** Constructor
122       @param Executive a pointer to the parent executive object */
123   FGAircraft(FGFDMExec *Executive);
124
125   /// Destructor
126   ~FGAircraft();
127
128   /** Runs the Aircraft model; called by the Executive
129       @see JSBSim.cpp documentation
130       @return false if no error */
131   bool Run(void);
132
133   bool InitModel(void);
134
135   /** Loads the aircraft.
136       The executive calls this method to load the aircraft into JSBSim.
137       @param el a pointer to the element tree
138       @return true if successful */
139   bool Load(Element* el);
140
141   /** Gets the aircraft name
142       @return the name of the aircraft as a string type */
143   inline string GetAircraftName(void) { return AircraftName; }
144
145   /// Gets the wing area
146   double GetWingArea(void) const { return WingArea; }
147   /// Gets the wing span
148   double GetWingSpan(void) const { return WingSpan; }
149   /// Gets the average wing chord
150   double Getcbar(void) const { return cbar; }
151   inline double GetWingIncidence(void) const { return WingIncidence; }
152   inline double GetWingIncidenceDeg(void) const { return WingIncidence*radtodeg; }
153   inline double GetHTailArea(void) const { return HTailArea; }
154   inline double GetHTailArm(void)  const { return HTailArm; }
155   inline double GetVTailArea(void) const { return VTailArea; }
156   inline double GetVTailArm(void)  const { return VTailArm; }
157   inline double Getlbarh(void) const { return lbarh; } // HTailArm / cbar
158   inline double Getlbarv(void) const { return lbarv; } // VTailArm / cbar
159   inline double Getvbarh(void) const { return vbarh; } // H. Tail Volume
160   inline double Getvbarv(void) const { return vbarv; } // V. Tail Volume
161   inline FGColumnVector3& GetMoments(void) { return vMoments; }
162   inline double GetMoments(int idx) const { return vMoments(idx); }
163   inline FGColumnVector3& GetForces(void) { return vForces; }
164   inline double GetForces(int idx) const { return vForces(idx); }
165   inline FGColumnVector3& GetBodyAccel(void) { return vBodyAccel; }
166   inline double GetBodyAccel(int idx) { return vBodyAccel(idx); }
167   inline FGColumnVector3& GetNcg   (void)  { return vNcg; }
168   inline double GetNcg(int idx)  { return vNcg(idx); }
169   inline FGColumnVector3& GetXYZrp(void) { return vXYZrp; }
170   inline FGColumnVector3& GetXYZvrp(void) { return vXYZvrp; }
171   inline FGColumnVector3& GetXYZep(void) { return vXYZep; }
172   inline double GetXYZrp(int idx) const { return vXYZrp(idx); }
173   inline double GetXYZvrp(int idx) const { return vXYZvrp(idx); }
174   inline double GetXYZep(int idx) const { return vXYZep(idx); }
175   inline void SetAircraftName(string name) {AircraftName = name;}
176   inline void SetHoldDown(int hd) {HoldDown = hd;}
177   inline int GetHoldDown(void) const {return HoldDown;}
178
179   void SetXYZrp(int idx, double value) {vXYZrp(idx) = value;}
180
181   void SetWingArea(double S) {WingArea = S;}
182
183   double GetNlf(void);
184
185   inline FGColumnVector3& GetNwcg(void) { return vNwcg; }
186
187   void bind(void);
188   void unbind(void);
189
190 private:
191   FGColumnVector3 vMoments;
192   FGColumnVector3 vForces;
193   FGColumnVector3 vXYZrp;
194   FGColumnVector3 vXYZvrp;
195   FGColumnVector3 vXYZep;
196   FGColumnVector3 vDXYZcg;
197   FGColumnVector3 vBodyAccel;
198   FGColumnVector3 vNcg;
199   FGColumnVector3 vNwcg;
200
201   double WingArea, WingSpan, cbar, WingIncidence;
202   double HTailArea, VTailArea, HTailArm, VTailArm;
203   double lbarh,lbarv,vbarh,vbarv;
204   int HoldDown;
205   string AircraftName;
206
207   void Debug(int from);
208 };
209
210 } // namespace JSBSim
211 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
212 #endif
213