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