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