]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGLGear.h
Update to the latest version of JSBSim which supports Lighter Than Air craft
[flightgear.git] / src / FDM / JSBSim / models / 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 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 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 <FGJSBBase.h>
46 #include <FGFDMExec.h>
47 #include <input_output/FGXMLElement.h>
48 #include <math/FGColumnVector3.h>
49 #include <math/FGTable.h>
50 #include <string>
51
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 DEFINITIONS
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
56 #define ID_LGEAR "$Id$"
57
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 FORWARD DECLARATIONS
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61
62 namespace JSBSim {
63
64 class FGAircraft;
65 class FGPropagate;
66 class FGFCS;
67 class FGState;
68 class FGMassBalance;
69 class FGAuxiliary;
70
71 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 CLASS DOCUMENTATION
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
74
75 /** Landing gear model.
76     Calculates forces and moments due to landing gear reactions. This is done in
77     several steps, and is dependent on what kind of gear is being modeled. Here
78     are the parameters that can be specified in the config file for modeling
79     landing gear:
80     <p>
81     <h3>Physical Characteristics</h3>
82     <ol>
83     <li>X, Y, Z location, in inches in structural coordinate frame</li>
84     <li>Spring constant, in lbs/ft</li>
85     <li>Damping coefficient, in lbs/ft/sec</li>
86     <li>Dynamic Friction Coefficient</li>
87     <li>Static Friction Coefficient</li>
88     </ol></p><p>
89     <h3>Operational Properties</h3>
90     <ol>
91     <li>Name</li>
92     <li>Steerability attribute {one of STEERABLE | FIXED | CASTERED}</li>
93     <li>Brake Group Membership {one of LEFT | CENTER | RIGHT | NOSE | TAIL | NONE}</li>
94     <li>Max Steer Angle, in degrees</li>
95     </ol></p>
96     <p>
97     <h3>Algorithm and Approach to Modeling</h3>
98     <ol>
99     <li>Find the location of the uncompressed landing gear relative to the CG of
100     the aircraft. Remember, the structural coordinate frame that the aircraft is
101     defined in is: X positive towards the tail, Y positive out the right side, Z
102     positive upwards. The locations of the various parts are given in inches in
103     the config file.</li>
104     <li>The vector giving the location of the gear (relative to the cg) is
105     rotated 180 degrees about the Y axis to put the coordinates in body frame (X
106     positive forwards, Y positive out the right side, Z positive downwards, with
107     the origin at the cg). The lengths are also now given in feet.</li>
108     <li>The new gear location is now transformed to the local coordinate frame
109     using the body-to-local matrix. (Mb2l).</li>
110     <li>Knowing the location of the center of gravity relative to the ground
111     (height above ground level or AGL) now enables gear deflection to be
112     calculated. The gear compression value is the local frame gear Z location
113     value minus the height AGL. [Currently, we make the assumption that the gear
114     is oriented - and the deflection occurs in - the Z axis only. Additionally,
115     the vector to the landing gear is currently not modified - which would
116     (correctly) move the point of contact to the actual compressed-gear point of
117     contact. Eventually, articulated gear may be modeled, but initially an
118     effort must be made to model a generic system.] As an example, say the
119     aircraft left main gear location (in local coordinates) is Z = 3 feet
120     (positive) and the height AGL is 2 feet. This tells us that the gear is
121     compressed 1 foot.</li>
122     <li>If the gear is compressed, a Weight-On-Wheels (WOW) flag is set.</li>
123     <li>With the compression length calculated, the compression velocity may now
124     be calculated. This will be used to determine the damping force in the
125     strut. The aircraft rotational rate is multiplied by the vector to the wheel
126     to get a wheel velocity in body frame. That velocity vector is then
127     transformed into the local coordinate frame.</li>
128     <li>The aircraft cg velocity in the local frame is added to the
129     just-calculated wheel velocity (due to rotation) to get a total wheel
130     velocity in the local frame.</li>
131     <li>The compression speed is the Z-component of the vector.</li>
132     <li>With the wheel velocity vector no longer needed, it is normalized and
133     multiplied by a -1 to reverse it. This will be used in the friction force
134     calculation.</li>
135     <li>Since the friction force takes place solely in the runway plane, the Z
136     coordinate of the normalized wheel velocity vector is set to zero.</li>
137     <li>The gear deflection force (the force on the aircraft acting along the
138     local frame Z axis) is now calculated given the spring and damper
139     coefficients, and the gear deflection speed and stroke length. Keep in mind
140     that gear forces always act in the negative direction (in both local and
141     body frames), and are not capable of generating a force in the positive
142     sense (one that would attract the aircraft to the ground). So, the gear
143     forces are always negative - they are limited to values of zero or less. The
144     gear force is simply the negative of the sum of the spring compression
145     length times the spring coefficient and the gear velocity times the damping
146     coefficient.</li>
147     <li>The lateral/directional force acting on the aircraft through the landing
148
149     gear (along the local frame X and Y axes) is calculated next. First, the
150     friction coefficient is multiplied by the recently calculated Z-force. This
151     is the friction force. It must be given direction in addition to magnitude.
152     We want the components in the local frame X and Y axes. From step 9, above,
153     the conditioned wheel velocity vector is taken and the X and Y parts are
154     multiplied by the friction force to get the X and Y components of friction.
155     </li>
156     <li>The wheel force in local frame is next converted to body frame.</li>
157     <li>The moment due to the gear force is calculated by multiplying r x F
158     (radius to wheel crossed into the wheel force). Both of these operands are
159     in body frame.</li>
160     </ol>
161
162     <h3>Configuration File Format:</h3>
163 @code
164         <contact type="{BOGEY | STRUCTURE}" name="{string}">
165             <location unit="{IN | M}">
166                 <x> {number} </x>
167                 <y> {number} </y>
168                 <z> {number} </z>
169             </location>
170             <static_friction> {number} </static_friction>
171             <dynamic_friction> {number} </dynamic_friction>
172             <rolling_friction> {number} </rolling_friction>
173             <spring_coeff unit="{LBS/FT | N/M}"> {number} </spring_coeff>
174             <damping_coeff unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff>
175             <damping_coeff_rebound unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff_rebound>
176             <max_steer unit="DEG"> {number | 0 | 360} </max_steer>
177             <brake_group> {NONE | LEFT | RIGHT | CENTER | NOSE | TAIL} </brake_group>
178             <retractable>{0 | 1}</retractable>
179             <table type="{CORNERING_COEFF}">
180             </table>
181             <relaxation_velocity>
182                <rolling unit="{FT/SEC | KTS | M/S}"> {number} </rolling>
183                <side unit="{FT/SEC | KTS | M/S}"> {number} </side>
184             </relaxation_velocity>
185             <force_lag_filter>
186                <rolling> {number} </rolling>
187                <side> {number} </side>
188             </force_lag_filter>
189             <wheel_slip_filter> {number} </wheel_slip_filter>  
190         </contact>
191 @endcode
192     @author Jon S. Berndt
193     @version $Id$
194     @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
195      NASA-Ames", NASA CR-2497, January 1975
196     @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
197      Wiley & Sons, 1979 ISBN 0-471-03032-5
198     @see W. A. Ragsdale, "A Generic Landing Gear Dynamics Model for LASRS++",
199      AIAA-2000-4303
200 */
201
202 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203 CLASS DECLARATION
204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
205
206 class FGLGear : public FGJSBBase
207 {
208 public:
209   /// Brake grouping enumerators
210   enum BrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail };
211   /// Steering group membership enumerators
212   enum SteerType {stSteer, stFixed, stCaster};
213   /// Contact point type
214   enum ContactType {ctBOGEY, ctSTRUCTURE, ctUNKNOWN};
215   /// Report type enumerators
216   enum ReportType {erNone=0, erTakeoff, erLand};
217   /** Constructor
218       @param el a pointer to the XML element that contains the CONTACT info.
219       @param Executive a pointer to the parent executive object
220       @param number integer identifier for this instance of FGLGear
221   */
222   FGLGear(Element* el, FGFDMExec* Executive, int number);
223   /** Constructor
224       @param lgear a reference to an existing FGLGear object     */
225   FGLGear(const FGLGear& lgear);
226   /// Destructor
227   ~FGLGear();
228
229
230   /// The Force vector for this gear
231   FGColumnVector3& Force(void);
232   /// The Moment vector for this gear
233   FGColumnVector3& Moment(void) {return vMoment;}
234
235   /// Gets the location of the gear in Body axes
236   FGColumnVector3& GetBodyLocation(void) { return vWhlBodyVec; }
237   double GetBodyLocation(int idx) const { return vWhlBodyVec(idx); }
238
239   FGColumnVector3& GetLocalGear(void) { return vLocalGear; }
240   double GetLocalGear(int idx) const { return vLocalGear(idx); }
241
242   /// Gets the name of the gear
243   inline string GetName(void) const {return name;          }
244   /// Gets the Weight On Wheels flag value
245   inline bool   GetWOW(void) const {return WOW;           }
246   /// Gets the current compressed length of the gear in feet
247   inline double  GetCompLen(void) const {return compressLength;}
248   /// Gets the current gear compression velocity in ft/sec
249   inline double  GetCompVel(void) const {return compressSpeed; }
250   /// Gets the gear compression force in pounds
251   inline double  GetCompForce(void) const {return vForce(eZ);    }
252   inline double  GetBrakeFCoeff(void) const {return BrakeFCoeff;}
253
254   /// Gets the current normalized tire pressure
255   inline double  GetTirePressure(void) const { return TirePressureNorm; }
256   /// Sets the new normalized tire pressure
257   inline void    SetTirePressure(double p) { TirePressureNorm = p; }
258
259   /// Sets the brake value in percent (0 - 100)
260   inline void SetBrake(double bp) {brakePct = bp;}
261
262   /** Set the console touchdown reporting feature
263       @param flag true turns on touchdown reporting, false turns it off */
264   inline void SetReport(bool flag) { ReportEnable = flag; }
265   /** Get the console touchdown reporting feature
266       @return true if reporting is turned on */
267   inline bool GetReport(void) const  { return ReportEnable; }
268   double GetSteerNorm(void) const    { return radtodeg/maxSteerAngle*SteerAngle; }
269   double GetDefaultSteerAngle(double cmd) const { return cmd*maxSteerAngle; }
270   double GetstaticFCoeff(void) const { return staticFCoeff; }
271
272   inline int GetBrakeGroup(void) const { return (int)eBrakeGrp; }
273   inline int GetSteerType(void) const  { return (int)eSteerType; }
274
275   inline double GetZPosition(void) const { return vXYZ(3); }
276   inline void SetZPosition(double z) { vXYZ(3) = z; }
277
278   bool GetSteerable(void) const { return eSteerType != stFixed; }
279   inline bool GetRetractable(void) const      { return isRetractable;   }
280   inline bool GetGearUnitUp(void) const       { return GearUp;          }
281   inline bool GetGearUnitDown(void) const     { return GearDown;        }
282   inline double GetWheelSideForce(void) const { return SideForce;       }
283   inline double GetWheelRollForce(void) const { return RollingForce;    }
284   inline double GetWheelSideVel(void) const   { return SideWhlVel;      }
285   inline double GetWheelRollVel(void) const   { return RollingWhlVel;   }
286   inline double GetBodyXForce(void) const     { return vLocalForce(eX); }
287   inline double GetBodyYForce(void) const     { return vLocalForce(eY); }
288   inline double GetWheelSlipAngle(void) const { return WheelSlip;       }
289   double GetWheelVel(int axis) const          { return vWhlVelVec(axis);}
290   bool IsBogey(void) const                    { return (eContactType == ctBOGEY);}
291   double GetGearUnitPos(void);
292
293   void bind(void);
294
295 private:
296   int GearNumber;
297   FGColumnVector3 vXYZ;
298   FGColumnVector3 vMoment;
299   FGColumnVector3 vWhlBodyVec;
300   FGColumnVector3 vLocalGear;
301   FGColumnVector3 vForce;
302   FGColumnVector3 last_vForce; // remove this
303   FGColumnVector3 vLocalForce;
304   FGColumnVector3 vWhlVelVec;     // Velocity of this wheel (Local)
305   FGColumnVector3 normal, cvel;
306   FGColumnVector3 prevOut, prevIn;
307   FGLocation contact, gearLoc;
308   FGTable *ForceY_Table;
309   double dT;
310   double SteerAngle;
311   double kSpring;
312   double bDamp;
313   double bDampRebound;
314   double compressLength;
315   double compressSpeed;
316   double staticFCoeff, dynamicFCoeff, rollingFCoeff;
317   double brakePct;
318   double BrakeFCoeff;
319   double maxCompLen;
320   double SinkRate;
321   double GroundSpeed;
322   double TakeoffDistanceTraveled;
323   double TakeoffDistanceTraveled50ft;
324   double LandingDistanceTraveled;
325   double MaximumStrutForce;
326   double MaximumStrutTravel;
327   double SideWhlVel, RollingWhlVel;
328   double RollingForce, SideForce, FCoeff;
329   double WheelSlip;
330   double prevSlipIn;
331   double prevSlipOut;
332   double TirePressureNorm;
333   double SinWheel, CosWheel;
334   double GearPos;
335   bool   useFCSGearPos;
336   bool WOW;
337   bool lastWOW;
338   bool FirstContact;
339   bool StartedGroundRun;
340   bool LandingReported;
341   bool TakeoffReported;
342   bool ReportEnable;
343   bool isRetractable;
344   bool GearUp, GearDown;
345   bool Servicable;
346   string name;
347   string sSteerType;
348   string sBrakeGroup;
349   string sRetractable;
350   string sContactType;
351
352   BrakeGroup  eBrakeGrp;
353   ContactType eContactType;
354   SteerType   eSteerType;
355   double  maxSteerAngle;
356   double RFRV;  // Rolling force relaxation velocity
357   double SFRV;  // Side force relaxation velocity
358   double LongForceLagFilterCoeff; // Longitudinal Force Lag Filter Coefficient
359   double LatForceLagFilterCoeff; // Lateral Force Lag Filter Coefficient
360   double WheelSlipLagFilterCoeff; // Wheel slip angle lag filter coefficient
361
362   FGFDMExec*     Exec;
363   FGState*       State;
364   FGAircraft*    Aircraft;
365   FGPropagate*   Propagate;
366   FGAuxiliary*   Auxiliary;
367   FGFCS*         FCS;
368   FGMassBalance* MassBalance;
369
370   void ComputeRetractionState(void);
371   void ComputeBrakeForceCoefficient(void);
372   void ComputeSteeringAngle(void);
373   void ComputeSlipAngle(void);
374   void ComputeSideForceCoefficient(void);
375   void ComputeVerticalStrutForce(void);
376   void CrashDetect(void);
377   void InitializeReporting(void);
378   void ResetReporting(void);
379   void ReportTakeoffOrLanding(void);
380   void Report(ReportType rt);
381   void Debug(int from);
382 };
383 }
384 #include "FGAircraft.h"
385 #include "FGPropagate.h"
386 #include "FGAuxiliary.h"
387 #include "FGFCS.h"
388 #include "FGMassBalance.h"
389 #include "FGState.h"
390
391 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
392
393 #endif