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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45 #include "FGGroundReactions.h"
47 #include "FGAuxiliary.h"
48 #include "FGAtmosphere.h"
49 #include "FGMassBalance.h"
50 #include "math/FGTable.h"
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65 static const char *IdSrc = "$Id$";
66 static const char *IdHdr = ID_LGEAR;
68 // Body To Structural (body frame is rotated 180 deg about Y and lengths are given in
69 // ft instead of inches)
70 const FGMatrix33 FGLGear::Tb2s(-1./inchtoft, 0., 0., 0., 1./inchtoft, 0., 0., 0., -1./inchtoft);
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
76 FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) :
81 Element *force_table=0;
83 Element *dampCoeffRebound=0;
86 kSpring = bDamp = bDampRebound = dynamicFCoeff = staticFCoeff = rollingFCoeff = maxSteerAngle = 0;
87 sSteerType = sBrakeGroup = sSteerType = "";
90 eDampTypeRebound = dtLinear;
92 name = el->GetAttributeValue("name");
93 sContactType = el->GetAttributeValue("type");
94 if (sContactType == "BOGEY") {
95 eContactType = ctBOGEY;
96 } else if (sContactType == "STRUCTURE") {
97 eContactType = ctSTRUCTURE;
99 // Unknown contact point types will be treated as STRUCTURE.
100 eContactType = ctSTRUCTURE;
103 if (el->FindElement("spring_coeff"))
104 kSpring = el->FindElementValueAsNumberConvertTo("spring_coeff", "LBS/FT");
105 if (el->FindElement("damping_coeff")) {
106 dampCoeff = el->FindElement("damping_coeff");
107 if (dampCoeff->GetAttributeValue("type") == "SQUARE") {
108 eDampType = dtSquare;
109 bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT2/SEC2");
111 bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT/SEC");
115 if (el->FindElement("damping_coeff_rebound")) {
116 dampCoeffRebound = el->FindElement("damping_coeff_rebound");
117 if (dampCoeffRebound->GetAttributeValue("type") == "SQUARE") {
118 eDampTypeRebound = dtSquare;
119 bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT2/SEC2");
121 bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT/SEC");
124 bDampRebound = bDamp;
125 eDampTypeRebound = eDampType;
128 if (el->FindElement("dynamic_friction"))
129 dynamicFCoeff = el->FindElementValueAsNumber("dynamic_friction");
130 if (el->FindElement("static_friction"))
131 staticFCoeff = el->FindElementValueAsNumber("static_friction");
132 if (el->FindElement("rolling_friction"))
133 rollingFCoeff = el->FindElementValueAsNumber("rolling_friction");
134 if (el->FindElement("max_steer"))
135 maxSteerAngle = el->FindElementValueAsNumberConvertTo("max_steer", "DEG");
136 if (el->FindElement("retractable"))
137 isRetractable = ((unsigned int)el->FindElementValueAsNumber("retractable"))>0.0?true:false;
140 force_table = el->FindElement("table");
141 while (force_table) {
142 force_type = force_table->GetAttributeValue("type");
143 if (force_type == "CORNERING_COEFF") {
144 ForceY_Table = new FGTable(fdmex->GetPropertyManager(), force_table);
146 cerr << "Undefined force table for " << name << " contact point" << endl;
148 force_table = el->FindNextElement("table");
151 sBrakeGroup = el->FindElementValue("brake_group");
153 if (maxSteerAngle == 360) sSteerType = "CASTERED";
154 else if (maxSteerAngle == 0.0) sSteerType = "FIXED";
155 else sSteerType = "STEERABLE";
157 Element* element = el->FindElement("location");
158 if (element) vXYZn = element->FindElementTripletConvertTo("IN");
159 else {cerr << "No location given for contact " << name << endl; exit(-1);}
160 SetTransformType(FGForce::tCustom);
162 element = el->FindElement("orientation");
163 if (element && (eContactType == ctBOGEY)) {
164 vGearOrient = element->FindElementTripletConvertTo("RAD");
166 double cp,sp,cr,sr,cy,sy;
168 cp=cos(vGearOrient(ePitch)); sp=sin(vGearOrient(ePitch));
169 cr=cos(vGearOrient(eRoll)); sr=sin(vGearOrient(eRoll));
170 cy=cos(vGearOrient(eYaw)); sy=sin(vGearOrient(eYaw));
176 mTGear(1,2) = sr*sp*cy - cr*sy;
177 mTGear(2,2) = sr*sp*sy + cr*cy;
180 mTGear(1,3) = cr*sp*cy + sr*sy;
181 mTGear(2,3) = cr*sp*sy - sr*cy;
190 if (sBrakeGroup == "LEFT" ) eBrakeGrp = bgLeft;
191 else if (sBrakeGroup == "RIGHT" ) eBrakeGrp = bgRight;
192 else if (sBrakeGroup == "CENTER") eBrakeGrp = bgCenter;
193 else if (sBrakeGroup == "NOSE" ) eBrakeGrp = bgNose;
194 else if (sBrakeGroup == "TAIL" ) eBrakeGrp = bgTail;
195 else if (sBrakeGroup == "NONE" ) eBrakeGrp = bgNone;
196 else if (sBrakeGroup.empty() ) {eBrakeGrp = bgNone;
197 sBrakeGroup = "NONE (defaulted)";}
199 cerr << "Improper braking group specification in config file: "
200 << sBrakeGroup << " is undefined." << endl;
203 if (sSteerType == "STEERABLE") eSteerType = stSteer;
204 else if (sSteerType == "FIXED" ) eSteerType = stFixed;
205 else if (sSteerType == "CASTERED" ) eSteerType = stCaster;
206 else if (sSteerType.empty() ) {eSteerType = stFixed;
207 sSteerType = "FIXED (defaulted)";}
209 cerr << "Improper steering type specification in config file: "
210 << sSteerType << " is undefined." << endl;
213 RFRV = 0.7; // Rolling force relaxation velocity, default value
214 SFRV = 0.7; // Side force relaxation velocity, default value
216 Element* relax_vel = el->FindElement("relaxation_velocity");
218 if (relax_vel->FindElement("rolling")) {
219 RFRV = relax_vel->FindElementValueAsNumberConvertTo("rolling", "FT/SEC");
221 if (relax_vel->FindElement("side")) {
222 SFRV = relax_vel->FindElementValueAsNumberConvertTo("side", "FT/SEC");
226 State = fdmex->GetState();
227 Aircraft = fdmex->GetAircraft();
228 Propagate = fdmex->GetPropagate();
229 Auxiliary = fdmex->GetAuxiliary();
230 FCS = fdmex->GetFCS();
231 MassBalance = fdmex->GetMassBalance();
233 LongForceLagFilterCoeff = 1/State->Getdt(); // default longitudinal force filter coefficient
234 LatForceLagFilterCoeff = 1/State->Getdt(); // default lateral force filter coefficient
236 Element* force_lag_filter_elem = el->FindElement("force_lag_filter");
237 if (force_lag_filter_elem) {
238 if (force_lag_filter_elem->FindElement("rolling")) {
239 LongForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("rolling");
241 if (force_lag_filter_elem->FindElement("side")) {
242 LatForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("side");
246 LongForceFilter = Filter(LongForceLagFilterCoeff, State->Getdt());
247 LatForceFilter = Filter(LatForceLagFilterCoeff, State->Getdt());
249 WheelSlipLagFilterCoeff = 1/State->Getdt();
251 Element *wheel_slip_angle_lag_elem = el->FindElement("wheel_slip_filter");
252 if (wheel_slip_angle_lag_elem) {
253 WheelSlipLagFilterCoeff = wheel_slip_angle_lag_elem->GetDataAsNumber();
256 WheelSlipFilter = Filter(WheelSlipLagFilterCoeff, State->Getdt());
261 useFCSGearPos = false;
264 // Add some AI here to determine if gear is located properly according to its
265 // brake group type ??
267 WOW = lastWOW = false;
269 FirstContact = false;
270 StartedGroundRun = false;
271 TakeoffReported = LandingReported = false;
272 LandingDistanceTraveled = TakeoffDistanceTraveled = TakeoffDistanceTraveled50ft = 0.0;
273 MaximumStrutForce = MaximumStrutTravel = 0.0;
274 SinkRate = GroundSpeed = 0.0;
276 vWhlBodyVec = MassBalance->StructuralToBody(vXYZn);
277 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec;
278 vWhlVelVec.InitMatrix();
280 compressLength = 0.0;
286 TirePressureNorm = 1.0;
298 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308 FGColumnVector3& FGLGear::GetBodyForces(void)
310 double t = fdmex->GetState()->Getsim_time();
311 dT = State->Getdt()*fdmex->GetGroundReactions()->GetRate();
315 if (isRetractable) ComputeRetractionState();
318 double verticalZProj = 0.;
320 vWhlBodyVec = MassBalance->StructuralToBody(vXYZn); // Get wheel in body frame
321 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec; // Get local frame wheel location
323 gearLoc = Propagate->GetLocation().LocalToLocation(vLocalGear);
324 // Compute the height of the theoretical location of the wheel (if strut is not compressed) with
325 // respect to the ground level
326 double height = fdmex->GetGroundCallback()->GetAGLevel(t, gearLoc, contact, normal, cvel);
327 vGroundNormal = -1. * Propagate->GetTec2b() * normal;
329 // The height returned above is the AGL and is expressed in the Z direction of the local
330 // coordinate frame. We now need to transform this height in actual compression of the strut (BOGEY)
331 // of in the normal direction to the ground (STRUCTURE)
332 switch (eContactType) {
334 verticalZProj = (Propagate->GetTb2l()*mTGear*FGColumnVector3(0.,0.,1.))(eZ);
335 compressLength = verticalZProj > 0.0 ? -height / verticalZProj : 0.0;
338 verticalZProj = (Propagate->GetTec2l()*normal)(eZ);
339 compressLength = fabs(verticalZProj) > 0.0 ? -height / verticalZProj : 0.0;
343 if (compressLength > 0.00) {
347 // [The next equation should really use the vector to the contact patch of
348 // the tire including the strut compression and not the original vWhlBodyVec.]
350 FGColumnVector3 vWhlDisplVec = mTGear * FGColumnVector3(0., 0., compressLength);
351 FGColumnVector3 vWhlContactVec = vWhlBodyVec - vWhlDisplVec;
352 vActingXYZn = vXYZn - Tb2s * vWhlDisplVec;
353 FGColumnVector3 vBodyWhlVel = Propagate->GetPQR() * vWhlContactVec;
354 vBodyWhlVel += Propagate->GetUVW() - Propagate->GetTec2b() * cvel;
356 vWhlVelVec = mTGear.Transposed() * vBodyWhlVel;
358 InitializeReporting();
359 ComputeSteeringAngle();
360 ComputeGroundCoordSys();
362 vLocalWhlVel = Transform().Transposed() * vBodyWhlVel;
364 switch (eContactType) {
366 // Compression speed along the strut
367 compressSpeed = -vWhlVelVec(eZ);
369 // Compression speed along the ground normal
370 compressSpeed = -vLocalWhlVel(eX);
373 ComputeVerticalStrutForce();
375 // Compute the forces in the wheel ground plane.
376 if (eContactType == ctBOGEY) {
378 ComputeBrakeForceCoefficient();
379 ComputeSideForceCoefficient();
380 double sign = vLocalWhlVel(eY)>0?1.0:(vLocalWhlVel(eY)<0?-1.0:0.0);
381 vFn(eY) = - ((1.0 - TirePressureNorm) * 30 + vFn(eX) * BrakeFCoeff) * sign;
382 vFn(eZ) = vFn(eX) * FCoeff;
384 else if (eContactType == ctSTRUCTURE) {
385 FGColumnVector3 vSlipVec = vLocalWhlVel;
387 vSlipVec.Normalize();
388 vFn -= staticFCoeff * vFn(eX) * vSlipVec;
391 // Lag and attenuate the XY-plane forces dependent on velocity. This code
392 // uses a lag filter, C/(s + C) where "C" is the filter coefficient. When
393 // "C" is chosen at the frame rate (in Hz), the jittering is significantly
394 // reduced. This is because the jitter is present *at* the execution rate.
395 // If a coefficient is set to something equal to or less than zero, the
396 // filter is bypassed.
398 if (LongForceLagFilterCoeff > 0) vFn(eY) = LongForceFilter.execute(vFn(eY));
399 if (LatForceLagFilterCoeff > 0) vFn(eZ) = LatForceFilter.execute(vFn(eZ));
401 if ((fabs(vLocalWhlVel(eY)) <= RFRV) && RFRV > 0) vFn(eY) *= fabs(vLocalWhlVel(eY))/RFRV;
402 if ((fabs(vLocalWhlVel(eZ)) <= SFRV) && SFRV > 0) vFn(eZ) *= fabs(vLocalWhlVel(eZ))/SFRV;
404 // End section for attenuating gear jitter
406 } else { // Gear is NOT compressed
409 compressLength = 0.0;
414 // Let wheel spin down slowly
415 vWhlVelVec(eX) -= 13.0*dT;
416 if (vWhlVelVec(eX) < 0.0) vWhlVelVec(eX) = 0.0;
418 // Return to neutral position between 1.0 and 0.8 gear pos.
419 SteerAngle *= max(GetGearUnitPos()-0.8, 0.0)/0.2;
425 ReportTakeoffOrLanding();
427 // Require both WOW and LastWOW to be true before checking crash conditions
428 // to allow the WOW flag to be used in terminating a scripted run.
429 if (WOW && lastWOW) CrashDetect();
433 return FGForce::GetBodyForces();
436 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
437 // Build a local "ground" coordinate system defined by
438 // eX : normal to the ground
439 // eY : projection of the rolling direction on the ground
440 // eZ : projection of the sliping direction on the ground
442 void FGLGear::ComputeGroundCoordSys(void)
444 // Euler angles are built up to create a local frame to describe the forces
445 // applied to the gear by the ground. Here pitch, yaw and roll do not have
446 // any physical meaning. It is just a convenient notation.
447 // First, "pitch" and "yaw" are determined in order to align eX with the
449 if (vGroundNormal(eZ) < -1.0)
450 vOrient(ePitch) = 0.5*M_PI;
451 else if (1.0 < vGroundNormal(eZ))
452 vOrient(ePitch) = -0.5*M_PI;
454 vOrient(ePitch) = asin(-vGroundNormal(eZ));
456 if (fabs(vOrient(ePitch)) == 0.5*M_PI)
459 vOrient(eYaw) = atan2(vGroundNormal(eY), vGroundNormal(eX));
462 UpdateCustomTransformMatrix();
464 if (eContactType == ctBOGEY) {
465 // In the case of a bogey, the third angle "roll" is used to align the axis eY and eZ
466 // to the rolling and sliping direction respectively.
467 FGColumnVector3 updatedRollingAxis = Transform().Transposed() * mTGear
468 * FGColumnVector3(-sin(SteerAngle), cos(SteerAngle), 0.);
470 vOrient(eRoll) = atan2(updatedRollingAxis(eY), -updatedRollingAxis(eZ));
471 UpdateCustomTransformMatrix();
475 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
477 void FGLGear::ComputeRetractionState(void)
479 double gearPos = GetGearUnitPos();
480 if (gearPos < 0.01) {
484 vWhlVelVec.InitMatrix();
485 } else if (gearPos > 0.99) {
494 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
496 void FGLGear::ComputeSlipAngle(void)
498 // Calculate tire slip angle.
499 WheelSlip = -atan2(vLocalWhlVel(eZ), fabs(vLocalWhlVel(eY)))*radtodeg;
501 // Filter the wheel slip angle
502 if (WheelSlipLagFilterCoeff > 0) WheelSlip = WheelSlipFilter.execute(WheelSlip);
505 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
506 // Compute the steering angle in any case.
507 // This will also make sure that animations will look right.
509 void FGLGear::ComputeSteeringAngle(void)
511 switch (eSteerType) {
513 SteerAngle = degtorad * FCS->GetSteerPosDeg(GearNumber);
519 SteerAngle = atan2(vWhlVelVec(eY), fabs(vWhlVelVec(eX)));
522 cerr << "Improper steering type membership detected for this gear." << endl;
527 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
528 // Reset reporting functionality after takeoff
530 void FGLGear::ResetReporting(void)
532 if (Propagate->GetDistanceAGL() > 200.0) {
533 FirstContact = false;
534 StartedGroundRun = false;
535 LandingReported = false;
536 TakeoffReported = true;
537 LandingDistanceTraveled = 0.0;
538 MaximumStrutForce = MaximumStrutTravel = 0.0;
542 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
544 void FGLGear::InitializeReporting(void)
546 // If this is the first time the wheel has made contact, remember some values
547 // for later printout.
551 SinkRate = compressSpeed;
552 GroundSpeed = Propagate->GetVel().Magnitude();
553 TakeoffReported = false;
556 // If the takeoff run is starting, initialize.
558 if ((Propagate->GetVel().Magnitude() > 0.1) &&
559 (FCS->GetBrake(bgLeft) == 0) &&
560 (FCS->GetBrake(bgRight) == 0) &&
561 (FCS->GetThrottlePos(0) > 0.90) && !StartedGroundRun)
563 TakeoffDistanceTraveled = 0;
564 TakeoffDistanceTraveled50ft = 0;
565 StartedGroundRun = true;
569 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
570 // Takeoff and landing reporting functionality
572 void FGLGear::ReportTakeoffOrLanding(void)
574 double deltaT = State->Getdt()*fdmex->GetGroundReactions()->GetRate();
577 LandingDistanceTraveled += Auxiliary->GetVground()*deltaT;
579 if (StartedGroundRun) {
580 TakeoffDistanceTraveled50ft += Auxiliary->GetVground()*deltaT;
581 if (WOW) TakeoffDistanceTraveled += Auxiliary->GetVground()*deltaT;
585 && Auxiliary->GetVground() <= 0.05
587 && fdmex->GetGroundReactions()->GetWOW())
589 if (debug_lvl > 0) Report(erLand);
594 && (Propagate->GetDistanceAGL() - vLocalGear(eZ)) > 50.0
595 && !fdmex->GetGroundReactions()->GetWOW())
597 if (debug_lvl > 0) Report(erTakeoff);
600 if (lastWOW != WOW) PutMessage("GEAR_CONTACT: " + name, WOW);
603 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
604 // Crash detection logic (really out-of-bounds detection)
606 void FGLGear::CrashDetect(void)
608 if ( (compressLength > 500.0 ||
609 vFn.Magnitude() > 100000000.0 ||
610 GetMoments().Magnitude() > 5000000000.0 ||
611 SinkRate > 1.4666*30 ) && !State->IntegrationSuspended())
613 PutMessage("Crash Detected: Simulation FREEZE.");
614 State->SuspendIntegration();
618 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619 // The following needs work regarding friction coefficients and braking and
620 // steering The BrakeFCoeff formula assumes that an anti-skid system is used.
621 // It also assumes that we won't be turning and braking at the same time.
622 // Will fix this later.
623 // [JSB] The braking force coefficients include normal rolling coefficient +
624 // a percentage of the static friction coefficient based on braking applied.
626 void FGLGear::ComputeBrakeForceCoefficient(void)
630 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
631 staticFCoeff*FCS->GetBrake(bgLeft) );
634 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
635 staticFCoeff*FCS->GetBrake(bgRight) );
638 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
639 staticFCoeff*FCS->GetBrake(bgCenter) );
642 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
643 staticFCoeff*FCS->GetBrake(bgCenter) );
646 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
647 staticFCoeff*FCS->GetBrake(bgCenter) );
650 BrakeFCoeff = rollingFCoeff;
653 cerr << "Improper brake group membership detected for this gear." << endl;
658 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
659 // Compute the sideforce coefficients using Pacejka's Magic Formula.
661 // y(x) = D sin {C arctan [Bx - E(Bx - arctan Bx)]}
663 // Where: B = Stiffness Factor (0.06, here)
664 // C = Shape Factor (2.8, here)
665 // D = Peak Factor (0.8, here)
666 // E = Curvature Factor (1.03, here)
668 void FGLGear::ComputeSideForceCoefficient(void)
671 FCoeff = ForceY_Table->GetValue(WheelSlip);
673 double StiffSlip = Stiffness*WheelSlip;
674 FCoeff = Peak * sin(Shape*atan(StiffSlip - Curvature*(StiffSlip - atan(StiffSlip))));
678 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
679 // Compute the vertical force on the wheel using square-law damping (per comment
680 // in paper AIAA-2000-4303 - see header prologue comments). We might consider
681 // allowing for both square and linear damping force calculation. Also need to
682 // possibly give a "rebound damping factor" that differs from the compression
685 void FGLGear::ComputeVerticalStrutForce(void)
687 double springForce = 0;
688 double dampForce = 0;
690 springForce = -compressLength * kSpring;
692 if (compressSpeed >= 0.0) {
694 if (eDampType == dtLinear) dampForce = -compressSpeed * bDamp;
695 else dampForce = -compressSpeed * compressSpeed * bDamp;
699 if (eDampTypeRebound == dtLinear)
700 dampForce = -compressSpeed * bDampRebound;
702 dampForce = compressSpeed * compressSpeed * bDampRebound;
706 StrutForce = min(springForce + dampForce, (double)0.0);
708 // The reaction force of the wheel is always normal to the ground
709 switch (eContactType) {
711 // Project back the strut force in the local coordinate frame of the ground
712 vFn(eX) = StrutForce / (mTGear.Transposed()*vGroundNormal)(eZ);
715 vFn(eX) = -StrutForce;
719 // Remember these values for reporting
720 MaximumStrutForce = max(MaximumStrutForce, fabs(StrutForce));
721 MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
724 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
726 double FGLGear::GetGearUnitPos(void)
728 // hack to provide backward compatibility to gear/gear-pos-norm property
729 if( useFCSGearPos || FCS->GetGearPos() != 1.0 ) {
730 useFCSGearPos = true;
731 return FCS->GetGearPos();
736 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
738 void FGLGear::bind(void)
740 string property_name;
741 string base_property_name;
742 base_property_name = CreateIndexedPropertyName("gear/unit", GearNumber);
743 if (eContactType == ctBOGEY) {
744 property_name = base_property_name + "/slip-angle-deg";
745 fdmex->GetPropertyManager()->Tie( property_name.c_str(), &WheelSlip );
746 property_name = base_property_name + "/WOW";
747 fdmex->GetPropertyManager()->Tie( property_name.c_str(), &WOW );
748 property_name = base_property_name + "/wheel-speed-fps";
749 fdmex->GetPropertyManager()->Tie( property_name.c_str(), (FGLGear*)this,
750 &FGLGear::GetWheelRollVel);
751 property_name = base_property_name + "/z-position";
752 fdmex->GetPropertyManager()->Tie( property_name.c_str(), (FGForce*)this,
753 &FGForce::GetLocationZ, &FGForce::SetLocationZ);
754 property_name = base_property_name + "/compression-ft";
755 fdmex->GetPropertyManager()->Tie( property_name.c_str(), &compressLength );
756 property_name = base_property_name + "/side_friction_coeff";
757 fdmex->GetPropertyManager()->Tie( property_name.c_str(), &FCoeff );
759 property_name = base_property_name + "/static_friction_coeff";
760 fdmex->GetPropertyManager()->Tie( property_name.c_str(), &staticFCoeff );
762 if (eSteerType == stCaster) {
763 property_name = base_property_name + "/steering-angle-rad";
764 fdmex->GetPropertyManager()->Tie( property_name.c_str(), &SteerAngle );
768 if( isRetractable ) {
769 property_name = base_property_name + "/pos-norm";
770 fdmex->GetPropertyManager()->Tie( property_name.c_str(), &GearPos );
774 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
776 void FGLGear::Report(ReportType repType)
778 if (fabs(TakeoffDistanceTraveled) < 0.001) return; // Don't print superfluous reports
782 cout << endl << "Touchdown report for " << name << " (WOW at time: "
783 << fdmex->GetState()->Getsim_time() << " seconds)" << endl;
784 cout << " Sink rate at contact: " << SinkRate << " fps, "
785 << SinkRate*0.3048 << " mps" << endl;
786 cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, "
787 << GroundSpeed*0.3048 << " mps" << endl;
788 cout << " Maximum contact force: " << MaximumStrutForce << " lbs, "
789 << MaximumStrutForce*4.448 << " Newtons" << endl;
790 cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, "
791 << MaximumStrutTravel*30.48 << " cm" << endl;
792 cout << " Distance traveled: " << LandingDistanceTraveled << " ft, "
793 << LandingDistanceTraveled*0.3048 << " meters" << endl;
794 LandingReported = true;
797 cout << endl << "Takeoff report for " << name << " (Liftoff at time: "
798 << fdmex->GetState()->Getsim_time() << " seconds)" << endl;
799 cout << " Distance traveled: " << TakeoffDistanceTraveled
800 << " ft, " << TakeoffDistanceTraveled*0.3048 << " meters" << endl;
801 cout << " Distance traveled (over 50'): " << TakeoffDistanceTraveled50ft
802 << " ft, " << TakeoffDistanceTraveled50ft*0.3048 << " meters" << endl;
803 cout << " [Altitude (ASL): " << fdmex->GetPropagate()->GetAltitudeASL() << " ft. / "
804 << fdmex->GetPropagate()->GetAltitudeASLmeters() << " m | Temperature: "
805 << fdmex->GetAtmosphere()->GetTemperature() - 459.67 << " F / "
806 << RankineToCelsius(fdmex->GetAtmosphere()->GetTemperature()) << " C]" << endl;
807 cout << " [Velocity (KCAS): " << fdmex->GetAuxiliary()->GetVcalibratedKTS() << "]" << endl;
808 TakeoffReported = true;
815 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
816 // The bitmasked value choices are as follows:
817 // unset: In this case (the default) JSBSim would only print
818 // out the normally expected messages, essentially echoing
819 // the config files as they are read. If the environment
820 // variable is not set, debug_lvl is set to 1 internally
821 // 0: This requests JSBSim not to output any messages
823 // 1: This value explicity requests the normal JSBSim
825 // 2: This value asks for a message to be printed out when
826 // a class is instantiated
827 // 4: When this value is set, a message is displayed when a
828 // FGModel object executes its Run() method
829 // 8: When this value is set, various runtime state variables
830 // are printed out periodically
831 // 16: When set various parameters are sanity checked and
832 // a message is printed out when they go out of bounds
834 void FGLGear::Debug(int from)
836 if (debug_lvl <= 0) return;
838 if (debug_lvl & 1) { // Standard console startup message output
839 if (from == 0) { // Constructor - loading and initialization
840 cout << " " << sContactType << " " << name << endl;
841 cout << " Location: " << vXYZn << endl;
842 cout << " Spring Constant: " << kSpring << endl;
844 if (eDampType == dtLinear)
845 cout << " Damping Constant: " << bDamp << " (linear)" << endl;
847 cout << " Damping Constant: " << bDamp << " (square law)" << endl;
849 if (eDampTypeRebound == dtLinear)
850 cout << " Rebound Damping Constant: " << bDampRebound << " (linear)" << endl;
852 cout << " Rebound Damping Constant: " << bDampRebound << " (square law)" << endl;
854 cout << " Dynamic Friction: " << dynamicFCoeff << endl;
855 cout << " Static Friction: " << staticFCoeff << endl;
856 if (eContactType == ctBOGEY) {
857 cout << " Rolling Friction: " << rollingFCoeff << endl;
858 cout << " Steering Type: " << sSteerType << endl;
859 cout << " Grouping: " << sBrakeGroup << endl;
860 cout << " Max Steer Angle: " << maxSteerAngle << endl;
861 cout << " Retractable: " << isRetractable << endl;
862 cout << " Relaxation Velocities:" << endl;
863 cout << " Rolling: " << RFRV << endl;
864 cout << " Side: " << SFRV << endl;
868 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
869 if (from == 0) cout << "Instantiated: FGLGear" << endl;
870 if (from == 1) cout << "Destroyed: FGLGear" << endl;
872 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
874 if (debug_lvl & 8 ) { // Runtime state variables
876 if (debug_lvl & 16) { // Sanity checking
878 if (debug_lvl & 64) {
879 if (from == 0) { // Constructor
880 cout << IdSrc << endl;
881 cout << IdHdr << endl;
886 } // namespace JSBSim