]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGLGear.h
FG_HAVE_STD_INCLUDES -> SG_HAVE_STD_INCLUDES
[flightgear.git] / src / FDM / JSBSim / FGLGear.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGLGear.h
4  Author:       Jon S. Berndt
5  Date started: 11/18/99
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 11/18/99   JSB   Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGLGEAR_H
35 #define FGLGEAR_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #ifdef FGFS
42 #  include <simgear/compiler.h>
43 #endif
44
45 #include <string>
46 #include "FGConfigFile.h"
47 #include "FGMatrix.h"
48 #include "FGFDMExec.h"
49 #include "FGState.h"
50
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 DEFINITIONS
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54
55 #define ID_LGEAR "$Header"
56
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 FORWARD DECLARATIONS
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
60
61 class FGAircraft;
62 class FGPosition;
63 class FGRotation;
64
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 CLASS DOCUMENTATION
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72
73 /** Landing gear model.
74     Calculates forces and moments due to landing gear reactions. This is done in
75     several steps, and is dependent on what kind of gear is being modeled. Here
76     are the parameters that can be specified in the config file for modeling
77     landing gear:
78     <p>
79     <b><u>Physical Characteristics</u></b><br>
80     <ol>
81     <li>X, Y, Z location, in inches in structural coordinate frame</li>
82     <li>Spring constant, in lbs/ft</li>
83     <li>Damping coefficient, in lbs/ft/sec</li>
84     <li>Dynamic Friction Coefficient</li>
85     <li>Static Friction Coefficient</li>
86     </ol></p><p>
87     <b><u>Operational Properties</b></u><br>
88     <ol>
89     <li>Name</li>
90     <li>Steerability attribute {one of STEERABLE | FIXED | CASTERED}</li>
91     <li>Brake Group Membership {one of LEFT | CENTER | RIGHT | NOSE | TAIL | NONE}</li>
92     <li>Max Steer Angle, in degrees</li>
93     </ol></p>
94     <p>
95     <b><u>Algorithm and Approach to Modeling</u></b><br>
96     <ol>
97     <li>Find the location of the uncompressed landing gear relative to the CG of
98     the aircraft. Remember, the structural coordinate frame that the aircraft is
99     defined in is: X positive towards the tail, Y positive out the right side, Z
100     positive upwards. The locations of the various parts are given in inches in
101     the config file.</li>
102     <li>The vector giving the location of the gear (relative to the cg) is
103     rotated 180 degrees about the Y axis to put the coordinates in body frame (X
104     positive forwards, Y positive out the right side, Z positive downwards, with
105     the origin at the cg). The lengths are also now given in feet.</li>
106     <li>The new gear location is now transformed to the local coordinate frame
107     using the body-to-local matrix. (Mb2l).</li>
108     <li>Knowing the location of the center of gravity relative to the ground
109     (height above ground level or AGL) now enables gear deflection to be
110     calculated. The gear compression value is the local frame gear Z location
111     value minus the height AGL. [Currently, we make the assumption that the gear
112     is oriented - and the deflection occurs in - the Z axis only. Additionally,
113     the vector to the landing gear is currently not modified - which would
114     (correctly) move the point of contact to the actual compressed-gear point of
115     contact. Eventually, articulated gear may be modeled, but initially an
116     effort must be made to model a generic system.] As an example, say the
117     aircraft left main gear location (in local coordinates) is Z = 3 feet
118     (positive) and the height AGL is 2 feet. This tells us that the gear is
119     compressed 1 foot.</li>
120     <li>If the gear is compressed, a Weight-On-Wheels (WOW) flag is set.</li>
121     <li>With the compression length calculated, the compression velocity may now
122     be calculated. This will be used to determine the damping force in the
123     strut. The aircraft rotational rate is multiplied by the vector to the wheel
124     to get a wheel velocity in body frame. That velocity vector is then
125     transformed into the local coordinate frame.</li>
126     <li>The aircraft cg velocity in the local frame is added to the
127     just-calculated wheel velocity (due to rotation) to get a total wheel
128     velocity in the local frame.</li>
129     <li>The compression speed is the Z-component of the vector.</li>
130     <li>With the wheel velocity vector no longer needed, it is normalized and
131     multiplied by a -1 to reverse it. This will be used in the friction force
132     calculation.</li>
133     <li>Since the friction force takes place solely in the runway plane, the Z
134     coordinate of the normalized wheel velocity vector is set to zero.</li>
135     <li>The gear deflection force (the force on the aircraft acting along the
136     local frame Z axis) is now calculated given the spring and damper
137     coefficients, and the gear deflection speed and stroke length. Keep in mind
138     that gear forces always act in the negative direction (in both local and
139     body frames), and are not capable of generating a force in the positive
140     sense (one that would attract the aircraft to the ground). So, the gear
141     forces are always negative - they are limited to values of zero or less. The
142     gear force is simply the negative of the sum of the spring compression
143     length times the spring coefficient and the gear velocity times the damping
144     coefficient.</li>
145     <li>The lateral/directional force acting on the aircraft through the landing
146     gear (along the local frame X and Y axes) is calculated next. First, the
147     friction coefficient is multiplied by the recently calculated Z-force. This
148     is the friction force. It must be given direction in addition to magnitude.
149     We want the components in the local frame X and Y axes. From step 9, above,
150     the conditioned wheel velocity vector is taken and the X and Y parts are
151     multiplied by the friction force to get the X and Y components of friction.
152     </li>
153     <li>The wheel force in local frame is next converted to body frame.</li>
154     <li>The moment due to the gear force is calculated by multiplying r x F
155     (radius to wheel crossed into the wheel force). Both of these operands are
156     in body frame.</li>
157     </ol>
158     @author Jon S. Berndt
159     @version $Id$
160     @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
161            NASA-Ames", NASA CR-2497, January 1975
162     @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
163            Wiley & Sons, 1979 ISBN 0-471-03032-5
164 */
165
166 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
167 CLASS DECLARATION
168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
169
170 class FGLGear
171 {
172 public:
173   /// Brake grouping enumerators
174   enum eBrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail };
175   /** Constructor
176       @param Executive a pointer to the parent executive object
177       @param File a pointer to the config file instance */
178   FGLGear(FGConfigFile* File, FGFDMExec* Executive);
179   /** Constructor
180       @param lgear a reference to an existing FGLGear object     */
181   FGLGear(const FGLGear& lgear);
182   /// Destructor
183   ~FGLGear(void);
184
185
186   /// The Force vector for this gear
187   FGColumnVector Force(void);
188   /// The Moment vector for this gear
189   FGColumnVector Moment(void) {return vMoment;}
190   /// Gets the location of the gear in Body axes
191   FGColumnVector GetBodyLocation(void) { return vWhlBodyVec; }
192   
193   FGColumnVector GetLocalGear(void) { return vLocalGear; }
194
195   /// Gets the name of the gear
196   inline string GetName(void)      {return name;          }
197   /// Gets the Weight On Wheels flag value
198   inline bool   GetWOW(void)       {return WOW;           }
199   /// Gets the current compressed length of the gear in feet
200   inline float  GetCompLen(void)   {return compressLength;}
201   /// Gets the current gear compression velocity in ft/sec
202   inline float  GetCompVel(void)   {return compressSpeed; }
203   /// Gets the gear compression force in pounds
204   inline float  GetCompForce(void) {return Force()(3);    }
205   
206   /// Sets the brake value in percent (0 - 100)
207   inline void SetBrake(double bp) {brakePct = bp;}
208
209   /** Set the console touchdown reporting feature
210       @param flag true turns on touchdown reporting, false turns it off */
211   inline void SetReport(bool flag) { ReportEnable = flag; }
212   /** Get the console touchdown reporting feature
213       @return true if reporting is turned on */
214   inline bool GetReport(void)    { return ReportEnable; }
215
216 private:
217   enum {eX=1, eY, eZ};
218   FGColumnVector vXYZ;
219   FGColumnVector vMoment;
220   FGColumnVector vWhlBodyVec;
221   FGColumnVector vLocalGear;
222   float kSpring;
223   float bDamp;
224   float compressLength;
225   float compressSpeed;
226   float staticFCoeff, dynamicFCoeff;
227   float brakePct;
228   float maxCompLen;
229   double SinkRate;
230   double GroundSpeed;
231   double DistanceTraveled;
232   double MaximumStrutForce;
233   double MaximumStrutTravel;
234   bool WOW;
235   bool FirstContact;
236   bool Reported;
237   bool ReportEnable;
238   string name;
239   string SteerType;
240   string BrakeGroup;
241   eBrakeGroup eBrakeGrp;
242   float  maxSteerAngle;
243
244   FGFDMExec*     Exec;
245   FGState*       State;
246   FGAircraft*    Aircraft;
247   FGPosition*    Position;
248   FGRotation*    Rotation;
249
250   void Report(void);
251 };
252
253 #include "FGAircraft.h"
254 #include "FGPosition.h"
255 #include "FGRotation.h"
256
257 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258 #endif