]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGLGear.cpp
Fix an issue where math.h doesn't define sqrt in namespace std (at least on MSVC...
[flightgear.git] / src / FDM / JSBSim / FGLGear.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGLGear.cpp
4  Author:       Jon S. Berndt
5                Norman H. Princen
6  Date started: 11/18/99
7  Purpose:      Encapsulates the landing gear elements
8  Called by:    FGAircraft
9
10  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
11
12  This program is free software; you can redistribute it and/or modify it under
13  the terms of the GNU General Public License as published by the Free Software
14  Foundation; either version 2 of the License, or (at your option) any later
15  version.
16
17  This program is distributed in the hope that it will be useful, but WITHOUT
18  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
20  details.
21
22  You should have received a copy of the GNU General Public License along with
23  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
24  Place - Suite 330, Boston, MA  02111-1307, USA.
25
26  Further information about the GNU General Public License can also be found on
27  the world wide web at http://www.gnu.org.
28
29 FUNCTIONAL DESCRIPTION
30 --------------------------------------------------------------------------------
31
32 HISTORY
33 --------------------------------------------------------------------------------
34 11/18/99   JSB   Created
35 01/30/01   NHP   Extended gear model to properly simulate steering and braking
36
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #include "FGLGear.h"
42
43 namespace JSBSim {
44
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 DEFINITIONS
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 GLOBAL DATA
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53 static const char *IdSrc = "$Id$";
54 static const char *IdHdr = ID_LGEAR;
55
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 CLASS IMPLEMENTATION
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59
60 FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : Exec(fdmex)
61 {
62   string tmp;
63   
64   *AC_cfg >> tmp >> name >> vXYZ(1) >> vXYZ(2) >> vXYZ(3)
65             >> kSpring >> bDamp>> dynamicFCoeff >> staticFCoeff
66                   >> rollingFCoeff >> sSteerType >> sBrakeGroup 
67                      >> maxSteerAngle >> sRetractable;
68
69   if      (sBrakeGroup == "LEFT"  ) eBrakeGrp = bgLeft;
70   else if (sBrakeGroup == "RIGHT" ) eBrakeGrp = bgRight;
71   else if (sBrakeGroup == "CENTER") eBrakeGrp = bgCenter;
72   else if (sBrakeGroup == "NOSE"  ) eBrakeGrp = bgNose;
73   else if (sBrakeGroup == "TAIL"  ) eBrakeGrp = bgTail;
74   else if (sBrakeGroup == "NONE"  ) eBrakeGrp = bgNone;
75   else {
76     cerr << "Improper braking group specification in config file: "
77          << sBrakeGroup << " is undefined." << endl;
78   }
79
80   if      (sSteerType == "STEERABLE") eSteerType = stSteer;
81   else if (sSteerType == "FIXED"    ) eSteerType = stFixed;
82   else if (sSteerType == "CASTERED" ) eSteerType = stCaster;
83   else {
84     cerr << "Improper steering type specification in config file: "
85          << sSteerType << " is undefined." << endl;
86   }
87   
88   if ( sRetractable == "RETRACT" ) {
89     isRetractable = true;
90   } else  {
91     isRetractable = false;
92   }  
93   
94   GearUp = false;
95   GearDown = true;
96   Servicable = true;
97
98 // Add some AI here to determine if gear is located properly according to its
99 // brake group type ??
100
101   State       = Exec->GetState();
102   Aircraft    = Exec->GetAircraft();
103   Position    = Exec->GetPosition();
104   Rotation    = Exec->GetRotation();
105   FCS         = Exec->GetFCS();
106   MassBalance = Exec->GetMassBalance();
107
108   WOW = lastWOW = true; // should the value be initialized to true?
109   ReportEnable = true;
110   FirstContact = false;
111   StartedGroundRun = false;
112   TakeoffReported = LandingReported = false;
113   LandingDistanceTraveled = TakeoffDistanceTraveled = TakeoffDistanceTraveled50ft = 0.0;
114   MaximumStrutForce = MaximumStrutTravel = 0.0;
115   SideForce = RollingForce = 0.0;
116   SinkRate = GroundSpeed = 0.0;
117
118   vWhlBodyVec = MassBalance->StructuralToBody(vXYZ);
119   
120   vLocalGear = State->GetTb2l() * vWhlBodyVec;
121
122   compressLength  = 0.0;
123   compressSpeed   = 0.0;
124   brakePct        = 0.0;
125   maxCompLen      = 0.0;
126
127   WheelSlip = lastWheelSlip = 0.0;
128
129   compressLength  = 0.0;
130   compressSpeed   = 0.0;
131   brakePct        = 0.0;
132   maxCompLen      = 0.0;
133
134   TirePressureNorm = 1.0;
135
136   Debug(0);
137 }
138
139 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
140
141 FGLGear::FGLGear(const FGLGear& lgear)
142 {
143   State    = lgear.State;
144   Aircraft = lgear.Aircraft;
145   Position = lgear.Position;
146   Rotation = lgear.Rotation;
147   Exec     = lgear.Exec;
148   FCS      = lgear.FCS;
149   MassBalance = lgear.MassBalance;
150
151   vXYZ = lgear.vXYZ;
152   vMoment = lgear.vMoment;
153   vWhlBodyVec = lgear.vWhlBodyVec;
154   vLocalGear = lgear.vLocalGear;
155
156   WOW                = lgear.WOW;
157   lastWOW            = lgear.lastWOW;
158   ReportEnable       = lgear.ReportEnable;
159   FirstContact       = lgear.FirstContact;
160   StartedGroundRun   = lgear.StartedGroundRun;
161   LandingDistanceTraveled   = lgear.LandingDistanceTraveled;
162   TakeoffDistanceTraveled   = lgear.TakeoffDistanceTraveled;
163   TakeoffDistanceTraveled50ft   = lgear.TakeoffDistanceTraveled50ft;
164   MaximumStrutForce  = lgear.MaximumStrutForce;
165   MaximumStrutTravel = lgear.MaximumStrutTravel;
166   SideForce          = lgear.SideForce;
167   RollingForce       = lgear.RollingForce;
168
169   kSpring         = lgear.kSpring;
170   bDamp           = lgear.bDamp;
171   compressLength  = lgear.compressLength;
172   compressSpeed   = lgear.compressSpeed;
173   staticFCoeff    = lgear.staticFCoeff;
174   dynamicFCoeff   = lgear.dynamicFCoeff;
175   rollingFCoeff   = lgear.rollingFCoeff;
176   brakePct        = lgear.brakePct;
177   maxCompLen      = lgear.maxCompLen;
178   SinkRate        = lgear.SinkRate;
179   GroundSpeed     = lgear.GroundSpeed;
180   LandingReported = lgear.LandingReported;
181   TakeoffReported = lgear.TakeoffReported;
182   name            = lgear.name;
183   sSteerType      = lgear.sSteerType;
184   sRetractable    = lgear.sRetractable;
185   eSteerType      = lgear.eSteerType;
186   sBrakeGroup     = lgear.sBrakeGroup;
187   eBrakeGrp       = lgear.eBrakeGrp;
188   maxSteerAngle   = lgear.maxSteerAngle;
189   isRetractable   = lgear.isRetractable;
190   GearUp          = lgear.GearUp;
191   GearDown        = lgear.GearDown;
192   WheelSlip       = lgear.WheelSlip;
193   lastWheelSlip   = lgear.lastWheelSlip;
194   TirePressureNorm = lgear.TirePressureNorm;
195   Servicable      = lgear.Servicable;
196 }
197
198 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
199
200 FGLGear::~FGLGear()
201 {
202   Debug(1);
203 }
204
205 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206
207 FGColumnVector3& FGLGear::Force(void)
208 {
209   double SteerGain = 0;
210   double SinWheel, CosWheel;
211   double deltaSlip;
212   double deltaT = State->Getdt()*Aircraft->GetRate();
213
214   vForce.InitMatrix();
215   vMoment.InitMatrix();
216
217   if (isRetractable) {
218     if (FCS->GetGearPos() < 0.01) {
219       GearUp   = true;
220       GearDown = false;
221      } else if (FCS->GetGearPos() > 0.99) {
222       GearDown = true;
223       GearUp   = false;
224      } else {
225       GearUp   = false;
226       GearDown = false;
227      }
228   } else {
229       GearUp   = false;
230       GearDown = true;
231   }         
232       
233   if (GearDown) {
234
235     vWhlBodyVec = MassBalance->StructuralToBody(vXYZ);
236
237 // vWhlBodyVec now stores the vector from the cg to this wheel
238
239     vLocalGear = State->GetTb2l() * vWhlBodyVec;
240
241 // vLocalGear now stores the vector from the cg to the wheel in local coords.
242
243     compressLength = vLocalGear(eZ) - Position->GetDistanceAGL();
244
245 // The compression length is currently measured in the Z-axis, only, at this time.
246 // It should be measured along the strut axis. If the local-frame gear position
247 // "hangs down" below the CG greater than the altitude, then the compressLength
248 // will be positive - i.e. the gear will have made contact.
249
250     if (compressLength > 0.00) {
251
252       WOW = true; // Weight-On-Wheels is true
253
254 // The next equation should really use the vector to the contact patch of the tire
255 // including the strut compression and not vWhlBodyVec.  Will fix this later.
256 // As it stands, now, the following equation takes the aircraft body-frame
257 // rotational rate and calculates the cross-product with the vector from the CG
258 // to the wheel, thus producing the instantaneous velocity vector of the tire
259 // in Body coords. The frame is also converted to local coordinates. When the
260 // aircraft local-frame velocity is added to this quantity, the total velocity of
261 // the wheel in local frame is then known. Subsequently, the compression speed
262 // (used for calculating damping force) is found by taking the Z-component of the
263 // wheel velocity.
264
265       vWhlVelVec      =  State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
266       vWhlVelVec     +=  Position->GetVel();
267       compressSpeed   =  vWhlVelVec(eZ);
268
269 // If this is the first time the wheel has made contact, remember some values
270 // for later printout.
271
272       if (!FirstContact) {
273         FirstContact  = true;
274         SinkRate      =  compressSpeed;
275         GroundSpeed   =  Position->GetVel().Magnitude();
276         TakeoffReported = false;
277       }
278
279 // If the takeoff run is starting, initialize.
280
281       if ((Position->GetVel().Magnitude() > 0.1) &&
282           (FCS->GetBrake(bgLeft) == 0) &&
283           (FCS->GetBrake(bgRight) == 0) &&
284           (FCS->GetThrottlePos(0) == 1) && !StartedGroundRun)
285       {
286         TakeoffDistanceTraveled = 0;
287         TakeoffDistanceTraveled50ft = 0;
288         StartedGroundRun = true;
289       }
290
291 // The following needs work regarding friction coefficients and braking and
292 // steering The BrakeFCoeff formula assumes that an anti-skid system is used.
293 // It also assumes that we won't be turning and braking at the same time.
294 // Will fix this later.
295 // [JSB] The braking force coefficients include normal rolling coefficient +
296 // a percentage of the static friction coefficient based on braking applied.
297
298       switch (eBrakeGrp) {
299       case bgLeft:
300          BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
301                         staticFCoeff*FCS->GetBrake(bgLeft) );
302         break;
303       case bgRight:
304         BrakeFCoeff =  ( rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
305                          staticFCoeff*FCS->GetBrake(bgRight) );
306         break;
307       case bgCenter:
308         BrakeFCoeff =  ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
309                          staticFCoeff*FCS->GetBrake(bgCenter) );
310         break;
311       case bgNose:
312         BrakeFCoeff =  ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
313                          staticFCoeff*FCS->GetBrake(bgCenter) );
314         break;
315       case bgTail:
316         BrakeFCoeff =  ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
317                          staticFCoeff*FCS->GetBrake(bgCenter) );
318         break;
319       case bgNone:
320         BrakeFCoeff =  rollingFCoeff;
321         break;
322       default:
323         cerr << "Improper brake group membership detected for this gear." << endl;
324         break;
325       }
326
327       switch (eSteerType) {
328       case stSteer:
329         SteerAngle = -maxSteerAngle * FCS->GetDrCmd() * 0.01745; 
330         break;
331       case stFixed:
332         SteerAngle = 0.0;
333         break;
334       case stCaster:
335 // Note to Jon: This is not correct for castering gear.  I'll fix it later.
336         SteerAngle = 0.0;
337         break;
338       default:
339         cerr << "Improper steering type membership detected for this gear." << endl;
340         break;
341       }
342
343 // Transform the wheel velocities from the local axis system to the wheel axis system.
344 // For now, steering angle is assumed to happen in the Local Z axis,
345 // not the strut axis as it should be.  Will fix this later.
346
347       SinWheel      = sin(Rotation->Getpsi() + SteerAngle);
348       CosWheel      = cos(Rotation->Getpsi() + SteerAngle);
349       RollingWhlVel = vWhlVelVec(eX)*CosWheel + vWhlVelVec(eY)*SinWheel;
350       SideWhlVel    = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel;
351
352 // Calculate tire slip angle.
353
354       if (RollingWhlVel == 0.0 && SideWhlVel == 0.0) {
355         WheelSlip = 0.0;
356       } else if (fabs(RollingWhlVel) < 1.0) {
357         WheelSlip = 0.05*radtodeg*atan2(SideWhlVel, RollingWhlVel) + 0.95*WheelSlip;
358       } else {
359         WheelSlip = radtodeg*atan2(SideWhlVel, RollingWhlVel);
360       }
361 /*
362       double maxdeltaSlip = 0.5*deltaT;
363
364       if (RollingWhlVel == 0.0 && SideWhlVel == 0.0) {
365         WheelSlip = 0.0;
366       } else if (RollingWhlVel < 1.0) {
367         WheelSlip = radtodeg*atan2(SideWhlVel, RollingWhlVel);
368         deltaSlip = WheelSlip - lastWheelSlip;
369         if (fabs(deltaSlip) > maxdeltaSlip) {
370           if (WheelSlip > lastWheelSlip) {
371             WheelSlip = lastWheelSlip + maxdeltaSlip;
372           } else if (WheelSlip < lastWheelSlip) {
373             WheelSlip = lastWheelSlip - maxdeltaSlip;
374           }
375         }
376       } else {
377         WheelSlip = radtodeg*atan2(SideWhlVel, RollingWhlVel);
378       }
379
380       if ((WheelSlip < 0.0 && lastWheelSlip > 0.0) ||
381           (WheelSlip > 0.0 && lastWheelSlip < 0.0))
382       {
383         WheelSlip = 0.0;
384       }
385 */    
386       lastWheelSlip = WheelSlip;
387
388 // Compute the sideforce coefficients using similar assumptions to LaRCSim for now.
389 // Allow a maximum of 10 degrees tire slip angle before wheel slides.  At that point,
390 // transition from static to dynamic friction.  There are more complicated formulations
391 // of this that avoid the discrete jump.  Will fix this later.
392
393       if (fabs(WheelSlip) <= 20.0) {
394         FCoeff = staticFCoeff*WheelSlip/20.0;
395       } else if (fabs(WheelSlip) <= 40.0) {
396 //        FCoeff = dynamicFCoeff*fabs(WheelSlip)/WheelSlip;
397         FCoeff = (dynamicFCoeff*(fabs(WheelSlip) - 20.0)/20.0 + 
398                   staticFCoeff*(40.0 - fabs(WheelSlip))/20.0)*fabs(WheelSlip)/WheelSlip;
399       } else {
400         FCoeff = dynamicFCoeff*fabs(WheelSlip)/WheelSlip;
401       }
402
403 // Compute the vertical force on the wheel using square-law damping (per comment
404 // in paper AIAA-2000-4303 - see header prologue comments). We might consider
405 // allowing for both square and linear damping force calculation. Also need to
406 // possibly give a "rebound damping factor" that differs from the compression
407 // case.
408
409       vLocalForce(eZ) =  min(-compressLength * kSpring
410                              - compressSpeed * bDamp, (double)0.0);
411
412       MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ)));
413       MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
414
415 // Compute the forces in the wheel ground plane.
416
417       RollingForce = 0;
418       if (fabs(RollingWhlVel) > 1E-3) {
419         RollingForce = (1.0 - TirePressureNorm) * 30
420                        + vLocalForce(eZ) * BrakeFCoeff
421                        * fabs(RollingWhlVel)/RollingWhlVel;
422       }
423       SideForce    = vLocalForce(eZ) * FCoeff;
424
425 // Transform these forces back to the local reference frame.
426
427       vLocalForce(eX) = RollingForce*CosWheel - SideForce*SinWheel;
428       vLocalForce(eY) = SideForce*CosWheel    + RollingForce*SinWheel;
429
430 // Note to Jon: At this point the forces will be too big when the airplane is
431 // stopped or rolling to a stop.  We need to make sure that the gear forces just
432 // balance out the non-gear forces when the airplane is stopped.  That way the
433 // airplane won't start to accelerate until the non-gear/ forces are larger than
434 // the gear forces.  I think that the proper fix should go into FGAircraft::FMGear.
435 // This routine would only compute the local strut forces and return them to
436 // FMGear. All of the gear forces would get adjusted in FMGear using the total
437 // non-gear forces. Then the gear moments would be calculated. If strange things
438 // start happening to the airplane during testing as it rolls to a stop, then we
439 // need to implement this change.  I ran out of time to do it now but have the
440 // equations.
441
442 // Transform the forces back to the body frame and compute the moment.
443
444       vForce  = State->GetTl2b() * vLocalForce;
445       vMoment = vWhlBodyVec * vForce;
446
447     } else { // Gear is NOT compressed
448
449       WOW = false;
450
451       if (Position->GetDistanceAGL() > 200.0) {
452         FirstContact = false;
453         StartedGroundRun = false;
454         LandingReported = false;
455         LandingDistanceTraveled = 0.0;
456         MaximumStrutForce = MaximumStrutTravel = 0.0;
457       }
458
459       compressLength = 0.0; // reset compressLength to zero for data output validity
460     }
461
462     if (FirstContact) LandingDistanceTraveled += Position->GetVground()*deltaT;
463   
464     if (StartedGroundRun) {
465        TakeoffDistanceTraveled50ft += Position->GetVground()*deltaT;
466       if (WOW) TakeoffDistanceTraveled += Position->GetVground()*deltaT;
467     }
468
469     if (ReportEnable && Position->GetVground() <= 0.05 && !LandingReported) {
470       if (debug_lvl > 0) Report(erLand);
471     }
472
473     if (ReportEnable && !TakeoffReported &&
474        (vLocalGear(eZ) - Position->GetDistanceAGL()) < -50.0)
475     {
476       if (debug_lvl > 0) Report(erTakeoff);
477     }
478
479     if (lastWOW != WOW) {
480       PutMessage("GEAR_CONTACT: " + name, WOW);
481     }
482
483     lastWOW = WOW;
484
485 // Crash detection logic (really out-of-bounds detection)
486
487     if (compressLength > 500.0 ||
488         vForce.Magnitude() > 100000000.0 ||
489         vMoment.Magnitude() > 5000000000.0 ||
490         SinkRate > 1.4666*30)
491     {
492       PutMessage("Crash Detected: Simulation FREEZE.");
493       Exec->Freeze();
494     }
495   } 
496   return vForce; 
497 }
498
499 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
500
501 void FGLGear::Report(ReportType repType)
502 {
503   switch(repType) {
504   case erLand:
505     cout << endl << "Touchdown report for " << name << endl;
506     cout << "  Sink rate at contact:  " << SinkRate                << " fps,    "
507                                 << SinkRate*0.3048          << " mps"     << endl;
508     cout << "  Contact ground speed:  " << GroundSpeed*.5925       << " knots,  "
509                                 << GroundSpeed*0.3048       << " mps"     << endl;
510     cout << "  Maximum contact force: " << MaximumStrutForce       << " lbs,    "
511                                 << MaximumStrutForce*4.448  << " Newtons" << endl;
512     cout << "  Maximum strut travel:  " << MaximumStrutTravel*12.0 << " inches, "
513                                 << MaximumStrutTravel*30.48 << " cm"      << endl;
514     cout << "  Distance traveled:     " << LandingDistanceTraveled        << " ft,     "
515                                 << LandingDistanceTraveled*0.3048  << " meters"  << endl;
516     LandingReported = true;
517     break;
518   case erTakeoff:
519     cout << endl << "Takeoff report for " << name << endl;
520     cout << "  Distance traveled:                " << TakeoffDistanceTraveled
521          << " ft,     " << TakeoffDistanceTraveled*0.3048  << " meters"  << endl;
522     cout << "  Distance traveled (over 50'):     " << TakeoffDistanceTraveled50ft
523          << " ft,     " << TakeoffDistanceTraveled50ft*0.3048 << " meters" << endl;
524     TakeoffReported = true;
525     break;
526   }
527 }
528
529 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
530 //    The bitmasked value choices are as follows:
531 //    unset: In this case (the default) JSBSim would only print
532 //       out the normally expected messages, essentially echoing
533 //       the config files as they are read. If the environment
534 //       variable is not set, debug_lvl is set to 1 internally
535 //    0: This requests JSBSim not to output any messages
536 //       whatsoever.
537 //    1: This value explicity requests the normal JSBSim
538 //       startup messages
539 //    2: This value asks for a message to be printed out when
540 //       a class is instantiated
541 //    4: When this value is set, a message is displayed when a
542 //       FGModel object executes its Run() method
543 //    8: When this value is set, various runtime state variables
544 //       are printed out periodically
545 //    16: When set various parameters are sanity checked and
546 //       a message is printed out when they go out of bounds
547
548 void FGLGear::Debug(int from)
549 {
550   if (debug_lvl <= 0) return;
551
552   if (debug_lvl & 1) { // Standard console startup message output
553     if (from == 0) { // Constructor
554       cout << "    Name: "               << name          << endl;
555       cout << "      Location: "         << vXYZ          << endl;
556       cout << "      Spring Constant:  " << kSpring       << endl;
557       cout << "      Damping Constant: " << bDamp         << endl;
558       cout << "      Dynamic Friction: " << dynamicFCoeff << endl;
559       cout << "      Static Friction:  " << staticFCoeff  << endl;
560       cout << "      Rolling Friction: " << rollingFCoeff << endl;
561       cout << "      Steering Type:    " << sSteerType    << endl;
562       cout << "      Grouping:         " << sBrakeGroup   << endl;
563       cout << "      Max Steer Angle:  " << maxSteerAngle << endl;
564       cout << "      Retractable:      " << sRetractable  << endl;
565     }
566   }
567   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
568     if (from == 0) cout << "Instantiated: FGLGear" << endl;
569     if (from == 1) cout << "Destroyed:    FGLGear" << endl;
570   }
571   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
572   }
573   if (debug_lvl & 8 ) { // Runtime state variables
574   }
575   if (debug_lvl & 16) { // Sanity checking
576   }
577   if (debug_lvl & 64) {
578     if (from == 0) { // Constructor
579       cout << IdSrc << endl;
580       cout << IdHdr << endl;
581     }
582   }
583 }
584
585 } // namespace JSBSim
586