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