]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGLGear.h
Updated to match changes in radiostack.[ch]xx
[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 "FGMatrix33.h"
48 #include "FGColumnVector3.h"
49 #include "FGColumnVector4.h"
50 #include "FGFDMExec.h"
51 #include "FGJSBBase.h"
52
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 DEFINITIONS
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56
57 #define ID_LGEAR "$Id$"
58
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 FORWARD DECLARATIONS
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63 class FGAircraft;
64 class FGPosition;
65 class FGRotation;
66 class FGFCS;
67 class FGState;
68 class FGMassBalance;
69
70 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 CLASS DOCUMENTATION
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
77
78 /** Landing gear model.
79     Calculates forces and moments due to landing gear reactions. This is done in
80     several steps, and is dependent on what kind of gear is being modeled. Here
81     are the parameters that can be specified in the config file for modeling
82     landing gear:
83     <p>
84     <b><u>Physical Characteristics</u></b><br>
85     <ol>
86     <li>X, Y, Z location, in inches in structural coordinate frame</li>
87     <li>Spring constant, in lbs/ft</li>
88     <li>Damping coefficient, in lbs/ft/sec</li>
89     <li>Dynamic Friction Coefficient</li>
90     <li>Static Friction Coefficient</li>
91     </ol></p><p>
92     <b><u>Operational Properties</b></u><br>
93     <ol>
94     <li>Name</li>
95     <li>Steerability attribute {one of STEERABLE | FIXED | CASTERED}</li>
96     <li>Brake Group Membership {one of LEFT | CENTER | RIGHT | NOSE | TAIL | NONE}</li>
97     <li>Max Steer Angle, in degrees</li>
98     </ol></p>
99     <p>
100     <b><u>Algorithm and Approach to Modeling</u></b><br>
101     <ol>
102     <li>Find the location of the uncompressed landing gear relative to the CG of
103     the aircraft. Remember, the structural coordinate frame that the aircraft is
104     defined in is: X positive towards the tail, Y positive out the right side, Z
105     positive upwards. The locations of the various parts are given in inches in
106     the config file.</li>
107     <li>The vector giving the location of the gear (relative to the cg) is
108     rotated 180 degrees about the Y axis to put the coordinates in body frame (X
109     positive forwards, Y positive out the right side, Z positive downwards, with
110     the origin at the cg). The lengths are also now given in feet.</li>
111     <li>The new gear location is now transformed to the local coordinate frame
112     using the body-to-local matrix. (Mb2l).</li>
113     <li>Knowing the location of the center of gravity relative to the ground
114     (height above ground level or AGL) now enables gear deflection to be
115     calculated. The gear compression value is the local frame gear Z location
116     value minus the height AGL. [Currently, we make the assumption that the gear
117     is oriented - and the deflection occurs in - the Z axis only. Additionally,
118     the vector to the landing gear is currently not modified - which would
119     (correctly) move the point of contact to the actual compressed-gear point of
120     contact. Eventually, articulated gear may be modeled, but initially an
121     effort must be made to model a generic system.] As an example, say the
122     aircraft left main gear location (in local coordinates) is Z = 3 feet
123     (positive) and the height AGL is 2 feet. This tells us that the gear is
124     compressed 1 foot.</li>
125     <li>If the gear is compressed, a Weight-On-Wheels (WOW) flag is set.</li>
126     <li>With the compression length calculated, the compression velocity may now
127     be calculated. This will be used to determine the damping force in the
128     strut. The aircraft rotational rate is multiplied by the vector to the wheel
129     to get a wheel velocity in body frame. That velocity vector is then
130     transformed into the local coordinate frame.</li>
131     <li>The aircraft cg velocity in the local frame is added to the
132     just-calculated wheel velocity (due to rotation) to get a total wheel
133     velocity in the local frame.</li>
134     <li>The compression speed is the Z-component of the vector.</li>
135     <li>With the wheel velocity vector no longer needed, it is normalized and
136     multiplied by a -1 to reverse it. This will be used in the friction force
137     calculation.</li>
138     <li>Since the friction force takes place solely in the runway plane, the Z
139     coordinate of the normalized wheel velocity vector is set to zero.</li>
140     <li>The gear deflection force (the force on the aircraft acting along the
141     local frame Z axis) is now calculated given the spring and damper
142     coefficients, and the gear deflection speed and stroke length. Keep in mind
143     that gear forces always act in the negative direction (in both local and
144     body frames), and are not capable of generating a force in the positive
145     sense (one that would attract the aircraft to the ground). So, the gear
146     forces are always negative - they are limited to values of zero or less. The
147     gear force is simply the negative of the sum of the spring compression
148     length times the spring coefficient and the gear velocity times the damping
149     coefficient.</li>
150     <li>The lateral/directional force acting on the aircraft through the landing
151
152     gear (along the local frame X and Y axes) is calculated next. First, the
153     friction coefficient is multiplied by the recently calculated Z-force. This
154     is the friction force. It must be given direction in addition to magnitude.
155     We want the components in the local frame X and Y axes. From step 9, above,
156     the conditioned wheel velocity vector is taken and the X and Y parts are
157     multiplied by the friction force to get the X and Y components of friction.
158     </li>
159     <li>The wheel force in local frame is next converted to body frame.</li>
160     <li>The moment due to the gear force is calculated by multiplying r x F
161     (radius to wheel crossed into the wheel force). Both of these operands are
162     in body frame.</li>
163     </ol>
164     @author Jon S. Berndt
165     @version $Id$
166     @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
167            NASA-Ames", NASA CR-2497, January 1975
168     @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
169            Wiley & Sons, 1979 ISBN 0-471-03032-5
170     @see W. A. Ragsdale, "A Generic Landing Gear Dynamics Model for LASRS++",
171      AIAA-2000-4303
172     @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGLGear.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
173          Header File </a>
174     @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGLGear.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">
175          Source File </a>
176 */
177
178 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 CLASS DECLARATION
180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
181
182 class FGLGear : public FGJSBBase
183 {
184 public:
185   /// Brake grouping enumerators
186   enum BrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail };
187   /// Steering group membership enumerators
188   enum SteerType {stSteer, stFixed, stCaster};
189   /** Constructor
190       @param Executive a pointer to the parent executive object
191       @param File a pointer to the config file instance */
192   FGLGear(FGConfigFile* File, FGFDMExec* Executive);
193   /** Constructor
194       @param lgear a reference to an existing FGLGear object     */
195   FGLGear(const FGLGear& lgear);
196   /// Destructor
197   ~FGLGear();
198
199
200   /// The Force vector for this gear
201   FGColumnVector3& Force(void);
202   /// The Moment vector for this gear
203   FGColumnVector3& Moment(void) {return vMoment;}
204
205   /// Gets the location of the gear in Body axes
206   FGColumnVector3& GetBodyLocation(void) { return vWhlBodyVec; }
207   double GetBodyLocation(int idx) { return vWhlBodyVec(idx); }
208
209   FGColumnVector3& GetLocalGear(void) { return vLocalGear; }
210   double GetLocalGear(int idx) { return vLocalGear(idx); }
211
212   /// Gets the name of the gear
213   inline string GetName(void)      {return name;          }
214   /// Gets the Weight On Wheels flag value
215   inline bool   GetWOW(void)       {return WOW;           }
216   /// Gets the current compressed length of the gear in feet
217   inline double  GetCompLen(void)   {return compressLength;}
218   /// Gets the current gear compression velocity in ft/sec
219   inline double  GetCompVel(void)   {return compressSpeed; }
220   /// Gets the gear compression force in pounds
221   inline double  GetCompForce(void) {return Force()(3);    }
222   inline double  GetBrakeFCoeff(void) {return BrakeFCoeff;}
223   
224   /// Sets the brake value in percent (0 - 100)
225   inline void SetBrake(double bp) {brakePct = bp;}
226
227   /** Set the console touchdown reporting feature
228       @param flag true turns on touchdown reporting, false turns it off */
229   inline void SetReport(bool flag) { ReportEnable = flag; }
230   /** Get the console touchdown reporting feature
231       @return true if reporting is turned on */
232   inline bool GetReport(void)    { return ReportEnable; }
233   inline double GetSteerAngle(void) { return SteerAngle;}
234   inline double GetstaticFCoeff(void) { return staticFCoeff;}
235   
236   inline int GetBrakeGroup(void) { return (int)eBrakeGrp; }
237   inline int GetSteerType(void)  { return (int)eSteerType; }
238   
239   inline bool GetRetractable(void)         { return isRetractable;   }
240   inline bool GetGearUnitUp(void)          { return GearUp;          }
241   inline bool GetGearUnitDown(void)        { return GearDown;        }
242   inline double GetWheelSideForce(void)    { return SideForce;       }
243   inline double GetWheelRollForce(void)    { return RollingForce;    }
244   inline double GetBodyXForce(void)        { return vLocalForce(eX); }
245   inline double GetBodyYForce(void)        { return vLocalForce(eY); }
246   inline double GetWheelSlipAngle(void)    { return WheelSlip;       }
247   
248 private:
249   FGColumnVector3 vXYZ;
250   FGColumnVector3 vMoment;
251   FGColumnVector3 vWhlBodyVec;
252   FGColumnVector3 vLocalGear;
253   FGColumnVector3 vForce;
254   FGColumnVector3 vLocalForce;
255   FGColumnVector3 vWhlVelVec;     // Velocity of this wheel (Local)
256   double SteerAngle;
257   double kSpring;
258   double bDamp;
259   double compressLength;
260   double compressSpeed;
261   double staticFCoeff, dynamicFCoeff, rollingFCoeff;
262   double brakePct;
263   double BrakeFCoeff;
264   double maxCompLen;
265   double SinkRate;
266   double GroundSpeed;
267   double DistanceTraveled;
268   double MaximumStrutForce;
269   double MaximumStrutTravel;
270   double SideWhlVel, RollingWhlVel;
271   double RollingForce, SideForce, FCoeff;
272   double WheelSlip;
273   bool WOW;
274   bool lastWOW;
275   bool FirstContact;
276   bool Reported;
277   bool ReportEnable;
278   bool isRetractable;
279   bool GearUp, GearDown;
280   string name;
281   string sSteerType;
282   string sBrakeGroup;
283   string sRetractable;
284   
285   BrakeGroup eBrakeGrp;
286   SteerType  eSteerType;
287   double  maxSteerAngle;
288
289   FGFDMExec*  Exec;
290   FGState*    State;
291   FGAircraft* Aircraft;
292   FGPosition* Position;
293   FGRotation* Rotation;
294   FGFCS*      FCS;
295   FGMassBalance* MassBalance;
296
297   void Report(void);
298   void Debug(int from);
299 };
300
301 #include "FGAircraft.h"
302 #include "FGPosition.h"
303 #include "FGRotation.h"
304 #include "FGFCS.h"
305 #include "FGMassBalance.h"
306
307 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308
309 #include "FGState.h"
310
311 #endif