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 FGColumnVector3 vRollingGroundVec;
397 if (eContactType == ctBOGEY) {
398 // Compute the rolling direction projected on the ground
399 // It consists in finding a vector 'r' such that 'r' lies in the plane (w,z) and r.n = 0 (scalar
401 // 'n' is the normal to the ground,
402 // (x,y,z) are the directions defined in the body coord system
403 // and 'w' is 'x' rotated by the steering angle (SteerAngle) in the plane (x,y).
404 // r = u * w + v * z and r.n = 0 => v/u = -w.n/z.n = a
405 // We also want u**2+v**2=1 and u > 0 (i.e. r orientated in the same 'direction' than w)
406 // after some arithmetic, one finds that :
407 double a = -(vGroundNormal(eX)*cos(SteerAngle)+vGroundNormal(eY)*sin(SteerAngle)) / vGroundNormal(eZ);
408 double u = 1. / sqrt(1. + a*a);
410 vRollingGroundVec = FGColumnVector3(u * cos(SteerAngle), u * sin(SteerAngle), v);
413 // Here the only significant direction is the normal to the ground "vGroundNormal". Since there is
414 // no wheel the 2 other vectors of the orthonormal basis are not meaningful and are only used to
415 // create the transformation matrix Tg2b. So we are building vRollingGroundVec as an arbitrary
416 // vector normal to vGroundNormal
417 if (fabs(vGroundNormal(eX)) > 0.)
418 vRollingGroundVec = FGColumnVector3(-vGroundNormal(eZ)/vGroundNormal(eX), 0., 1.);
419 else if (fabs(vGroundNormal(eY)) > 0.)
420 vRollingGroundVec = FGColumnVector3(0., -vGroundNormal(eZ)/vGroundNormal(eY), 1.);
422 vRollingGroundVec = FGColumnVector3(1., 0., -vGroundNormal(eX)/vGroundNormal(eZ));
424 vRollingGroundVec.Normalize();
427 // The sliping direction is the cross product multiplication of the ground normal and rolling
429 FGColumnVector3 vSlipGroundVec = vGroundNormal * vRollingGroundVec;
431 Tg2b(1,1) = vRollingGroundVec(eX);
432 Tg2b(2,1) = vRollingGroundVec(eY);
433 Tg2b(3,1) = vRollingGroundVec(eZ);
434 Tg2b(1,2) = vSlipGroundVec(eX);
435 Tg2b(2,2) = vSlipGroundVec(eY);
436 Tg2b(3,2) = vSlipGroundVec(eZ);
437 Tg2b(1,3) = vGroundNormal(eX);
438 Tg2b(2,3) = vGroundNormal(eY);
439 Tg2b(3,3) = vGroundNormal(eZ);
441 Tb2g = Tg2b.Transposed();
444 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
446 void FGLGear::ComputeRetractionState(void)
448 double gearPos = GetGearUnitPos();
449 if (gearPos < 0.01) {
453 vLocalWhlVel.InitMatrix();
454 } else if (gearPos > 0.99) {
463 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
465 void FGLGear::ComputeSlipAngle(void)
467 // Calculate tire slip angle.
468 WheelSlip = -atan2(vLocalWhlVel(eY), fabs(vLocalWhlVel(eX)))*radtodeg;
470 // Filter the wheel slip angle
471 if (WheelSlipLagFilterCoeff > 0) WheelSlip = WheelSlipFilter.execute(WheelSlip);
474 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
475 // Compute the steering angle in any case.
476 // This will also make sure that animations will look right.
478 void FGLGear::ComputeSteeringAngle(void)
480 switch (eSteerType) {
482 SteerAngle = degtorad * FCS->GetSteerPosDeg(GearNumber);
488 SteerAngle = atan2(fabs(vWhlVelVec(eX)), vWhlVelVec(eY));
491 cerr << "Improper steering type membership detected for this gear." << endl;
496 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
497 // Reset reporting functionality after takeoff
499 void FGLGear::ResetReporting(void)
501 if (Propagate->GetDistanceAGL() > 200.0) {
502 FirstContact = false;
503 StartedGroundRun = false;
504 LandingReported = false;
505 TakeoffReported = true;
506 LandingDistanceTraveled = 0.0;
507 MaximumStrutForce = MaximumStrutTravel = 0.0;
511 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
513 void FGLGear::InitializeReporting(void)
515 // If this is the first time the wheel has made contact, remember some values
516 // for later printout.
520 SinkRate = compressSpeed;
521 GroundSpeed = Propagate->GetVel().Magnitude();
522 TakeoffReported = false;
525 // If the takeoff run is starting, initialize.
527 if ((Propagate->GetVel().Magnitude() > 0.1) &&
528 (FCS->GetBrake(bgLeft) == 0) &&
529 (FCS->GetBrake(bgRight) == 0) &&
530 (FCS->GetThrottlePos(0) > 0.90) && !StartedGroundRun)
532 TakeoffDistanceTraveled = 0;
533 TakeoffDistanceTraveled50ft = 0;
534 StartedGroundRun = true;
538 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
539 // Takeoff and landing reporting functionality
541 void FGLGear::ReportTakeoffOrLanding(void)
543 double deltaT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
546 LandingDistanceTraveled += Auxiliary->GetVground()*deltaT;
548 if (StartedGroundRun) {
549 TakeoffDistanceTraveled50ft += Auxiliary->GetVground()*deltaT;
550 if (WOW) TakeoffDistanceTraveled += Auxiliary->GetVground()*deltaT;
554 && Auxiliary->GetVground() <= 0.05
556 && Exec->GetGroundReactions()->GetWOW())
558 if (debug_lvl > 0) Report(erLand);
563 && (Propagate->GetDistanceAGL() - vLocalGear(eZ)) > 50.0
564 && !Exec->GetGroundReactions()->GetWOW())
566 if (debug_lvl > 0) Report(erTakeoff);
569 if (lastWOW != WOW) PutMessage("GEAR_CONTACT: " + name, WOW);
572 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
573 // Crash detection logic (really out-of-bounds detection)
575 void FGLGear::CrashDetect(void)
577 if ( (compressLength > 500.0 ||
578 vForce.Magnitude() > 100000000.0 ||
579 vMoment.Magnitude() > 5000000000.0 ||
580 SinkRate > 1.4666*30 ) && !State->IntegrationSuspended())
582 PutMessage("Crash Detected: Simulation FREEZE.");
583 State->SuspendIntegration();
587 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
588 // The following needs work regarding friction coefficients and braking and
589 // steering The BrakeFCoeff formula assumes that an anti-skid system is used.
590 // It also assumes that we won't be turning and braking at the same time.
591 // Will fix this later.
592 // [JSB] The braking force coefficients include normal rolling coefficient +
593 // a percentage of the static friction coefficient based on braking applied.
595 void FGLGear::ComputeBrakeForceCoefficient(void)
599 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
600 staticFCoeff*FCS->GetBrake(bgLeft) );
603 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
604 staticFCoeff*FCS->GetBrake(bgRight) );
607 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
608 staticFCoeff*FCS->GetBrake(bgCenter) );
611 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
612 staticFCoeff*FCS->GetBrake(bgCenter) );
615 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
616 staticFCoeff*FCS->GetBrake(bgCenter) );
619 BrakeFCoeff = rollingFCoeff;
622 cerr << "Improper brake group membership detected for this gear." << endl;
627 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
628 // Compute the sideforce coefficients using Pacejka's Magic Formula.
630 // y(x) = D sin {C arctan [Bx - E(Bx - arctan Bx)]}
632 // Where: B = Stiffness Factor (0.06, here)
633 // C = Shape Factor (2.8, here)
634 // D = Peak Factor (0.8, here)
635 // E = Curvature Factor (1.03, here)
637 void FGLGear::ComputeSideForceCoefficient(void)
640 FCoeff = ForceY_Table->GetValue(WheelSlip);
642 double StiffSlip = Stiffness*WheelSlip;
643 FCoeff = Peak * sin(Shape*atan(StiffSlip - Curvature*(StiffSlip - atan(StiffSlip))));
647 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
648 // Compute the vertical force on the wheel using square-law damping (per comment
649 // in paper AIAA-2000-4303 - see header prologue comments). We might consider
650 // allowing for both square and linear damping force calculation. Also need to
651 // possibly give a "rebound damping factor" that differs from the compression
654 void FGLGear::ComputeVerticalStrutForce(void)
656 double springForce = 0;
657 double dampForce = 0;
659 springForce = -compressLength * kSpring;
661 if (compressSpeed >= 0.0) {
663 if (eDampType == dtLinear) dampForce = -compressSpeed * bDamp;
664 else dampForce = -compressSpeed * compressSpeed * bDamp;
668 if (eDampTypeRebound == dtLinear)
669 dampForce = -compressSpeed * bDampRebound;
671 dampForce = compressSpeed * compressSpeed * bDampRebound;
675 StrutForce = min(springForce + dampForce, (double)0.0);
677 // The reaction force of the wheel is always normal to the ground
678 switch (eContactType) {
680 // Project back the strut force in the local coordinate frame of the ground
681 vLocalForce(eZ) = StrutForce / vGroundNormal(eZ);
684 vLocalForce(eZ) = -StrutForce;
688 // Remember these values for reporting
689 MaximumStrutForce = max(MaximumStrutForce, fabs(StrutForce));
690 MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
693 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
695 double FGLGear::GetGearUnitPos(void)
697 // hack to provide backward compatibility to gear/gear-pos-norm property
698 if( useFCSGearPos || FCS->GetGearPos() != 1.0 ) {
699 useFCSGearPos = true;
700 return FCS->GetGearPos();
705 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
707 void FGLGear::bind(void)
709 string property_name;
710 string base_property_name;
711 base_property_name = CreateIndexedPropertyName("gear/unit", GearNumber);
712 if (eContactType == ctBOGEY) {
713 property_name = base_property_name + "/slip-angle-deg";
714 Exec->GetPropertyManager()->Tie( property_name.c_str(), &WheelSlip );
715 property_name = base_property_name + "/WOW";
716 Exec->GetPropertyManager()->Tie( property_name.c_str(), &WOW );
717 property_name = base_property_name + "/wheel-speed-fps";
718 Exec->GetPropertyManager()->Tie( property_name.c_str(), (FGLGear*)this,
719 &FGLGear::GetWheelRollVel);
720 property_name = base_property_name + "/z-position";
721 Exec->GetPropertyManager()->Tie( property_name.c_str(), (FGLGear*)this,
722 &FGLGear::GetZPosition, &FGLGear::SetZPosition);
723 property_name = base_property_name + "/compression-ft";
724 Exec->GetPropertyManager()->Tie( property_name.c_str(), &compressLength );
725 property_name = base_property_name + "/side_friction_coeff";
726 Exec->GetPropertyManager()->Tie( property_name.c_str(), &FCoeff );
728 property_name = base_property_name + "/static_friction_coeff";
729 Exec->GetPropertyManager()->Tie( property_name.c_str(), &staticFCoeff );
733 if( isRetractable ) {
734 property_name = base_property_name + "/pos-norm";
735 Exec->GetPropertyManager()->Tie( property_name.c_str(), &GearPos );
740 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
742 void FGLGear::Report(ReportType repType)
744 if (fabs(TakeoffDistanceTraveled) < 0.001) return; // Don't print superfluous reports
748 cout << endl << "Touchdown report for " << name << " (WOW at time: "
749 << Exec->GetState()->Getsim_time() << " seconds)" << endl;
750 cout << " Sink rate at contact: " << SinkRate << " fps, "
751 << SinkRate*0.3048 << " mps" << endl;
752 cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, "
753 << GroundSpeed*0.3048 << " mps" << endl;
754 cout << " Maximum contact force: " << MaximumStrutForce << " lbs, "
755 << MaximumStrutForce*4.448 << " Newtons" << endl;
756 cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, "
757 << MaximumStrutTravel*30.48 << " cm" << endl;
758 cout << " Distance traveled: " << LandingDistanceTraveled << " ft, "
759 << LandingDistanceTraveled*0.3048 << " meters" << endl;
760 LandingReported = true;
763 cout << endl << "Takeoff report for " << name << " (Liftoff at time: "
764 << Exec->GetState()->Getsim_time() << " seconds)" << endl;
765 cout << " Distance traveled: " << TakeoffDistanceTraveled
766 << " ft, " << TakeoffDistanceTraveled*0.3048 << " meters" << endl;
767 cout << " Distance traveled (over 50'): " << TakeoffDistanceTraveled50ft
768 << " ft, " << TakeoffDistanceTraveled50ft*0.3048 << " meters" << endl;
769 cout << " [Altitude (ASL): " << Exec->GetPropagate()->GetAltitudeASL() << " ft. / "
770 << Exec->GetPropagate()->GetAltitudeASLmeters() << " m | Temperature: "
771 << Exec->GetAtmosphere()->GetTemperature() - 459.67 << " F / "
772 << RankineToCelsius(Exec->GetAtmosphere()->GetTemperature()) << " C]" << endl;
773 cout << " [Velocity (KCAS): " << Exec->GetAuxiliary()->GetVcalibratedKTS() << "]" << endl;
774 TakeoffReported = true;
779 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
780 // The bitmasked value choices are as follows:
781 // unset: In this case (the default) JSBSim would only print
782 // out the normally expected messages, essentially echoing
783 // the config files as they are read. If the environment
784 // variable is not set, debug_lvl is set to 1 internally
785 // 0: This requests JSBSim not to output any messages
787 // 1: This value explicity requests the normal JSBSim
789 // 2: This value asks for a message to be printed out when
790 // a class is instantiated
791 // 4: When this value is set, a message is displayed when a
792 // FGModel object executes its Run() method
793 // 8: When this value is set, various runtime state variables
794 // are printed out periodically
795 // 16: When set various parameters are sanity checked and
796 // a message is printed out when they go out of bounds
798 void FGLGear::Debug(int from)
800 if (debug_lvl <= 0) return;
802 if (debug_lvl & 1) { // Standard console startup message output
803 if (from == 0) { // Constructor - loading and initialization
804 cout << " " << sContactType << " " << name << endl;
805 cout << " Location: " << vXYZ << endl;
806 cout << " Spring Constant: " << kSpring << endl;
808 if (eDampType == dtLinear)
809 cout << " Damping Constant: " << bDamp << " (linear)" << endl;
811 cout << " Damping Constant: " << bDamp << " (square law)" << endl;
813 if (eDampTypeRebound == dtLinear)
814 cout << " Rebound Damping Constant: " << bDampRebound << " (linear)" << endl;
816 cout << " Rebound Damping Constant: " << bDampRebound << " (square law)" << endl;
818 cout << " Dynamic Friction: " << dynamicFCoeff << endl;
819 cout << " Static Friction: " << staticFCoeff << endl;
820 if (eContactType == ctBOGEY) {
821 cout << " Rolling Friction: " << rollingFCoeff << endl;
822 cout << " Steering Type: " << sSteerType << endl;
823 cout << " Grouping: " << sBrakeGroup << endl;
824 cout << " Max Steer Angle: " << maxSteerAngle << endl;
825 cout << " Retractable: " << isRetractable << endl;
826 cout << " Relaxation Velocities:" << endl;
827 cout << " Rolling: " << RFRV << endl;
828 cout << " Side: " << SFRV << endl;
832 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
833 if (from == 0) cout << "Instantiated: FGLGear" << endl;
834 if (from == 1) cout << "Destroyed: FGLGear" << endl;
836 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
838 if (debug_lvl & 8 ) { // Runtime state variables
840 if (debug_lvl & 16) { // Sanity checking
842 if (debug_lvl & 64) {
843 if (from == 0) { // Constructor
844 cout << IdSrc << endl;
845 cout << IdHdr << endl;
850 } // namespace JSBSim