1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8 Purpose: Encapsulates the landing gear elements
11 ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU Lesser General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
23 You should have received a copy of the GNU Lesser General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
25 Place - Suite 330, Boston, MA 02111-1307, USA.
27 Further information about the GNU Lesser General Public License can also be found on
28 the world wide web at http://www.gnu.org.
30 FUNCTIONAL DESCRIPTION
31 --------------------------------------------------------------------------------
34 --------------------------------------------------------------------------------
36 01/30/01 NHP Extended gear model to properly simulate steering and braking
37 07/08/09 BC Modified gear model to support large angles between aircraft and ground
39 /%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55 static const char *IdSrc = "$Id$";
56 static const char *IdHdr = ID_LGEAR;
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62 FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) :
66 Element *force_table=0;
68 Element *dampCoeffRebound=0;
71 kSpring = bDamp = bDampRebound = dynamicFCoeff = staticFCoeff = rollingFCoeff = maxSteerAngle = 0;
72 sSteerType = sBrakeGroup = sSteerType = "";
75 eDampTypeRebound = dtLinear;
77 name = el->GetAttributeValue("name");
78 sContactType = el->GetAttributeValue("type");
79 if (sContactType == "BOGEY") {
80 eContactType = ctBOGEY;
81 } else if (sContactType == "STRUCTURE") {
82 eContactType = ctSTRUCTURE;
84 eContactType = ctUNKNOWN;
87 if (el->FindElement("spring_coeff"))
88 kSpring = el->FindElementValueAsNumberConvertTo("spring_coeff", "LBS/FT");
89 if (el->FindElement("damping_coeff")) {
90 dampCoeff = el->FindElement("damping_coeff");
91 if (dampCoeff->GetAttributeValue("type") == "SQUARE") {
93 bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT2/SEC2");
95 bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT/SEC");
99 if (el->FindElement("damping_coeff_rebound")) {
100 dampCoeffRebound = el->FindElement("damping_coeff_rebound");
101 if (dampCoeffRebound->GetAttributeValue("type") == "SQUARE") {
102 eDampTypeRebound = dtSquare;
103 bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT2/SEC2");
105 bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT/SEC");
108 bDampRebound = bDamp;
109 eDampTypeRebound = eDampType;
112 if (el->FindElement("dynamic_friction"))
113 dynamicFCoeff = el->FindElementValueAsNumber("dynamic_friction");
114 if (el->FindElement("static_friction"))
115 staticFCoeff = el->FindElementValueAsNumber("static_friction");
116 if (el->FindElement("rolling_friction"))
117 rollingFCoeff = el->FindElementValueAsNumber("rolling_friction");
118 if (el->FindElement("max_steer"))
119 maxSteerAngle = el->FindElementValueAsNumberConvertTo("max_steer", "DEG");
120 if (el->FindElement("retractable"))
121 isRetractable = ((unsigned int)el->FindElementValueAsNumber("retractable"))>0.0?true:false;
124 force_table = el->FindElement("table");
125 while (force_table) {
126 force_type = force_table->GetAttributeValue("type");
127 if (force_type == "CORNERING_COEFF") {
128 ForceY_Table = new FGTable(Exec->GetPropertyManager(), force_table);
130 cerr << "Undefined force table for " << name << " contact point" << endl;
132 force_table = el->FindNextElement("table");
135 sBrakeGroup = el->FindElementValue("brake_group");
137 if (maxSteerAngle == 360) sSteerType = "CASTERED";
138 else if (maxSteerAngle == 0.0) sSteerType = "FIXED";
139 else sSteerType = "STEERABLE";
141 Element* element = el->FindElement("location");
142 if (element) vXYZ = element->FindElementTripletConvertTo("IN");
143 else {cerr << "No location given for contact " << name << endl; exit(-1);}
145 if (sBrakeGroup == "LEFT" ) eBrakeGrp = bgLeft;
146 else if (sBrakeGroup == "RIGHT" ) eBrakeGrp = bgRight;
147 else if (sBrakeGroup == "CENTER") eBrakeGrp = bgCenter;
148 else if (sBrakeGroup == "NOSE" ) eBrakeGrp = bgNose;
149 else if (sBrakeGroup == "TAIL" ) eBrakeGrp = bgTail;
150 else if (sBrakeGroup == "NONE" ) eBrakeGrp = bgNone;
151 else if (sBrakeGroup.empty() ) {eBrakeGrp = bgNone;
152 sBrakeGroup = "NONE (defaulted)";}
154 cerr << "Improper braking group specification in config file: "
155 << sBrakeGroup << " is undefined." << endl;
158 if (sSteerType == "STEERABLE") eSteerType = stSteer;
159 else if (sSteerType == "FIXED" ) eSteerType = stFixed;
160 else if (sSteerType == "CASTERED" ) eSteerType = stCaster;
161 else if (sSteerType.empty() ) {eSteerType = stFixed;
162 sSteerType = "FIXED (defaulted)";}
164 cerr << "Improper steering type specification in config file: "
165 << sSteerType << " is undefined." << endl;
168 RFRV = 0.7; // Rolling force relaxation velocity, default value
169 SFRV = 0.7; // Side force relaxation velocity, default value
171 Element* relax_vel = el->FindElement("relaxation_velocity");
173 if (relax_vel->FindElement("rolling")) {
174 RFRV = relax_vel->FindElementValueAsNumberConvertTo("rolling", "FT/SEC");
176 if (relax_vel->FindElement("side")) {
177 SFRV = relax_vel->FindElementValueAsNumberConvertTo("side", "FT/SEC");
181 State = Exec->GetState();
182 LongForceLagFilterCoeff = 1/State->Getdt(); // default longitudinal force filter coefficient
183 LatForceLagFilterCoeff = 1/State->Getdt(); // default lateral force filter coefficient
185 Element* force_lag_filter_elem = el->FindElement("force_lag_filter");
186 if (force_lag_filter_elem) {
187 if (force_lag_filter_elem->FindElement("rolling")) {
188 LongForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("rolling");
190 if (force_lag_filter_elem->FindElement("side")) {
191 LatForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("side");
195 LongForceFilter = Filter(LongForceLagFilterCoeff, State->Getdt());
196 LatForceFilter = Filter(LatForceLagFilterCoeff, State->Getdt());
198 WheelSlipLagFilterCoeff = 1/State->Getdt();
200 Element *wheel_slip_angle_lag_elem = el->FindElement("wheel_slip_filter");
201 if (wheel_slip_angle_lag_elem) {
202 WheelSlipLagFilterCoeff = wheel_slip_angle_lag_elem->GetDataAsNumber();
205 WheelSlipFilter = Filter(WheelSlipLagFilterCoeff, State->Getdt());
210 useFCSGearPos = false;
213 // Add some AI here to determine if gear is located properly according to its
214 // brake group type ??
216 State = Exec->GetState();
217 Aircraft = Exec->GetAircraft();
218 Propagate = Exec->GetPropagate();
219 Auxiliary = Exec->GetAuxiliary();
220 FCS = Exec->GetFCS();
221 MassBalance = Exec->GetMassBalance();
223 WOW = lastWOW = false;
225 FirstContact = false;
226 StartedGroundRun = false;
227 TakeoffReported = LandingReported = false;
228 LandingDistanceTraveled = TakeoffDistanceTraveled = TakeoffDistanceTraveled50ft = 0.0;
229 MaximumStrutForce = MaximumStrutTravel = 0.0;
230 SinkRate = GroundSpeed = 0.0;
232 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ);
234 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec;
236 vLocalWhlVel.InitMatrix();
238 compressLength = 0.0;
244 TirePressureNorm = 1.0;
256 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
264 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
266 FGColumnVector3& FGLGear::Force(void)
268 double t = Exec->GetState()->Getsim_time();
269 dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
272 vLocalForce.InitMatrix();
273 vMoment.InitMatrix();
275 if (isRetractable) ComputeRetractionState();
279 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ); // Get wheel in body frame
280 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec; // Get local frame wheel location
282 gearLoc = Propagate->GetLocation().LocalToLocation(vLocalGear);
283 // Compute the height of the theoretical location of the wheel (if strut is not compressed) with
284 // respect to the ground level
285 double height = Exec->GetGroundCallback()->GetAGLevel(t, gearLoc, contact, normal, cvel);
286 vGroundNormal = -1. * Propagate->GetTec2b() * normal;
288 switch (eContactType) {
290 // Project the height in the local coordinate frame of the strut to compute the actual compression
291 // length. The strut is assumed to be parallel to Z in the body frame.
292 compressLength = vGroundNormal(eZ) < 0.0 ? height / vGroundNormal(eZ) : 0.0;
295 compressLength = -height;
299 if (compressLength > 0.00) {
303 // [The next equation should really use the vector to the contact patch of
304 // the tire including the strut compression and not the original vWhlBodyVec.]
306 FGColumnVector3 vWhlContactVec = vWhlBodyVec - FGColumnVector3(0., 0., compressLength);
307 vWhlVelVec = Propagate->GetPQR() * vWhlContactVec;
308 vWhlVelVec += Propagate->GetUVW() - Propagate->GetTec2b() * cvel;
310 InitializeReporting();
311 ComputeSteeringAngle();
312 ComputeGroundCoordSys();
314 vLocalWhlVel = Tb2g * vWhlVelVec;
316 compressSpeed = -vLocalWhlVel(eZ);
317 if (eContactType == ctBOGEY)
318 // Project the compression speed in the local coordinate frame of the strut
319 compressSpeed /= -vGroundNormal(eZ);
321 ComputeVerticalStrutForce();
323 // Compute the forces in the wheel ground plane.
324 if (eContactType == ctBOGEY) {
326 ComputeBrakeForceCoefficient();
327 ComputeSideForceCoefficient();
328 double sign = vLocalWhlVel(eX)>0?1.0:(vLocalWhlVel(eX)<0?-1.0:0.0);
329 vLocalForce(eX) = - ((1.0 - TirePressureNorm) * 30 + vLocalForce(eZ) * BrakeFCoeff) * sign;
330 vLocalForce(eY) = vLocalForce(eZ) * FCoeff;
332 else if (eContactType == ctSTRUCTURE) {
333 FGColumnVector3 vSlipVec = vLocalWhlVel;
335 vSlipVec.Normalize();
336 vLocalForce -= staticFCoeff * vLocalForce(eZ) * vSlipVec;
339 // Lag and attenuate the XY-plane forces dependent on velocity. This code
340 // uses a lag filter, C/(s + C) where "C" is the filter coefficient. When
341 // "C" is chosen at the frame rate (in Hz), the jittering is significantly
342 // reduced. This is because the jitter is present *at* the execution rate.
343 // If a coefficient is set to something equal to or less than zero, the
344 // filter is bypassed.
346 if (LongForceLagFilterCoeff > 0) vLocalForce(eX) = LongForceFilter.execute(vLocalForce(eX));
347 if (LatForceLagFilterCoeff > 0) vLocalForce(eY) = LatForceFilter.execute(vLocalForce(eY));
349 if ((fabs(vLocalWhlVel(eX)) <= RFRV) && RFRV > 0) vLocalForce(eX) *= fabs(vLocalWhlVel(eX))/RFRV;
350 if ((fabs(vLocalWhlVel(eY)) <= SFRV) && SFRV > 0) vLocalForce(eY) *= fabs(vLocalWhlVel(eY))/SFRV;
352 // End section for attenuating gear jitter
354 // Transform the forces back to the body frame and compute the moment.
356 vForce = Tg2b * vLocalForce;
357 vMoment = vWhlContactVec * vForce;
359 } else { // Gear is NOT compressed
362 compressLength = 0.0;
365 // Let wheel spin down slowly
366 vLocalWhlVel(eX) -= 13.0*dT;
367 if (vLocalWhlVel(eX) < 0.0) vLocalWhlVel(eX) = 0.0;
369 // Return to neutral position between 1.0 and 0.8 gear pos.
370 SteerAngle *= max(GetGearUnitPos()-0.8, 0.0)/0.2;
376 ReportTakeoffOrLanding();
378 // Require both WOW and LastWOW to be true before checking crash conditions
379 // to allow the WOW flag to be used in terminating a scripted run.
380 if (WOW && lastWOW) CrashDetect();
387 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
388 // Build a local "ground" coordinate system defined by
389 // eX : projection of the rolling direction on the ground
390 // eY : projection of the sliping direction on the ground
391 // eZ : normal to the ground
393 void FGLGear::ComputeGroundCoordSys(void)
395 // Compute the rolling direction projected on the ground
396 // It consists in finding a vector 'r' such that 'r' lies in the plane (w,z) and r.n = 0 (scalar
398 // 'n' is the normal to the ground,
399 // (x,y,z) are the directions defined in the body coord system
400 // and 'w' is 'x' rotated by the steering angle (SteerAngle) in the plane (x,y).
401 // r = u * w + v * z and r.n = 0 => v/u = -w.n/z.n = a
402 // We also want u**2+v**2=1 and u > 0 (i.e. r orientated in the same 'direction' than w)
403 // after some arithmetic, one finds that :
404 double a = -(vGroundNormal(eX)*cos(SteerAngle)+vGroundNormal(eY)*sin(SteerAngle)) / vGroundNormal(eZ);
405 double u = 1. / sqrt(1. + a*a);
407 FGColumnVector3 vRollingGroundVec = FGColumnVector3(u * cos(SteerAngle), u * sin(SteerAngle), v);
409 // The sliping direction is the cross product multiplication of the ground normal and rolling
411 FGColumnVector3 vSlipGroundVec = vGroundNormal * vRollingGroundVec;
413 Tg2b(1,1) = vRollingGroundVec(eX);
414 Tg2b(2,1) = vRollingGroundVec(eY);
415 Tg2b(3,1) = vRollingGroundVec(eZ);
416 Tg2b(1,2) = vSlipGroundVec(eX);
417 Tg2b(2,2) = vSlipGroundVec(eY);
418 Tg2b(3,2) = vSlipGroundVec(eZ);
419 Tg2b(1,3) = vGroundNormal(eX);
420 Tg2b(2,3) = vGroundNormal(eY);
421 Tg2b(3,3) = vGroundNormal(eZ);
423 Tb2g = Tg2b.Transposed();
426 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
428 void FGLGear::ComputeRetractionState(void)
430 double gearPos = GetGearUnitPos();
431 if (gearPos < 0.01) {
435 vLocalWhlVel.InitMatrix();
436 } else if (gearPos > 0.99) {
445 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
447 void FGLGear::ComputeSlipAngle(void)
449 // Calculate tire slip angle.
450 WheelSlip = -atan2(vLocalWhlVel(eY), fabs(vLocalWhlVel(eX)))*radtodeg;
452 // Filter the wheel slip angle
453 if (WheelSlipLagFilterCoeff > 0) WheelSlip = WheelSlipFilter.execute(WheelSlip);
456 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
457 // Compute the steering angle in any case.
458 // This will also make sure that animations will look right.
460 void FGLGear::ComputeSteeringAngle(void)
462 switch (eSteerType) {
464 SteerAngle = degtorad * FCS->GetSteerPosDeg(GearNumber);
470 SteerAngle = atan2(fabs(vWhlVelVec(eX)), vWhlVelVec(eY));
473 cerr << "Improper steering type membership detected for this gear." << endl;
478 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
479 // Reset reporting functionality after takeoff
481 void FGLGear::ResetReporting(void)
483 if (Propagate->GetDistanceAGL() > 200.0) {
484 FirstContact = false;
485 StartedGroundRun = false;
486 LandingReported = false;
487 TakeoffReported = true;
488 LandingDistanceTraveled = 0.0;
489 MaximumStrutForce = MaximumStrutTravel = 0.0;
493 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
495 void FGLGear::InitializeReporting(void)
497 // If this is the first time the wheel has made contact, remember some values
498 // for later printout.
502 SinkRate = compressSpeed;
503 GroundSpeed = Propagate->GetVel().Magnitude();
504 TakeoffReported = false;
507 // If the takeoff run is starting, initialize.
509 if ((Propagate->GetVel().Magnitude() > 0.1) &&
510 (FCS->GetBrake(bgLeft) == 0) &&
511 (FCS->GetBrake(bgRight) == 0) &&
512 (FCS->GetThrottlePos(0) > 0.90) && !StartedGroundRun)
514 TakeoffDistanceTraveled = 0;
515 TakeoffDistanceTraveled50ft = 0;
516 StartedGroundRun = true;
520 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
521 // Takeoff and landing reporting functionality
523 void FGLGear::ReportTakeoffOrLanding(void)
525 double deltaT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
528 LandingDistanceTraveled += Auxiliary->GetVground()*deltaT;
530 if (StartedGroundRun) {
531 TakeoffDistanceTraveled50ft += Auxiliary->GetVground()*deltaT;
532 if (WOW) TakeoffDistanceTraveled += Auxiliary->GetVground()*deltaT;
536 && Auxiliary->GetVground() <= 0.05
538 && Exec->GetGroundReactions()->GetWOW())
540 if (debug_lvl > 0) Report(erLand);
545 && (Propagate->GetDistanceAGL() - vLocalGear(eZ)) > 50.0
546 && !Exec->GetGroundReactions()->GetWOW())
548 if (debug_lvl > 0) Report(erTakeoff);
551 if (lastWOW != WOW) PutMessage("GEAR_CONTACT: " + name, WOW);
554 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
555 // Crash detection logic (really out-of-bounds detection)
557 void FGLGear::CrashDetect(void)
559 if ( (compressLength > 500.0 ||
560 vForce.Magnitude() > 100000000.0 ||
561 vMoment.Magnitude() > 5000000000.0 ||
562 SinkRate > 1.4666*30 ) && !State->IntegrationSuspended())
564 PutMessage("Crash Detected: Simulation FREEZE.");
565 State->SuspendIntegration();
569 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
570 // The following needs work regarding friction coefficients and braking and
571 // steering The BrakeFCoeff formula assumes that an anti-skid system is used.
572 // It also assumes that we won't be turning and braking at the same time.
573 // Will fix this later.
574 // [JSB] The braking force coefficients include normal rolling coefficient +
575 // a percentage of the static friction coefficient based on braking applied.
577 void FGLGear::ComputeBrakeForceCoefficient(void)
581 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
582 staticFCoeff*FCS->GetBrake(bgLeft) );
585 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
586 staticFCoeff*FCS->GetBrake(bgRight) );
589 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
590 staticFCoeff*FCS->GetBrake(bgCenter) );
593 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
594 staticFCoeff*FCS->GetBrake(bgCenter) );
597 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
598 staticFCoeff*FCS->GetBrake(bgCenter) );
601 BrakeFCoeff = rollingFCoeff;
604 cerr << "Improper brake group membership detected for this gear." << endl;
609 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
610 // Compute the sideforce coefficients using Pacejka's Magic Formula.
612 // y(x) = D sin {C arctan [Bx - E(Bx - arctan Bx)]}
614 // Where: B = Stiffness Factor (0.06, here)
615 // C = Shape Factor (2.8, here)
616 // D = Peak Factor (0.8, here)
617 // E = Curvature Factor (1.03, here)
619 void FGLGear::ComputeSideForceCoefficient(void)
622 FCoeff = ForceY_Table->GetValue(WheelSlip);
624 double StiffSlip = Stiffness*WheelSlip;
625 FCoeff = Peak * sin(Shape*atan(StiffSlip - Curvature*(StiffSlip - atan(StiffSlip))));
629 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
630 // Compute the vertical force on the wheel using square-law damping (per comment
631 // in paper AIAA-2000-4303 - see header prologue comments). We might consider
632 // allowing for both square and linear damping force calculation. Also need to
633 // possibly give a "rebound damping factor" that differs from the compression
636 void FGLGear::ComputeVerticalStrutForce(void)
638 double springForce = 0;
639 double dampForce = 0;
641 springForce = -compressLength * kSpring;
643 if (compressSpeed >= 0.0) {
645 if (eDampType == dtLinear) dampForce = -compressSpeed * bDamp;
646 else dampForce = -compressSpeed * compressSpeed * bDamp;
650 if (eDampTypeRebound == dtLinear)
651 dampForce = -compressSpeed * bDampRebound;
653 dampForce = compressSpeed * compressSpeed * bDampRebound;
657 StrutForce = min(springForce + dampForce, (double)0.0);
659 // The reaction force of the wheel is always normal to the ground
660 switch (eContactType) {
662 // Project back the strut force in the local coordinate frame of the ground
663 vLocalForce(eZ) = StrutForce / vGroundNormal(eZ);
666 vLocalForce(eZ) = -StrutForce;
670 // Remember these values for reporting
671 MaximumStrutForce = max(MaximumStrutForce, fabs(StrutForce));
672 MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
675 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
677 double FGLGear::GetGearUnitPos(void)
679 // hack to provide backward compatibility to gear/gear-pos-norm property
680 if( useFCSGearPos || FCS->GetGearPos() != 1.0 ) {
681 useFCSGearPos = true;
682 return FCS->GetGearPos();
687 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
689 void FGLGear::bind(void)
691 string property_name;
692 string base_property_name;
693 base_property_name = CreateIndexedPropertyName("gear/unit", GearNumber);
694 if (eContactType == ctBOGEY) {
695 property_name = base_property_name + "/slip-angle-deg";
696 Exec->GetPropertyManager()->Tie( property_name.c_str(), &WheelSlip );
697 property_name = base_property_name + "/WOW";
698 Exec->GetPropertyManager()->Tie( property_name.c_str(), &WOW );
699 property_name = base_property_name + "/wheel-speed-fps";
700 Exec->GetPropertyManager()->Tie( property_name.c_str(), (FGLGear*)this,
701 &FGLGear::GetWheelRollVel);
702 property_name = base_property_name + "/z-position";
703 Exec->GetPropertyManager()->Tie( property_name.c_str(), (FGLGear*)this,
704 &FGLGear::GetZPosition, &FGLGear::SetZPosition);
705 property_name = base_property_name + "/compression-ft";
706 Exec->GetPropertyManager()->Tie( property_name.c_str(), &compressLength );
707 property_name = base_property_name + "/side_friction_coeff";
708 Exec->GetPropertyManager()->Tie( property_name.c_str(), &FCoeff );
710 property_name = base_property_name + "/static_friction_coeff";
711 Exec->GetPropertyManager()->Tie( property_name.c_str(), &staticFCoeff );
715 if( isRetractable ) {
716 property_name = base_property_name + "/pos-norm";
717 Exec->GetPropertyManager()->Tie( property_name.c_str(), &GearPos );
722 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
724 void FGLGear::Report(ReportType repType)
726 if (fabs(TakeoffDistanceTraveled) < 0.001) return; // Don't print superfluous reports
730 cout << endl << "Touchdown report for " << name << " (WOW at time: "
731 << Exec->GetState()->Getsim_time() << " seconds)" << endl;
732 cout << " Sink rate at contact: " << SinkRate << " fps, "
733 << SinkRate*0.3048 << " mps" << endl;
734 cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, "
735 << GroundSpeed*0.3048 << " mps" << endl;
736 cout << " Maximum contact force: " << MaximumStrutForce << " lbs, "
737 << MaximumStrutForce*4.448 << " Newtons" << endl;
738 cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, "
739 << MaximumStrutTravel*30.48 << " cm" << endl;
740 cout << " Distance traveled: " << LandingDistanceTraveled << " ft, "
741 << LandingDistanceTraveled*0.3048 << " meters" << endl;
742 LandingReported = true;
745 cout << endl << "Takeoff report for " << name << " (Liftoff at time: "
746 << Exec->GetState()->Getsim_time() << " seconds)" << endl;
747 cout << " Distance traveled: " << TakeoffDistanceTraveled
748 << " ft, " << TakeoffDistanceTraveled*0.3048 << " meters" << endl;
749 cout << " Distance traveled (over 50'): " << TakeoffDistanceTraveled50ft
750 << " ft, " << TakeoffDistanceTraveled50ft*0.3048 << " meters" << endl;
751 cout << " [Altitude (ASL): " << Exec->GetPropagate()->GetAltitudeASL() << " ft. / "
752 << Exec->GetPropagate()->GetAltitudeASLmeters() << " m | Temperature: "
753 << Exec->GetAtmosphere()->GetTemperature() - 459.67 << " F / "
754 << RankineToCelsius(Exec->GetAtmosphere()->GetTemperature()) << " C]" << endl;
755 cout << " [Velocity (KCAS): " << Exec->GetAuxiliary()->GetVcalibratedKTS() << "]" << endl;
756 TakeoffReported = true;
761 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
762 // The bitmasked value choices are as follows:
763 // unset: In this case (the default) JSBSim would only print
764 // out the normally expected messages, essentially echoing
765 // the config files as they are read. If the environment
766 // variable is not set, debug_lvl is set to 1 internally
767 // 0: This requests JSBSim not to output any messages
769 // 1: This value explicity requests the normal JSBSim
771 // 2: This value asks for a message to be printed out when
772 // a class is instantiated
773 // 4: When this value is set, a message is displayed when a
774 // FGModel object executes its Run() method
775 // 8: When this value is set, various runtime state variables
776 // are printed out periodically
777 // 16: When set various parameters are sanity checked and
778 // a message is printed out when they go out of bounds
780 void FGLGear::Debug(int from)
782 if (debug_lvl <= 0) return;
784 if (debug_lvl & 1) { // Standard console startup message output
785 if (from == 0) { // Constructor - loading and initialization
786 cout << " " << sContactType << " " << name << endl;
787 cout << " Location: " << vXYZ << endl;
788 cout << " Spring Constant: " << kSpring << endl;
790 if (eDampType == dtLinear)
791 cout << " Damping Constant: " << bDamp << " (linear)" << endl;
793 cout << " Damping Constant: " << bDamp << " (square law)" << endl;
795 if (eDampTypeRebound == dtLinear)
796 cout << " Rebound Damping Constant: " << bDampRebound << " (linear)" << endl;
798 cout << " Rebound Damping Constant: " << bDampRebound << " (square law)" << endl;
800 cout << " Dynamic Friction: " << dynamicFCoeff << endl;
801 cout << " Static Friction: " << staticFCoeff << endl;
802 if (eContactType == ctBOGEY) {
803 cout << " Rolling Friction: " << rollingFCoeff << endl;
804 cout << " Steering Type: " << sSteerType << endl;
805 cout << " Grouping: " << sBrakeGroup << endl;
806 cout << " Max Steer Angle: " << maxSteerAngle << endl;
807 cout << " Retractable: " << isRetractable << endl;
808 cout << " Relaxation Velocities:" << endl;
809 cout << " Rolling: " << RFRV << endl;
810 cout << " Side: " << SFRV << endl;
814 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
815 if (from == 0) cout << "Instantiated: FGLGear" << endl;
816 if (from == 1) cout << "Destroyed: FGLGear" << endl;
818 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
820 if (debug_lvl & 8 ) { // Runtime state variables
822 if (debug_lvl & 16) { // Sanity checking
824 if (debug_lvl & 64) {
825 if (from == 0) { // Constructor
826 cout << IdSrc << endl;
827 cout << IdHdr << endl;
832 } // namespace JSBSim