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) : Exec(fdmex),
63 Element *force_table=0;
66 kSpring = bDamp = bDampRebound = dynamicFCoeff = staticFCoeff = rollingFCoeff = maxSteerAngle = 0;
67 sSteerType = sBrakeGroup = sSteerType = "";
70 name = el->GetAttributeValue("name");
71 sContactType = el->GetAttributeValue("type");
72 if (sContactType == "BOGEY") {
73 eContactType = ctBOGEY;
74 } else if (sContactType == "STRUCTURE") {
75 eContactType = ctSTRUCTURE;
77 eContactType = ctUNKNOWN;
80 if (el->FindElement("spring_coeff"))
81 kSpring = el->FindElementValueAsNumberConvertTo("spring_coeff", "LBS/FT");
82 if (el->FindElement("damping_coeff"))
83 bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT/SEC");
85 if (el->FindElement("damping_coeff_rebound"))
86 bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT/SEC");
90 if (el->FindElement("dynamic_friction"))
91 dynamicFCoeff = el->FindElementValueAsNumber("dynamic_friction");
92 if (el->FindElement("static_friction"))
93 staticFCoeff = el->FindElementValueAsNumber("static_friction");
94 if (el->FindElement("rolling_friction"))
95 rollingFCoeff = el->FindElementValueAsNumber("rolling_friction");
96 if (el->FindElement("max_steer"))
97 maxSteerAngle = el->FindElementValueAsNumberConvertTo("max_steer", "DEG");
98 if (el->FindElement("retractable"))
99 isRetractable = ((unsigned int)el->FindElementValueAsNumber("retractable"))>0.0?true:false;
102 force_table = el->FindElement("table");
103 while (force_table) {
104 force_type = force_table->GetAttributeValue("type");
105 if (force_type == "CORNERING_COEFF") {
106 ForceY_Table = new FGTable(Exec->GetPropertyManager(), force_table);
108 cerr << "Undefined force table for " << name << " contact point" << endl;
110 force_table = el->FindNextElement("table");
113 sBrakeGroup = el->FindElementValue("brake_group");
115 if (maxSteerAngle == 360) sSteerType = "CASTERED";
116 else if (maxSteerAngle == 0.0) sSteerType = "FIXED";
117 else sSteerType = "STEERABLE";
119 Element* element = el->FindElement("location");
120 if (element) vXYZ = element->FindElementTripletConvertTo("IN");
121 else {cerr << "No location given for contact " << name << endl; exit(-1);}
123 if (sBrakeGroup == "LEFT" ) eBrakeGrp = bgLeft;
124 else if (sBrakeGroup == "RIGHT" ) eBrakeGrp = bgRight;
125 else if (sBrakeGroup == "CENTER") eBrakeGrp = bgCenter;
126 else if (sBrakeGroup == "NOSE" ) eBrakeGrp = bgNose;
127 else if (sBrakeGroup == "TAIL" ) eBrakeGrp = bgTail;
128 else if (sBrakeGroup == "NONE" ) eBrakeGrp = bgNone;
129 else if (sBrakeGroup.empty() ) {eBrakeGrp = bgNone;
130 sBrakeGroup = "NONE (defaulted)";}
132 cerr << "Improper braking group specification in config file: "
133 << sBrakeGroup << " is undefined." << endl;
136 if (sSteerType == "STEERABLE") eSteerType = stSteer;
137 else if (sSteerType == "FIXED" ) eSteerType = stFixed;
138 else if (sSteerType == "CASTERED" ) eSteerType = stCaster;
139 else if (sSteerType.empty() ) {eSteerType = stFixed;
140 sSteerType = "FIXED (defaulted)";}
142 cerr << "Improper steering type specification in config file: "
143 << sSteerType << " is undefined." << endl;
146 RFRV = 0.7; // Rolling force relaxation velocity, default value
147 SFRV = 0.7; // Side force relaxation velocity, default value
149 Element* relax_vel = el->FindElement("relaxation_velocity");
151 if (relax_vel->FindElement("rolling")) {
152 RFRV = relax_vel->FindElementValueAsNumberConvertTo("rolling", "FT/SEC");
154 if (relax_vel->FindElement("side")) {
155 SFRV = relax_vel->FindElementValueAsNumberConvertTo("side", "FT/SEC");
159 State = Exec->GetState();
160 LongForceLagFilterCoeff = 1/State->Getdt(); // default longitudinal force filter coefficient
161 LatForceLagFilterCoeff = 1/State->Getdt(); // default lateral force filter coefficient
163 Element* force_lag_filter_elem = el->FindElement("force_lag_filter");
164 if (force_lag_filter_elem) {
165 if (force_lag_filter_elem->FindElement("rolling")) {
166 LongForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("rolling");
168 if (force_lag_filter_elem->FindElement("side")) {
169 LatForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("side");
173 WheelSlipLagFilterCoeff = 1/State->Getdt();
175 Element *wheel_slip_angle_lag_elem = el->FindElement("wheel_slip_filter");
176 if (wheel_slip_angle_lag_elem) {
177 WheelSlipLagFilterCoeff = wheel_slip_angle_lag_elem->GetDataAsNumber();
183 useFCSGearPos = false;
186 // Add some AI here to determine if gear is located properly according to its
187 // brake group type ??
189 State = Exec->GetState();
190 Aircraft = Exec->GetAircraft();
191 Propagate = Exec->GetPropagate();
192 Auxiliary = Exec->GetAuxiliary();
193 FCS = Exec->GetFCS();
194 MassBalance = Exec->GetMassBalance();
196 WOW = lastWOW = false;
198 FirstContact = false;
199 StartedGroundRun = false;
200 TakeoffReported = LandingReported = false;
201 LandingDistanceTraveled = TakeoffDistanceTraveled = TakeoffDistanceTraveled50ft = 0.0;
202 MaximumStrutForce = MaximumStrutTravel = 0.0;
203 SideForce = RollingForce = 0.0;
204 SinkRate = GroundSpeed = 0.0;
206 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ);
208 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec;
210 compressLength = 0.0;
216 TirePressureNorm = 1.0;
230 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
232 FGLGear::FGLGear(const FGLGear& lgear)
234 GearNumber = lgear.GearNumber;
236 Aircraft = lgear.Aircraft;
237 Propagate = lgear.Propagate;
238 Auxiliary = lgear.Auxiliary;
241 MassBalance = lgear.MassBalance;
244 vMoment = lgear.vMoment;
245 vWhlBodyVec = lgear.vWhlBodyVec;
246 vLocalGear = lgear.vLocalGear;
249 lastWOW = lgear.lastWOW;
250 ReportEnable = lgear.ReportEnable;
251 FirstContact = lgear.FirstContact;
252 StartedGroundRun = lgear.StartedGroundRun;
253 LandingDistanceTraveled = lgear.LandingDistanceTraveled;
254 TakeoffDistanceTraveled = lgear.TakeoffDistanceTraveled;
255 TakeoffDistanceTraveled50ft = lgear.TakeoffDistanceTraveled50ft;
256 MaximumStrutForce = lgear.MaximumStrutForce;
257 MaximumStrutTravel = lgear.MaximumStrutTravel;
258 SideForce = lgear.SideForce;
259 RollingForce = lgear.RollingForce;
261 kSpring = lgear.kSpring;
263 bDampRebound = lgear.bDampRebound;
264 compressLength = lgear.compressLength;
265 compressSpeed = lgear.compressSpeed;
266 staticFCoeff = lgear.staticFCoeff;
267 dynamicFCoeff = lgear.dynamicFCoeff;
268 rollingFCoeff = lgear.rollingFCoeff;
269 brakePct = lgear.brakePct;
270 maxCompLen = lgear.maxCompLen;
271 SinkRate = lgear.SinkRate;
272 GroundSpeed = lgear.GroundSpeed;
273 LandingReported = lgear.LandingReported;
274 TakeoffReported = lgear.TakeoffReported;
276 sSteerType = lgear.sSteerType;
277 sRetractable = lgear.sRetractable;
278 sContactType = lgear.sContactType;
279 eContactType = lgear.eContactType;
280 sBrakeGroup = lgear.sBrakeGroup;
281 eSteerType = lgear.eSteerType;
282 eBrakeGrp = lgear.eBrakeGrp;
283 maxSteerAngle = lgear.maxSteerAngle;
284 isRetractable = lgear.isRetractable;
285 GearUp = lgear.GearUp;
286 GearDown = lgear.GearDown;
287 GearPos = lgear.GearPos;
288 useFCSGearPos = lgear.useFCSGearPos;
289 WheelSlip = lgear.WheelSlip;
290 TirePressureNorm = lgear.TirePressureNorm;
291 Servicable = lgear.Servicable;
292 ForceY_Table = lgear.ForceY_Table;
293 CosWheel = lgear.CosWheel;
294 SinWheel = lgear.SinWheel;
295 prevOut = lgear.prevOut;
296 prevIn = lgear.prevIn;
297 prevSlipIn = lgear.prevSlipIn;
298 prevSlipOut = lgear.prevSlipOut;
301 LongForceLagFilterCoeff = lgear.LongForceLagFilterCoeff;
302 LatForceLagFilterCoeff = lgear.LatForceLagFilterCoeff;
303 WheelSlipLagFilterCoeff = lgear.WheelSlipLagFilterCoeff;
306 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
313 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315 FGColumnVector3& FGLGear::Force(void)
317 double t = Exec->GetState()->Getsim_time();
318 dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
321 vMoment.InitMatrix();
323 if (isRetractable) ComputeRetractionState();
325 if (!GearDown) return vForce; // return the null vForce column vector
327 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ); // Get wheel in body frame
328 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec; // Get local frame wheel location
330 gearLoc = Propagate->GetLocation().LocalToLocation(vLocalGear);
331 compressLength = -Exec->GetGroundCallback()->GetAGLevel(t, gearLoc, contact, normal, cvel);
333 // The compression length is measured in the Z-axis, only, at this time.
335 if (compressLength > 0.00) {
339 // [The next equation should really use the vector to the contact patch of
340 // the tire including the strut compression and not the original vWhlBodyVec.]
342 vWhlVelVec = Propagate->GetTb2l() * (Propagate->GetPQR() * vWhlBodyVec);
343 vWhlVelVec += Propagate->GetVel() - cvel;
344 compressSpeed = vWhlVelVec(eZ);
346 InitializeReporting();
347 ComputeBrakeForceCoefficient();
348 ComputeSteeringAngle();
350 ComputeSideForceCoefficient();
351 ComputeVerticalStrutForce();
353 // Compute the forces in the wheel ground plane.
355 double sign = RollingWhlVel>0?1.0:(RollingWhlVel<0?-1.0:0.0);
356 RollingForce = ((1.0 - TirePressureNorm) * 30 + vLocalForce(eZ) * BrakeFCoeff) * sign;
357 SideForce = vLocalForce(eZ) * FCoeff;
359 // Transform these forces back to the local reference frame.
361 vLocalForce(eX) = RollingForce*CosWheel - SideForce*SinWheel;
362 vLocalForce(eY) = SideForce*CosWheel + RollingForce*SinWheel;
364 // Transform the forces back to the body frame and compute the moment.
366 vForce = Propagate->GetTl2b() * vLocalForce;
368 // Start experimental section for gear jitter reduction
370 // Lag and attenuate the XY-plane forces dependent on velocity
372 double ca, cb, denom;
373 FGColumnVector3 Output;
375 // This code implements a lag filter, C/(s + C) where
376 // "C" is the filter coefficient. When "C" is chosen at the
377 // frame rate (in Hz), the jittering is significantly reduced. This is because
378 // the jitter is present *at* the execution rate.
379 // If a coefficient is set to something equal to or less than zero, the filter
382 if (LongForceLagFilterCoeff > 0) {
383 denom = 2.00 + dT*LongForceLagFilterCoeff;
384 ca = dT*LongForceLagFilterCoeff / denom;
385 cb = (2.00 - dT*LongForceLagFilterCoeff) / denom;
386 Output(eX) = vForce(eX) * ca + prevIn(eX) * ca + prevOut(eX) * cb;
387 vForce(eX) = Output(eX);
389 if (LatForceLagFilterCoeff > 0) {
390 denom = 2.00 + dT*LatForceLagFilterCoeff;
391 ca = dT*LatForceLagFilterCoeff / denom;
392 cb = (2.00 - dT*LatForceLagFilterCoeff) / denom;
393 Output(eY) = vForce(eY) * ca + prevIn(eY) * ca + prevOut(eY) * cb;
394 vForce(eY) = Output(eY);
400 if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
401 if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) vForce(eY) *= fabs(SideWhlVel)/SFRV;
403 // End section for attentuating gear jitter
405 vMoment = vWhlBodyVec * vForce;
407 } else { // Gear is NOT compressed
410 compressLength = 0.0;
412 // Return to neutral position between 1.0 and 0.8 gear pos.
413 SteerAngle *= max(GetGearUnitPos()-0.8, 0.0)/0.2;
418 ReportTakeoffOrLanding();
420 // Require both WOW and LastWOW to be true before checking crash conditions
421 // to allow the WOW flag to be used in terminating a scripted run.
422 if (WOW && lastWOW) CrashDetect();
429 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
431 void FGLGear::ComputeRetractionState(void)
433 double gearPos = GetGearUnitPos();
434 if (gearPos < 0.01) {
437 } else if (gearPos > 0.99) {
446 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
448 void FGLGear::ComputeSlipAngle(void)
450 // Transform the wheel velocities from the local axis system to the wheel axis system.
451 RollingWhlVel = vWhlVelVec(eX)*CosWheel + vWhlVelVec(eY)*SinWheel;
452 SideWhlVel = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel;
454 // Calculate tire slip angle.
455 WheelSlip = atan2(SideWhlVel, fabs(RollingWhlVel))*radtodeg;
457 // Filter the wheel slip angle
459 double SlipOutput, ca, cb, denom;
461 if (WheelSlipLagFilterCoeff > 0) {
462 denom = 2.00 + dT*WheelSlipLagFilterCoeff;
463 ca = dT*WheelSlipLagFilterCoeff / denom;
464 cb = (2.00 - dT*WheelSlipLagFilterCoeff) / denom;
466 SlipOutput = ca * (WheelSlip + prevSlipIn) + cb * prevSlipOut;
468 prevSlipIn = WheelSlip;
469 WheelSlip = prevSlipOut = SlipOutput;
473 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
474 // Compute the steering angle in any case.
475 // This will also make sure that animations will look right.
477 void FGLGear::ComputeSteeringAngle(void)
479 double casterLocalFrameAngleRad = 0.0;
480 double casterAngle = 0.0;
482 switch (eSteerType) {
484 SteerAngle = degtorad * FCS->GetSteerPosDeg(GearNumber);
490 // This is not correct for castering gear. Should make steer angle parallel
491 // to the actual velocity vector of the wheel, given aircraft velocity vector
494 casterLocalFrameAngleRad = acos(vWhlVelVec(eX)/vWhlVelVec.Magnitude());
495 casterAngle = casterLocalFrameAngleRad - Propagate->GetEuler(ePsi);
498 cerr << "Improper steering type membership detected for this gear." << endl;
502 SinWheel = sin(Propagate->GetEuler(ePsi) + SteerAngle);
503 CosWheel = cos(Propagate->GetEuler(ePsi) + SteerAngle);
506 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
507 // Reset reporting functionality after takeoff
509 void FGLGear::ResetReporting(void)
511 if (Propagate->GetDistanceAGL() > 200.0) {
512 FirstContact = false;
513 StartedGroundRun = false;
514 LandingReported = false;
515 TakeoffReported = true;
516 LandingDistanceTraveled = 0.0;
517 MaximumStrutForce = MaximumStrutTravel = 0.0;
521 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
523 void FGLGear::InitializeReporting(void)
525 // If this is the first time the wheel has made contact, remember some values
526 // for later printout.
530 SinkRate = compressSpeed;
531 GroundSpeed = Propagate->GetVel().Magnitude();
532 TakeoffReported = false;
535 // If the takeoff run is starting, initialize.
537 if ((Propagate->GetVel().Magnitude() > 0.1) &&
538 (FCS->GetBrake(bgLeft) == 0) &&
539 (FCS->GetBrake(bgRight) == 0) &&
540 (FCS->GetThrottlePos(0) > 0.90) && !StartedGroundRun)
542 TakeoffDistanceTraveled = 0;
543 TakeoffDistanceTraveled50ft = 0;
544 StartedGroundRun = true;
548 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
549 // Takeoff and landing reporting functionality
551 void FGLGear::ReportTakeoffOrLanding(void)
553 double deltaT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
556 LandingDistanceTraveled += Auxiliary->GetVground()*deltaT;
558 if (StartedGroundRun) {
559 TakeoffDistanceTraveled50ft += Auxiliary->GetVground()*deltaT;
560 if (WOW) TakeoffDistanceTraveled += Auxiliary->GetVground()*deltaT;
564 && Auxiliary->GetVground() <= 0.05
566 && Exec->GetGroundReactions()->GetWOW())
568 if (debug_lvl > 0) Report(erLand);
573 && (Propagate->GetDistanceAGL() - vLocalGear(eZ)) > 50.0
574 && !Exec->GetGroundReactions()->GetWOW())
576 if (debug_lvl > 0) Report(erTakeoff);
579 if (lastWOW != WOW) PutMessage("GEAR_CONTACT: " + name, WOW);
582 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
583 // Crash detection logic (really out-of-bounds detection)
585 void FGLGear::CrashDetect(void)
587 if ( (compressLength > 500.0 ||
588 vForce.Magnitude() > 100000000.0 ||
589 vMoment.Magnitude() > 5000000000.0 ||
590 SinkRate > 1.4666*30 ) && !State->IntegrationSuspended())
592 PutMessage("Crash Detected: Simulation FREEZE.");
593 State->SuspendIntegration();
597 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598 // The following needs work regarding friction coefficients and braking and
599 // steering The BrakeFCoeff formula assumes that an anti-skid system is used.
600 // It also assumes that we won't be turning and braking at the same time.
601 // Will fix this later.
602 // [JSB] The braking force coefficients include normal rolling coefficient +
603 // a percentage of the static friction coefficient based on braking applied.
605 void FGLGear::ComputeBrakeForceCoefficient(void)
609 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
610 staticFCoeff*FCS->GetBrake(bgLeft) );
613 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
614 staticFCoeff*FCS->GetBrake(bgRight) );
617 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
618 staticFCoeff*FCS->GetBrake(bgCenter) );
621 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
622 staticFCoeff*FCS->GetBrake(bgCenter) );
625 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
626 staticFCoeff*FCS->GetBrake(bgCenter) );
629 BrakeFCoeff = rollingFCoeff;
632 cerr << "Improper brake group membership detected for this gear." << endl;
637 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
638 // Compute the sideforce coefficients using similar assumptions to LaRCSim for now.
639 // Allow a maximum of 10 degrees tire slip angle before wheel slides. At that point,
640 // transition from static to dynamic friction. There are more complicated formulations
641 // of this that avoid the discrete jump (similar to Pacejka). Will fix this later.
643 void FGLGear::ComputeSideForceCoefficient(void)
647 FCoeff = ForceY_Table->GetValue(WheelSlip);
651 if (fabs(WheelSlip) <= 10.0) {
652 FCoeff = staticFCoeff*WheelSlip/10.0;
653 } else if (fabs(WheelSlip) <= 40.0) {
654 FCoeff = (dynamicFCoeff*(fabs(WheelSlip) - 10.0)/10.0
655 + staticFCoeff*(40.0 - fabs(WheelSlip))/10.0)*(WheelSlip>=0?1.0:-1.0);
657 FCoeff = dynamicFCoeff*(WheelSlip>=0?1.0:-1.0);
662 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
663 // Compute the vertical force on the wheel using square-law damping (per comment
664 // in paper AIAA-2000-4303 - see header prologue comments). We might consider
665 // allowing for both square and linear damping force calculation. Also need to
666 // possibly give a "rebound damping factor" that differs from the compression
669 void FGLGear::ComputeVerticalStrutForce(void)
671 double springForce = 0;
672 double dampForce = 0;
674 springForce = -compressLength * kSpring;
676 if (compressSpeed >= 0.0) {
677 dampForce = -compressSpeed * bDamp;
679 dampForce = -compressSpeed * bDampRebound;
681 vLocalForce(eZ) = min(springForce + dampForce, (double)0.0);
683 // Remember these values for reporting
684 MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ)));
685 MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
688 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
690 double FGLGear::GetGearUnitPos(void)
692 // hack to provide backward compatibility to gear/gear-pos-norm property
693 if( useFCSGearPos || FCS->GetGearPos() != 1.0 ) {
694 useFCSGearPos = true;
695 return FCS->GetGearPos();
700 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
702 void FGLGear::bind(void)
704 char property_name[80];
705 if (eContactType == ctBOGEY) {
706 snprintf(property_name, 80, "gear/unit[%d]/slip-angle-deg", GearNumber);
707 Exec->GetPropertyManager()->Tie( property_name, &WheelSlip );
708 snprintf(property_name, 80, "gear/unit[%d]/WOW", GearNumber);
709 Exec->GetPropertyManager()->Tie( property_name, &WOW );
710 snprintf(property_name, 80, "gear/unit[%d]/wheel-speed-fps", GearNumber);
711 Exec->GetPropertyManager()->Tie( property_name, &RollingWhlVel );
712 snprintf(property_name, 80, "gear/unit[%d]/z-position", GearNumber);
713 Exec->GetPropertyManager()->Tie( property_name, (FGLGear*)this,
714 &FGLGear::GetZPosition, &FGLGear::SetZPosition);
717 if( isRetractable ) {
718 snprintf(property_name, 80, "gear/unit[%d]/pos-norm", GearNumber);
719 Exec->GetPropertyManager()->Tie( property_name, &GearPos );
724 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
726 void FGLGear::Report(ReportType repType)
730 cout << endl << "Touchdown report for " << name << endl;
731 cout << " Sink rate at contact: " << SinkRate << " fps, "
732 << SinkRate*0.3048 << " mps" << endl;
733 cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, "
734 << GroundSpeed*0.3048 << " mps" << endl;
735 cout << " Maximum contact force: " << MaximumStrutForce << " lbs, "
736 << MaximumStrutForce*4.448 << " Newtons" << endl;
737 cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, "
738 << MaximumStrutTravel*30.48 << " cm" << endl;
739 cout << " Distance traveled: " << LandingDistanceTraveled << " ft, "
740 << LandingDistanceTraveled*0.3048 << " meters" << endl;
741 LandingReported = true;
744 cout << endl << "Takeoff report for " << name << endl;
745 cout << " Distance traveled: " << TakeoffDistanceTraveled
746 << " ft, " << TakeoffDistanceTraveled*0.3048 << " meters" << endl;
747 cout << " Distance traveled (over 50'): " << TakeoffDistanceTraveled50ft
748 << " ft, " << TakeoffDistanceTraveled50ft*0.3048 << " meters" << endl;
749 TakeoffReported = true;
754 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
755 // The bitmasked value choices are as follows:
756 // unset: In this case (the default) JSBSim would only print
757 // out the normally expected messages, essentially echoing
758 // the config files as they are read. If the environment
759 // variable is not set, debug_lvl is set to 1 internally
760 // 0: This requests JSBSim not to output any messages
762 // 1: This value explicity requests the normal JSBSim
764 // 2: This value asks for a message to be printed out when
765 // a class is instantiated
766 // 4: When this value is set, a message is displayed when a
767 // FGModel object executes its Run() method
768 // 8: When this value is set, various runtime state variables
769 // are printed out periodically
770 // 16: When set various parameters are sanity checked and
771 // a message is printed out when they go out of bounds
773 void FGLGear::Debug(int from)
775 if (debug_lvl <= 0) return;
777 if (debug_lvl & 1) { // Standard console startup message output
778 if (from == 0) { // Constructor - loading and initialization
779 cout << " " << sContactType << " " << name << endl;
780 cout << " Location: " << vXYZ << endl;
781 cout << " Spring Constant: " << kSpring << endl;
782 cout << " Damping Constant: " << bDamp << endl;
783 cout << " Dynamic Friction: " << dynamicFCoeff << endl;
784 cout << " Static Friction: " << staticFCoeff << endl;
785 if (eContactType == ctBOGEY) {
786 cout << " Rolling Friction: " << rollingFCoeff << endl;
787 cout << " Steering Type: " << sSteerType << endl;
788 cout << " Grouping: " << sBrakeGroup << endl;
789 cout << " Max Steer Angle: " << maxSteerAngle << endl;
790 cout << " Retractable: " << isRetractable << endl;
791 cout << " Relaxation Velocities:" << endl;
792 cout << " Rolling: " << RFRV << endl;
793 cout << " Side: " << SFRV << endl;
797 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
798 if (from == 0) cout << "Instantiated: FGLGear" << endl;
799 if (from == 1) cout << "Destroyed: FGLGear" << endl;
801 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
803 if (debug_lvl & 8 ) { // Runtime state variables
805 if (debug_lvl & 16) { // Sanity checking
807 if (debug_lvl & 64) {
808 if (from == 0) { // Constructor
809 cout << IdSrc << endl;
810 cout << IdHdr << endl;
815 } // namespace JSBSim