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