1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 Purpose: Encapsulates the landing gear elements
10 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
12 This program is free software; you can redistribute it and/or modify it under
13 the terms of the GNU Lesser General Public License as published by the Free Software
14 Foundation; either version 2 of the License, or (at your option) any later
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 Lesser General Public License for more
22 You should have received a copy of the GNU Lesser 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.
26 Further information about the GNU Lesser General Public License can also be found on
27 the world wide web at http://www.gnu.org.
29 FUNCTIONAL DESCRIPTION
30 --------------------------------------------------------------------------------
33 --------------------------------------------------------------------------------
35 01/30/01 NHP Extended gear model to properly simulate steering and braking
37 /%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53 static const char *IdSrc = "$Id$";
54 static const char *IdHdr = ID_LGEAR;
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
60 FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) :
64 Element *force_table=0;
66 Element *dampCoeffRebound=0;
69 kSpring = bDamp = bDampRebound = dynamicFCoeff = staticFCoeff = rollingFCoeff = maxSteerAngle = 0;
70 sSteerType = sBrakeGroup = sSteerType = "";
73 eDampTypeRebound = dtLinear;
75 name = el->GetAttributeValue("name");
76 sContactType = el->GetAttributeValue("type");
77 if (sContactType == "BOGEY") {
78 eContactType = ctBOGEY;
79 } else if (sContactType == "STRUCTURE") {
80 eContactType = ctSTRUCTURE;
82 eContactType = ctUNKNOWN;
85 if (el->FindElement("spring_coeff"))
86 kSpring = el->FindElementValueAsNumberConvertTo("spring_coeff", "LBS/FT");
87 if (el->FindElement("damping_coeff")) {
88 dampCoeff = el->FindElement("damping_coeff");
89 if (dampCoeff->GetAttributeValue("type") == "SQUARE") {
91 bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT2/SEC2");
93 bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT/SEC");
97 if (el->FindElement("damping_coeff_rebound")) {
98 dampCoeffRebound = el->FindElement("damping_coeff_rebound");
99 if (dampCoeffRebound->GetAttributeValue("type") == "SQUARE") {
100 eDampTypeRebound = dtSquare;
101 bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT2/SEC2");
103 bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT/SEC");
106 bDampRebound = bDamp;
107 eDampTypeRebound = eDampType;
110 if (el->FindElement("dynamic_friction"))
111 dynamicFCoeff = el->FindElementValueAsNumber("dynamic_friction");
112 if (el->FindElement("static_friction"))
113 staticFCoeff = el->FindElementValueAsNumber("static_friction");
114 if (el->FindElement("rolling_friction"))
115 rollingFCoeff = el->FindElementValueAsNumber("rolling_friction");
116 if (el->FindElement("max_steer"))
117 maxSteerAngle = el->FindElementValueAsNumberConvertTo("max_steer", "DEG");
118 if (el->FindElement("retractable"))
119 isRetractable = ((unsigned int)el->FindElementValueAsNumber("retractable"))>0.0?true:false;
122 force_table = el->FindElement("table");
123 while (force_table) {
124 force_type = force_table->GetAttributeValue("type");
125 if (force_type == "CORNERING_COEFF") {
126 ForceY_Table = new FGTable(Exec->GetPropertyManager(), force_table);
128 cerr << "Undefined force table for " << name << " contact point" << endl;
130 force_table = el->FindNextElement("table");
133 sBrakeGroup = el->FindElementValue("brake_group");
135 if (maxSteerAngle == 360) sSteerType = "CASTERED";
136 else if (maxSteerAngle == 0.0) sSteerType = "FIXED";
137 else sSteerType = "STEERABLE";
139 Element* element = el->FindElement("location");
140 if (element) vXYZ = element->FindElementTripletConvertTo("IN");
141 else {cerr << "No location given for contact " << name << endl; exit(-1);}
143 if (sBrakeGroup == "LEFT" ) eBrakeGrp = bgLeft;
144 else if (sBrakeGroup == "RIGHT" ) eBrakeGrp = bgRight;
145 else if (sBrakeGroup == "CENTER") eBrakeGrp = bgCenter;
146 else if (sBrakeGroup == "NOSE" ) eBrakeGrp = bgNose;
147 else if (sBrakeGroup == "TAIL" ) eBrakeGrp = bgTail;
148 else if (sBrakeGroup == "NONE" ) eBrakeGrp = bgNone;
149 else if (sBrakeGroup.empty() ) {eBrakeGrp = bgNone;
150 sBrakeGroup = "NONE (defaulted)";}
152 cerr << "Improper braking group specification in config file: "
153 << sBrakeGroup << " is undefined." << endl;
156 if (sSteerType == "STEERABLE") eSteerType = stSteer;
157 else if (sSteerType == "FIXED" ) eSteerType = stFixed;
158 else if (sSteerType == "CASTERED" ) eSteerType = stCaster;
159 else if (sSteerType.empty() ) {eSteerType = stFixed;
160 sSteerType = "FIXED (defaulted)";}
162 cerr << "Improper steering type specification in config file: "
163 << sSteerType << " is undefined." << endl;
166 RFRV = 0.7; // Rolling force relaxation velocity, default value
167 SFRV = 0.7; // Side force relaxation velocity, default value
169 Element* relax_vel = el->FindElement("relaxation_velocity");
171 if (relax_vel->FindElement("rolling")) {
172 RFRV = relax_vel->FindElementValueAsNumberConvertTo("rolling", "FT/SEC");
174 if (relax_vel->FindElement("side")) {
175 SFRV = relax_vel->FindElementValueAsNumberConvertTo("side", "FT/SEC");
179 State = Exec->GetState();
180 LongForceLagFilterCoeff = 1/State->Getdt(); // default longitudinal force filter coefficient
181 LatForceLagFilterCoeff = 1/State->Getdt(); // default lateral force filter coefficient
183 Element* force_lag_filter_elem = el->FindElement("force_lag_filter");
184 if (force_lag_filter_elem) {
185 if (force_lag_filter_elem->FindElement("rolling")) {
186 LongForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("rolling");
188 if (force_lag_filter_elem->FindElement("side")) {
189 LatForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("side");
193 LongForceFilter = Filter(LongForceLagFilterCoeff, State->Getdt());
194 LatForceFilter = Filter(LatForceLagFilterCoeff, State->Getdt());
196 WheelSlipLagFilterCoeff = 1/State->Getdt();
198 Element *wheel_slip_angle_lag_elem = el->FindElement("wheel_slip_filter");
199 if (wheel_slip_angle_lag_elem) {
200 WheelSlipLagFilterCoeff = wheel_slip_angle_lag_elem->GetDataAsNumber();
203 WheelSlipFilter = Filter(WheelSlipLagFilterCoeff, State->Getdt());
208 useFCSGearPos = false;
211 // Add some AI here to determine if gear is located properly according to its
212 // brake group type ??
214 State = Exec->GetState();
215 Aircraft = Exec->GetAircraft();
216 Propagate = Exec->GetPropagate();
217 Auxiliary = Exec->GetAuxiliary();
218 FCS = Exec->GetFCS();
219 MassBalance = Exec->GetMassBalance();
221 WOW = lastWOW = false;
223 FirstContact = false;
224 StartedGroundRun = false;
225 TakeoffReported = LandingReported = false;
226 LandingDistanceTraveled = TakeoffDistanceTraveled = TakeoffDistanceTraveled50ft = 0.0;
227 MaximumStrutForce = MaximumStrutTravel = 0.0;
228 SideForce = RollingForce = 0.0;
229 SinkRate = GroundSpeed = 0.0;
231 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ);
233 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec;
235 compressLength = 0.0;
241 TirePressureNorm = 1.0;
259 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
266 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
268 FGColumnVector3& FGLGear::Force(void)
270 double t = Exec->GetState()->Getsim_time();
271 dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
274 vMoment.InitMatrix();
276 if (isRetractable) ComputeRetractionState();
280 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ); // Get wheel in body frame
281 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec; // Get local frame wheel location
283 gearLoc = Propagate->GetLocation().LocalToLocation(vLocalGear);
284 compressLength = -Exec->GetGroundCallback()->GetAGLevel(t, gearLoc, contact, normal, cvel);
286 // The compression length is measured in the Z-axis, only, at this time.
288 if (compressLength > 0.00) {
292 // [The next equation should really use the vector to the contact patch of
293 // the tire including the strut compression and not the original vWhlBodyVec.]
295 vWhlVelVec = Propagate->GetTb2l() * (Propagate->GetPQR() * vWhlBodyVec);
296 vWhlVelVec += Propagate->GetVel() - cvel;
297 compressSpeed = vWhlVelVec(eZ);
299 InitializeReporting();
300 ComputeBrakeForceCoefficient();
301 ComputeSteeringAngle();
303 ComputeSideForceCoefficient();
304 ComputeVerticalStrutForce();
306 // Compute the forces in the wheel ground plane.
308 double sign = RollingWhlVel>0?1.0:(RollingWhlVel<0?-1.0:0.0);
309 RollingForce = ((1.0 - TirePressureNorm) * 30 + vLocalForce(eZ) * BrakeFCoeff) * sign;
310 SideForce = vLocalForce(eZ) * FCoeff;
312 // Transform these forces back to the local reference frame.
314 vLocalForce(eX) = RollingForce*CosWheel - SideForce*SinWheel;
315 vLocalForce(eY) = SideForce*CosWheel + RollingForce*SinWheel;
317 // Transform the forces back to the body frame and compute the moment.
319 vForce = Propagate->GetTl2b() * vLocalForce;
321 // Lag and attenuate the XY-plane forces dependent on velocity. This code
322 // uses a lag filter, C/(s + C) where "C" is the filter coefficient. When
323 // "C" is chosen at the frame rate (in Hz), the jittering is significantly
324 // reduced. This is because the jitter is present *at* the execution rate.
325 // If a coefficient is set to something equal to or less than zero, the
326 // filter is bypassed.
328 if (LongForceLagFilterCoeff > 0) vForce(eX) = LongForceFilter.execute(vForce(eX));
329 if (LatForceLagFilterCoeff > 0) vForce(eY) = LatForceFilter.execute(vForce(eY));
331 if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
332 if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) vForce(eY) *= fabs(SideWhlVel)/SFRV;
334 // End section for attentuating gear jitter
336 vMoment = vWhlBodyVec * vForce;
338 } else { // Gear is NOT compressed
341 compressLength = 0.0;
343 // No wheel conditons
344 RollingWhlVel = SideWhlVel = WheelSlip = 0.0;
346 // Return to neutral position between 1.0 and 0.8 gear pos.
347 SteerAngle *= max(GetGearUnitPos()-0.8, 0.0)/0.2;
353 ReportTakeoffOrLanding();
355 // Require both WOW and LastWOW to be true before checking crash conditions
356 // to allow the WOW flag to be used in terminating a scripted run.
357 if (WOW && lastWOW) CrashDetect();
364 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
366 void FGLGear::ComputeRetractionState(void)
368 double gearPos = GetGearUnitPos();
369 if (gearPos < 0.01) {
373 } else if (gearPos > 0.99) {
382 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
384 void FGLGear::ComputeSlipAngle(void)
386 // Transform the wheel velocities from the local axis system to the wheel axis system.
387 RollingWhlVel = vWhlVelVec(eX)*CosWheel + vWhlVelVec(eY)*SinWheel;
388 SideWhlVel = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel;
390 // Calculate tire slip angle.
391 WheelSlip = atan2(SideWhlVel, fabs(RollingWhlVel))*radtodeg;
393 // Filter the wheel slip angle
394 if (WheelSlipLagFilterCoeff > 0) WheelSlip = WheelSlipFilter.execute(WheelSlip);
397 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
398 // Compute the steering angle in any case.
399 // This will also make sure that animations will look right.
401 void FGLGear::ComputeSteeringAngle(void)
403 double casterLocalFrameAngleRad = 0.0;
404 double casterAngle = 0.0;
406 switch (eSteerType) {
408 SteerAngle = degtorad * FCS->GetSteerPosDeg(GearNumber);
414 // This is not correct for castering gear. Should make steer angle parallel
415 // to the actual velocity vector of the wheel, given aircraft velocity vector
418 casterLocalFrameAngleRad = acos(vWhlVelVec(eX)/vWhlVelVec.Magnitude());
419 casterAngle = casterLocalFrameAngleRad - Propagate->GetEuler(ePsi);
422 cerr << "Improper steering type membership detected for this gear." << endl;
426 SinWheel = sin(Propagate->GetEuler(ePsi) + SteerAngle);
427 CosWheel = cos(Propagate->GetEuler(ePsi) + SteerAngle);
430 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
431 // Reset reporting functionality after takeoff
433 void FGLGear::ResetReporting(void)
435 if (Propagate->GetDistanceAGL() > 200.0) {
436 FirstContact = false;
437 StartedGroundRun = false;
438 LandingReported = false;
439 TakeoffReported = true;
440 LandingDistanceTraveled = 0.0;
441 MaximumStrutForce = MaximumStrutTravel = 0.0;
445 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
447 void FGLGear::InitializeReporting(void)
449 // If this is the first time the wheel has made contact, remember some values
450 // for later printout.
454 SinkRate = compressSpeed;
455 GroundSpeed = Propagate->GetVel().Magnitude();
456 TakeoffReported = false;
459 // If the takeoff run is starting, initialize.
461 if ((Propagate->GetVel().Magnitude() > 0.1) &&
462 (FCS->GetBrake(bgLeft) == 0) &&
463 (FCS->GetBrake(bgRight) == 0) &&
464 (FCS->GetThrottlePos(0) > 0.90) && !StartedGroundRun)
466 TakeoffDistanceTraveled = 0;
467 TakeoffDistanceTraveled50ft = 0;
468 StartedGroundRun = true;
472 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
473 // Takeoff and landing reporting functionality
475 void FGLGear::ReportTakeoffOrLanding(void)
477 double deltaT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
480 LandingDistanceTraveled += Auxiliary->GetVground()*deltaT;
482 if (StartedGroundRun) {
483 TakeoffDistanceTraveled50ft += Auxiliary->GetVground()*deltaT;
484 if (WOW) TakeoffDistanceTraveled += Auxiliary->GetVground()*deltaT;
488 && Auxiliary->GetVground() <= 0.05
490 && Exec->GetGroundReactions()->GetWOW())
492 if (debug_lvl > 0) Report(erLand);
497 && (Propagate->GetDistanceAGL() - vLocalGear(eZ)) > 50.0
498 && !Exec->GetGroundReactions()->GetWOW())
500 if (debug_lvl > 0) Report(erTakeoff);
503 if (lastWOW != WOW) PutMessage("GEAR_CONTACT: " + name, WOW);
506 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
507 // Crash detection logic (really out-of-bounds detection)
509 void FGLGear::CrashDetect(void)
511 if ( (compressLength > 500.0 ||
512 vForce.Magnitude() > 100000000.0 ||
513 vMoment.Magnitude() > 5000000000.0 ||
514 SinkRate > 1.4666*30 ) && !State->IntegrationSuspended())
516 PutMessage("Crash Detected: Simulation FREEZE.");
517 State->SuspendIntegration();
521 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
522 // The following needs work regarding friction coefficients and braking and
523 // steering The BrakeFCoeff formula assumes that an anti-skid system is used.
524 // It also assumes that we won't be turning and braking at the same time.
525 // Will fix this later.
526 // [JSB] The braking force coefficients include normal rolling coefficient +
527 // a percentage of the static friction coefficient based on braking applied.
529 void FGLGear::ComputeBrakeForceCoefficient(void)
533 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
534 staticFCoeff*FCS->GetBrake(bgLeft) );
537 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
538 staticFCoeff*FCS->GetBrake(bgRight) );
541 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
542 staticFCoeff*FCS->GetBrake(bgCenter) );
545 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
546 staticFCoeff*FCS->GetBrake(bgCenter) );
549 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
550 staticFCoeff*FCS->GetBrake(bgCenter) );
553 BrakeFCoeff = rollingFCoeff;
556 cerr << "Improper brake group membership detected for this gear." << endl;
561 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
562 // Compute the sideforce coefficients using Pacejka's Magic Formula.
564 // y(x) = D sin {C arctan [Bx - E(Bx - arctan Bx)]}
566 // Where: B = Stiffness Factor (0.06, here)
567 // C = Shape Factor (2.8, here)
568 // D = Peak Factor (0.8, here)
569 // E = Curvature Factor (1.03, here)
571 void FGLGear::ComputeSideForceCoefficient(void)
574 FCoeff = ForceY_Table->GetValue(WheelSlip);
576 double StiffSlip = Stiffness*WheelSlip;
577 FCoeff = Peak * sin(Shape*atan(StiffSlip - Curvature*(StiffSlip - atan(StiffSlip))));
581 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
582 // Compute the vertical force on the wheel using square-law damping (per comment
583 // in paper AIAA-2000-4303 - see header prologue comments). We might consider
584 // allowing for both square and linear damping force calculation. Also need to
585 // possibly give a "rebound damping factor" that differs from the compression
588 void FGLGear::ComputeVerticalStrutForce(void)
590 double springForce = 0;
591 double dampForce = 0;
593 springForce = -compressLength * kSpring;
595 if (compressSpeed >= 0.0) {
597 if (eDampType == dtLinear) dampForce = -compressSpeed * bDamp;
598 else dampForce = -compressSpeed * compressSpeed * bDamp;
602 if (eDampTypeRebound == dtLinear)
603 dampForce = -compressSpeed * bDampRebound;
605 dampForce = compressSpeed * compressSpeed * bDampRebound;
608 vLocalForce(eZ) = min(springForce + dampForce, (double)0.0);
610 // Remember these values for reporting
611 MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ)));
612 MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
615 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
617 double FGLGear::GetGearUnitPos(void)
619 // hack to provide backward compatibility to gear/gear-pos-norm property
620 if( useFCSGearPos || FCS->GetGearPos() != 1.0 ) {
621 useFCSGearPos = true;
622 return FCS->GetGearPos();
627 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
629 void FGLGear::bind(void)
631 string property_name;
632 string base_property_name;
633 base_property_name = CreateIndexedPropertyName("gear/unit", GearNumber);
634 if (eContactType == ctBOGEY) {
635 property_name = base_property_name + "/slip-angle-deg";
636 Exec->GetPropertyManager()->Tie( property_name.c_str(), &WheelSlip );
637 property_name = base_property_name + "/WOW";
638 Exec->GetPropertyManager()->Tie( property_name.c_str(), &WOW );
639 property_name = base_property_name + "/wheel-speed-fps";
640 Exec->GetPropertyManager()->Tie( property_name.c_str(), &RollingWhlVel );
641 property_name = base_property_name + "/z-position";
642 Exec->GetPropertyManager()->Tie( property_name.c_str(), (FGLGear*)this,
643 &FGLGear::GetZPosition, &FGLGear::SetZPosition);
644 property_name = base_property_name + "/compression-ft";
645 Exec->GetPropertyManager()->Tie( property_name.c_str(), &compressLength );
646 property_name = base_property_name + "/side_friction_coeff";
647 Exec->GetPropertyManager()->Tie( property_name.c_str(), &FCoeff );
650 if( isRetractable ) {
651 property_name = base_property_name + "/pos-norm";
652 Exec->GetPropertyManager()->Tie( property_name.c_str(), &GearPos );
657 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
659 void FGLGear::Report(ReportType repType)
661 if (fabs(TakeoffDistanceTraveled) < 0.001) return; // Don't print superfluous reports
665 cout << endl << "Touchdown report for " << name << endl;
666 cout << " Sink rate at contact: " << SinkRate << " fps, "
667 << SinkRate*0.3048 << " mps" << endl;
668 cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, "
669 << GroundSpeed*0.3048 << " mps" << endl;
670 cout << " Maximum contact force: " << MaximumStrutForce << " lbs, "
671 << MaximumStrutForce*4.448 << " Newtons" << endl;
672 cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, "
673 << MaximumStrutTravel*30.48 << " cm" << endl;
674 cout << " Distance traveled: " << LandingDistanceTraveled << " ft, "
675 << LandingDistanceTraveled*0.3048 << " meters" << endl;
676 LandingReported = true;
679 cout << endl << "Takeoff report for " << name << endl;
680 cout << " Distance traveled: " << TakeoffDistanceTraveled
681 << " ft, " << TakeoffDistanceTraveled*0.3048 << " meters" << endl;
682 cout << " Distance traveled (over 50'): " << TakeoffDistanceTraveled50ft
683 << " ft, " << TakeoffDistanceTraveled50ft*0.3048 << " meters" << endl;
684 TakeoffReported = true;
689 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
690 // The bitmasked value choices are as follows:
691 // unset: In this case (the default) JSBSim would only print
692 // out the normally expected messages, essentially echoing
693 // the config files as they are read. If the environment
694 // variable is not set, debug_lvl is set to 1 internally
695 // 0: This requests JSBSim not to output any messages
697 // 1: This value explicity requests the normal JSBSim
699 // 2: This value asks for a message to be printed out when
700 // a class is instantiated
701 // 4: When this value is set, a message is displayed when a
702 // FGModel object executes its Run() method
703 // 8: When this value is set, various runtime state variables
704 // are printed out periodically
705 // 16: When set various parameters are sanity checked and
706 // a message is printed out when they go out of bounds
708 void FGLGear::Debug(int from)
710 if (debug_lvl <= 0) return;
712 if (debug_lvl & 1) { // Standard console startup message output
713 if (from == 0) { // Constructor - loading and initialization
714 cout << " " << sContactType << " " << name << endl;
715 cout << " Location: " << vXYZ << endl;
716 cout << " Spring Constant: " << kSpring << endl;
718 if (eDampType == dtLinear)
719 cout << " Damping Constant: " << bDamp << " (linear)" << endl;
721 cout << " Damping Constant: " << bDamp << " (square law)" << endl;
723 if (eDampTypeRebound == dtLinear)
724 cout << " Rebound Damping Constant: " << bDampRebound << " (linear)" << endl;
726 cout << " Rebound Damping Constant: " << bDampRebound << " (square law)" << endl;
728 cout << " Dynamic Friction: " << dynamicFCoeff << endl;
729 cout << " Static Friction: " << staticFCoeff << endl;
730 if (eContactType == ctBOGEY) {
731 cout << " Rolling Friction: " << rollingFCoeff << endl;
732 cout << " Steering Type: " << sSteerType << endl;
733 cout << " Grouping: " << sBrakeGroup << endl;
734 cout << " Max Steer Angle: " << maxSteerAngle << endl;
735 cout << " Retractable: " << isRetractable << endl;
736 cout << " Relaxation Velocities:" << endl;
737 cout << " Rolling: " << RFRV << endl;
738 cout << " Side: " << SFRV << endl;
742 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
743 if (from == 0) cout << "Instantiated: FGLGear" << endl;
744 if (from == 1) cout << "Destroyed: FGLGear" << endl;
746 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
748 if (debug_lvl & 8 ) { // Runtime state variables
750 if (debug_lvl & 16) { // Sanity checking
752 if (debug_lvl & 64) {
753 if (from == 0) { // Constructor
754 cout << IdSrc << endl;
755 cout << IdHdr << endl;
760 } // namespace JSBSim