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