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;
65 Element *dampCoeffRebound=0;
68 kSpring = bDamp = bDampRebound = dynamicFCoeff = staticFCoeff = rollingFCoeff = maxSteerAngle = 0;
69 sSteerType = sBrakeGroup = sSteerType = "";
72 eDampTypeRebound = dtLinear;
74 name = el->GetAttributeValue("name");
75 sContactType = el->GetAttributeValue("type");
76 if (sContactType == "BOGEY") {
77 eContactType = ctBOGEY;
78 } else if (sContactType == "STRUCTURE") {
79 eContactType = ctSTRUCTURE;
81 eContactType = ctUNKNOWN;
84 if (el->FindElement("spring_coeff"))
85 kSpring = el->FindElementValueAsNumberConvertTo("spring_coeff", "LBS/FT");
86 if (el->FindElement("damping_coeff")) {
87 dampCoeff = el->FindElement("damping_coeff");
88 if (dampCoeff->GetAttributeValue("type") == "SQUARE") {
90 bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT2/SEC2");
92 bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT/SEC");
96 if (el->FindElement("damping_coeff_rebound")) {
97 dampCoeffRebound = el->FindElement("damping_coeff_rebound");
98 if (dampCoeffRebound->GetAttributeValue("type") == "SQUARE") {
99 eDampTypeRebound = dtSquare;
100 bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT2/SEC2");
102 bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT/SEC");
105 bDampRebound = bDamp;
106 eDampTypeRebound = eDampType;
109 if (el->FindElement("dynamic_friction"))
110 dynamicFCoeff = el->FindElementValueAsNumber("dynamic_friction");
111 if (el->FindElement("static_friction"))
112 staticFCoeff = el->FindElementValueAsNumber("static_friction");
113 if (el->FindElement("rolling_friction"))
114 rollingFCoeff = el->FindElementValueAsNumber("rolling_friction");
115 if (el->FindElement("max_steer"))
116 maxSteerAngle = el->FindElementValueAsNumberConvertTo("max_steer", "DEG");
117 if (el->FindElement("retractable"))
118 isRetractable = ((unsigned int)el->FindElementValueAsNumber("retractable"))>0.0?true:false;
121 force_table = el->FindElement("table");
122 while (force_table) {
123 force_type = force_table->GetAttributeValue("type");
124 if (force_type == "CORNERING_COEFF") {
125 ForceY_Table = new FGTable(Exec->GetPropertyManager(), force_table);
127 cerr << "Undefined force table for " << name << " contact point" << endl;
129 force_table = el->FindNextElement("table");
132 sBrakeGroup = el->FindElementValue("brake_group");
134 if (maxSteerAngle == 360) sSteerType = "CASTERED";
135 else if (maxSteerAngle == 0.0) sSteerType = "FIXED";
136 else sSteerType = "STEERABLE";
138 Element* element = el->FindElement("location");
139 if (element) vXYZ = element->FindElementTripletConvertTo("IN");
140 else {cerr << "No location given for contact " << name << endl; exit(-1);}
142 if (sBrakeGroup == "LEFT" ) eBrakeGrp = bgLeft;
143 else if (sBrakeGroup == "RIGHT" ) eBrakeGrp = bgRight;
144 else if (sBrakeGroup == "CENTER") eBrakeGrp = bgCenter;
145 else if (sBrakeGroup == "NOSE" ) eBrakeGrp = bgNose;
146 else if (sBrakeGroup == "TAIL" ) eBrakeGrp = bgTail;
147 else if (sBrakeGroup == "NONE" ) eBrakeGrp = bgNone;
148 else if (sBrakeGroup.empty() ) {eBrakeGrp = bgNone;
149 sBrakeGroup = "NONE (defaulted)";}
151 cerr << "Improper braking group specification in config file: "
152 << sBrakeGroup << " is undefined." << endl;
155 if (sSteerType == "STEERABLE") eSteerType = stSteer;
156 else if (sSteerType == "FIXED" ) eSteerType = stFixed;
157 else if (sSteerType == "CASTERED" ) eSteerType = stCaster;
158 else if (sSteerType.empty() ) {eSteerType = stFixed;
159 sSteerType = "FIXED (defaulted)";}
161 cerr << "Improper steering type specification in config file: "
162 << sSteerType << " is undefined." << endl;
165 RFRV = 0.7; // Rolling force relaxation velocity, default value
166 SFRV = 0.7; // Side force relaxation velocity, default value
168 Element* relax_vel = el->FindElement("relaxation_velocity");
170 if (relax_vel->FindElement("rolling")) {
171 RFRV = relax_vel->FindElementValueAsNumberConvertTo("rolling", "FT/SEC");
173 if (relax_vel->FindElement("side")) {
174 SFRV = relax_vel->FindElementValueAsNumberConvertTo("side", "FT/SEC");
178 State = Exec->GetState();
179 LongForceLagFilterCoeff = 1/State->Getdt(); // default longitudinal force filter coefficient
180 LatForceLagFilterCoeff = 1/State->Getdt(); // default lateral force filter coefficient
182 Element* force_lag_filter_elem = el->FindElement("force_lag_filter");
183 if (force_lag_filter_elem) {
184 if (force_lag_filter_elem->FindElement("rolling")) {
185 LongForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("rolling");
187 if (force_lag_filter_elem->FindElement("side")) {
188 LatForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("side");
192 WheelSlipLagFilterCoeff = 1/State->Getdt();
194 Element *wheel_slip_angle_lag_elem = el->FindElement("wheel_slip_filter");
195 if (wheel_slip_angle_lag_elem) {
196 WheelSlipLagFilterCoeff = wheel_slip_angle_lag_elem->GetDataAsNumber();
202 useFCSGearPos = false;
205 // Add some AI here to determine if gear is located properly according to its
206 // brake group type ??
208 State = Exec->GetState();
209 Aircraft = Exec->GetAircraft();
210 Propagate = Exec->GetPropagate();
211 Auxiliary = Exec->GetAuxiliary();
212 FCS = Exec->GetFCS();
213 MassBalance = Exec->GetMassBalance();
215 WOW = lastWOW = false;
217 FirstContact = false;
218 StartedGroundRun = false;
219 TakeoffReported = LandingReported = false;
220 LandingDistanceTraveled = TakeoffDistanceTraveled = TakeoffDistanceTraveled50ft = 0.0;
221 MaximumStrutForce = MaximumStrutTravel = 0.0;
222 SideForce = RollingForce = 0.0;
223 SinkRate = GroundSpeed = 0.0;
225 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ);
227 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec;
229 compressLength = 0.0;
235 TirePressureNorm = 1.0;
249 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251 FGLGear::FGLGear(const FGLGear& lgear)
253 GearNumber = lgear.GearNumber;
255 Aircraft = lgear.Aircraft;
256 Propagate = lgear.Propagate;
257 Auxiliary = lgear.Auxiliary;
260 MassBalance = lgear.MassBalance;
263 vMoment = lgear.vMoment;
264 vWhlBodyVec = lgear.vWhlBodyVec;
265 vLocalGear = lgear.vLocalGear;
268 lastWOW = lgear.lastWOW;
269 ReportEnable = lgear.ReportEnable;
270 FirstContact = lgear.FirstContact;
271 StartedGroundRun = lgear.StartedGroundRun;
272 LandingDistanceTraveled = lgear.LandingDistanceTraveled;
273 TakeoffDistanceTraveled = lgear.TakeoffDistanceTraveled;
274 TakeoffDistanceTraveled50ft = lgear.TakeoffDistanceTraveled50ft;
275 MaximumStrutForce = lgear.MaximumStrutForce;
276 MaximumStrutTravel = lgear.MaximumStrutTravel;
277 SideForce = lgear.SideForce;
278 RollingForce = lgear.RollingForce;
280 kSpring = lgear.kSpring;
282 bDampRebound = lgear.bDampRebound;
283 compressLength = lgear.compressLength;
284 compressSpeed = lgear.compressSpeed;
285 staticFCoeff = lgear.staticFCoeff;
286 dynamicFCoeff = lgear.dynamicFCoeff;
287 rollingFCoeff = lgear.rollingFCoeff;
288 brakePct = lgear.brakePct;
289 maxCompLen = lgear.maxCompLen;
290 SinkRate = lgear.SinkRate;
291 GroundSpeed = lgear.GroundSpeed;
292 LandingReported = lgear.LandingReported;
293 TakeoffReported = lgear.TakeoffReported;
295 sSteerType = lgear.sSteerType;
296 sRetractable = lgear.sRetractable;
297 sContactType = lgear.sContactType;
298 eContactType = lgear.eContactType;
299 sBrakeGroup = lgear.sBrakeGroup;
300 eSteerType = lgear.eSteerType;
301 eBrakeGrp = lgear.eBrakeGrp;
302 maxSteerAngle = lgear.maxSteerAngle;
303 isRetractable = lgear.isRetractable;
304 GearUp = lgear.GearUp;
305 GearDown = lgear.GearDown;
306 GearPos = lgear.GearPos;
307 useFCSGearPos = lgear.useFCSGearPos;
308 WheelSlip = lgear.WheelSlip;
309 TirePressureNorm = lgear.TirePressureNorm;
310 Servicable = lgear.Servicable;
311 ForceY_Table = lgear.ForceY_Table;
312 CosWheel = lgear.CosWheel;
313 SinWheel = lgear.SinWheel;
314 prevOut = lgear.prevOut;
315 prevIn = lgear.prevIn;
316 prevSlipIn = lgear.prevSlipIn;
317 prevSlipOut = lgear.prevSlipOut;
320 LongForceLagFilterCoeff = lgear.LongForceLagFilterCoeff;
321 LatForceLagFilterCoeff = lgear.LatForceLagFilterCoeff;
322 WheelSlipLagFilterCoeff = lgear.WheelSlipLagFilterCoeff;
325 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
332 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
334 FGColumnVector3& FGLGear::Force(void)
336 double t = Exec->GetState()->Getsim_time();
337 dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
340 vMoment.InitMatrix();
342 if (isRetractable) ComputeRetractionState();
344 if (!GearDown) return vForce; // return the null vForce column vector
346 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ); // Get wheel in body frame
347 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec; // Get local frame wheel location
349 gearLoc = Propagate->GetLocation().LocalToLocation(vLocalGear);
350 compressLength = -Exec->GetGroundCallback()->GetAGLevel(t, gearLoc, contact, normal, cvel);
352 // The compression length is measured in the Z-axis, only, at this time.
354 if (compressLength > 0.00) {
358 // [The next equation should really use the vector to the contact patch of
359 // the tire including the strut compression and not the original vWhlBodyVec.]
361 vWhlVelVec = Propagate->GetTb2l() * (Propagate->GetPQR() * vWhlBodyVec);
362 vWhlVelVec += Propagate->GetVel() - cvel;
363 compressSpeed = vWhlVelVec(eZ);
365 InitializeReporting();
366 ComputeBrakeForceCoefficient();
367 ComputeSteeringAngle();
369 ComputeSideForceCoefficient();
370 ComputeVerticalStrutForce();
372 // Compute the forces in the wheel ground plane.
374 double sign = RollingWhlVel>0?1.0:(RollingWhlVel<0?-1.0:0.0);
375 RollingForce = ((1.0 - TirePressureNorm) * 30 + vLocalForce(eZ) * BrakeFCoeff) * sign;
376 SideForce = vLocalForce(eZ) * FCoeff;
378 // Transform these forces back to the local reference frame.
380 vLocalForce(eX) = RollingForce*CosWheel - SideForce*SinWheel;
381 vLocalForce(eY) = SideForce*CosWheel + RollingForce*SinWheel;
383 // Transform the forces back to the body frame and compute the moment.
385 vForce = Propagate->GetTl2b() * vLocalForce;
387 // Start experimental section for gear jitter reduction
389 // Lag and attenuate the XY-plane forces dependent on velocity
391 double ca, cb, denom;
392 FGColumnVector3 Output;
394 // This code implements a lag filter, C/(s + C) where
395 // "C" is the filter coefficient. When "C" is chosen at the
396 // frame rate (in Hz), the jittering is significantly reduced. This is because
397 // the jitter is present *at* the execution rate.
398 // If a coefficient is set to something equal to or less than zero, the filter
401 if (LongForceLagFilterCoeff > 0) {
402 denom = 2.00 + dT*LongForceLagFilterCoeff;
403 ca = dT*LongForceLagFilterCoeff / denom;
404 cb = (2.00 - dT*LongForceLagFilterCoeff) / denom;
405 Output(eX) = vForce(eX) * ca + prevIn(eX) * ca + prevOut(eX) * cb;
406 vForce(eX) = Output(eX);
408 if (LatForceLagFilterCoeff > 0) {
409 denom = 2.00 + dT*LatForceLagFilterCoeff;
410 ca = dT*LatForceLagFilterCoeff / denom;
411 cb = (2.00 - dT*LatForceLagFilterCoeff) / denom;
412 Output(eY) = vForce(eY) * ca + prevIn(eY) * ca + prevOut(eY) * cb;
413 vForce(eY) = Output(eY);
419 if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
420 if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) vForce(eY) *= fabs(SideWhlVel)/SFRV;
422 // End section for attentuating gear jitter
424 vMoment = vWhlBodyVec * vForce;
426 } else { // Gear is NOT compressed
429 compressLength = 0.0;
431 // Return to neutral position between 1.0 and 0.8 gear pos.
432 SteerAngle *= max(GetGearUnitPos()-0.8, 0.0)/0.2;
437 ReportTakeoffOrLanding();
439 // Require both WOW and LastWOW to be true before checking crash conditions
440 // to allow the WOW flag to be used in terminating a scripted run.
441 if (WOW && lastWOW) CrashDetect();
448 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
450 void FGLGear::ComputeRetractionState(void)
452 double gearPos = GetGearUnitPos();
453 if (gearPos < 0.01) {
456 } else if (gearPos > 0.99) {
465 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
467 void FGLGear::ComputeSlipAngle(void)
469 // Transform the wheel velocities from the local axis system to the wheel axis system.
470 RollingWhlVel = vWhlVelVec(eX)*CosWheel + vWhlVelVec(eY)*SinWheel;
471 SideWhlVel = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel;
473 // Calculate tire slip angle.
474 WheelSlip = atan2(SideWhlVel, fabs(RollingWhlVel))*radtodeg;
476 // Filter the wheel slip angle
478 double SlipOutput, ca, cb, denom;
480 if (WheelSlipLagFilterCoeff > 0) {
481 denom = 2.00 + dT*WheelSlipLagFilterCoeff;
482 ca = dT*WheelSlipLagFilterCoeff / denom;
483 cb = (2.00 - dT*WheelSlipLagFilterCoeff) / denom;
485 SlipOutput = ca * (WheelSlip + prevSlipIn) + cb * prevSlipOut;
487 prevSlipIn = WheelSlip;
488 WheelSlip = prevSlipOut = SlipOutput;
492 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
493 // Compute the steering angle in any case.
494 // This will also make sure that animations will look right.
496 void FGLGear::ComputeSteeringAngle(void)
498 double casterLocalFrameAngleRad = 0.0;
499 double casterAngle = 0.0;
501 switch (eSteerType) {
503 SteerAngle = degtorad * FCS->GetSteerPosDeg(GearNumber);
509 // This is not correct for castering gear. Should make steer angle parallel
510 // to the actual velocity vector of the wheel, given aircraft velocity vector
513 casterLocalFrameAngleRad = acos(vWhlVelVec(eX)/vWhlVelVec.Magnitude());
514 casterAngle = casterLocalFrameAngleRad - Propagate->GetEuler(ePsi);
517 cerr << "Improper steering type membership detected for this gear." << endl;
521 SinWheel = sin(Propagate->GetEuler(ePsi) + SteerAngle);
522 CosWheel = cos(Propagate->GetEuler(ePsi) + SteerAngle);
525 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
526 // Reset reporting functionality after takeoff
528 void FGLGear::ResetReporting(void)
530 if (Propagate->GetDistanceAGL() > 200.0) {
531 FirstContact = false;
532 StartedGroundRun = false;
533 LandingReported = false;
534 TakeoffReported = true;
535 LandingDistanceTraveled = 0.0;
536 MaximumStrutForce = MaximumStrutTravel = 0.0;
540 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
542 void FGLGear::InitializeReporting(void)
544 // If this is the first time the wheel has made contact, remember some values
545 // for later printout.
549 SinkRate = compressSpeed;
550 GroundSpeed = Propagate->GetVel().Magnitude();
551 TakeoffReported = false;
554 // If the takeoff run is starting, initialize.
556 if ((Propagate->GetVel().Magnitude() > 0.1) &&
557 (FCS->GetBrake(bgLeft) == 0) &&
558 (FCS->GetBrake(bgRight) == 0) &&
559 (FCS->GetThrottlePos(0) > 0.90) && !StartedGroundRun)
561 TakeoffDistanceTraveled = 0;
562 TakeoffDistanceTraveled50ft = 0;
563 StartedGroundRun = true;
567 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
568 // Takeoff and landing reporting functionality
570 void FGLGear::ReportTakeoffOrLanding(void)
572 double deltaT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
575 LandingDistanceTraveled += Auxiliary->GetVground()*deltaT;
577 if (StartedGroundRun) {
578 TakeoffDistanceTraveled50ft += Auxiliary->GetVground()*deltaT;
579 if (WOW) TakeoffDistanceTraveled += Auxiliary->GetVground()*deltaT;
583 && Auxiliary->GetVground() <= 0.05
585 && Exec->GetGroundReactions()->GetWOW())
587 if (debug_lvl > 0) Report(erLand);
592 && (Propagate->GetDistanceAGL() - vLocalGear(eZ)) > 50.0
593 && !Exec->GetGroundReactions()->GetWOW())
595 if (debug_lvl > 0) Report(erTakeoff);
598 if (lastWOW != WOW) PutMessage("GEAR_CONTACT: " + name, WOW);
601 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
602 // Crash detection logic (really out-of-bounds detection)
604 void FGLGear::CrashDetect(void)
606 if ( (compressLength > 500.0 ||
607 vForce.Magnitude() > 100000000.0 ||
608 vMoment.Magnitude() > 5000000000.0 ||
609 SinkRate > 1.4666*30 ) && !State->IntegrationSuspended())
611 PutMessage("Crash Detected: Simulation FREEZE.");
612 State->SuspendIntegration();
616 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
617 // The following needs work regarding friction coefficients and braking and
618 // steering The BrakeFCoeff formula assumes that an anti-skid system is used.
619 // It also assumes that we won't be turning and braking at the same time.
620 // Will fix this later.
621 // [JSB] The braking force coefficients include normal rolling coefficient +
622 // a percentage of the static friction coefficient based on braking applied.
624 void FGLGear::ComputeBrakeForceCoefficient(void)
628 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
629 staticFCoeff*FCS->GetBrake(bgLeft) );
632 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
633 staticFCoeff*FCS->GetBrake(bgRight) );
636 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
637 staticFCoeff*FCS->GetBrake(bgCenter) );
640 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
641 staticFCoeff*FCS->GetBrake(bgCenter) );
644 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
645 staticFCoeff*FCS->GetBrake(bgCenter) );
648 BrakeFCoeff = rollingFCoeff;
651 cerr << "Improper brake group membership detected for this gear." << endl;
656 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
657 // Compute the sideforce coefficients using similar assumptions to LaRCSim for now.
658 // Allow a maximum of 10 degrees tire slip angle before wheel slides. At that point,
659 // transition from static to dynamic friction. There are more complicated formulations
660 // of this that avoid the discrete jump (similar to Pacejka). Will fix this later.
662 void FGLGear::ComputeSideForceCoefficient(void)
666 FCoeff = ForceY_Table->GetValue(WheelSlip);
670 if (fabs(WheelSlip) <= 10.0) {
671 FCoeff = staticFCoeff*WheelSlip/10.0;
672 } else if (fabs(WheelSlip) <= 40.0) {
673 FCoeff = (dynamicFCoeff*(fabs(WheelSlip) - 10.0)/10.0
674 + staticFCoeff*(40.0 - fabs(WheelSlip))/10.0)*(WheelSlip>=0?1.0:-1.0);
676 FCoeff = dynamicFCoeff*(WheelSlip>=0?1.0:-1.0);
681 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
682 // Compute the vertical force on the wheel using square-law damping (per comment
683 // in paper AIAA-2000-4303 - see header prologue comments). We might consider
684 // allowing for both square and linear damping force calculation. Also need to
685 // possibly give a "rebound damping factor" that differs from the compression
688 void FGLGear::ComputeVerticalStrutForce(void)
690 double springForce = 0;
691 double dampForce = 0;
693 springForce = -compressLength * kSpring;
695 if (compressSpeed >= 0.0) {
697 if (eDampType == dtLinear) dampForce = -compressSpeed * bDamp;
698 else dampForce = -compressSpeed * compressSpeed * bDamp;
702 if (eDampTypeRebound == dtLinear)
703 dampForce = -compressSpeed * bDampRebound;
705 dampForce = compressSpeed * compressSpeed * bDampRebound;
708 vLocalForce(eZ) = min(springForce + dampForce, (double)0.0);
710 // Remember these values for reporting
711 MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ)));
712 MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
715 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
717 double FGLGear::GetGearUnitPos(void)
719 // hack to provide backward compatibility to gear/gear-pos-norm property
720 if( useFCSGearPos || FCS->GetGearPos() != 1.0 ) {
721 useFCSGearPos = true;
722 return FCS->GetGearPos();
727 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
729 void FGLGear::bind(void)
731 char property_name[80];
732 if (eContactType == ctBOGEY) {
733 snprintf(property_name, 80, "gear/unit[%d]/slip-angle-deg", GearNumber);
734 Exec->GetPropertyManager()->Tie( property_name, &WheelSlip );
735 snprintf(property_name, 80, "gear/unit[%d]/WOW", GearNumber);
736 Exec->GetPropertyManager()->Tie( property_name, &WOW );
737 snprintf(property_name, 80, "gear/unit[%d]/wheel-speed-fps", GearNumber);
738 Exec->GetPropertyManager()->Tie( property_name, &RollingWhlVel );
739 snprintf(property_name, 80, "gear/unit[%d]/z-position", GearNumber);
740 Exec->GetPropertyManager()->Tie( property_name, (FGLGear*)this,
741 &FGLGear::GetZPosition, &FGLGear::SetZPosition);
744 if( isRetractable ) {
745 snprintf(property_name, 80, "gear/unit[%d]/pos-norm", GearNumber);
746 Exec->GetPropertyManager()->Tie( property_name, &GearPos );
751 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
753 void FGLGear::Report(ReportType repType)
757 cout << endl << "Touchdown report for " << name << endl;
758 cout << " Sink rate at contact: " << SinkRate << " fps, "
759 << SinkRate*0.3048 << " mps" << endl;
760 cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, "
761 << GroundSpeed*0.3048 << " mps" << endl;
762 cout << " Maximum contact force: " << MaximumStrutForce << " lbs, "
763 << MaximumStrutForce*4.448 << " Newtons" << endl;
764 cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, "
765 << MaximumStrutTravel*30.48 << " cm" << endl;
766 cout << " Distance traveled: " << LandingDistanceTraveled << " ft, "
767 << LandingDistanceTraveled*0.3048 << " meters" << endl;
768 LandingReported = true;
771 cout << endl << "Takeoff report for " << name << endl;
772 cout << " Distance traveled: " << TakeoffDistanceTraveled
773 << " ft, " << TakeoffDistanceTraveled*0.3048 << " meters" << endl;
774 cout << " Distance traveled (over 50'): " << TakeoffDistanceTraveled50ft
775 << " ft, " << TakeoffDistanceTraveled50ft*0.3048 << " meters" << endl;
776 TakeoffReported = true;
781 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
782 // The bitmasked value choices are as follows:
783 // unset: In this case (the default) JSBSim would only print
784 // out the normally expected messages, essentially echoing
785 // the config files as they are read. If the environment
786 // variable is not set, debug_lvl is set to 1 internally
787 // 0: This requests JSBSim not to output any messages
789 // 1: This value explicity requests the normal JSBSim
791 // 2: This value asks for a message to be printed out when
792 // a class is instantiated
793 // 4: When this value is set, a message is displayed when a
794 // FGModel object executes its Run() method
795 // 8: When this value is set, various runtime state variables
796 // are printed out periodically
797 // 16: When set various parameters are sanity checked and
798 // a message is printed out when they go out of bounds
800 void FGLGear::Debug(int from)
802 if (debug_lvl <= 0) return;
804 if (debug_lvl & 1) { // Standard console startup message output
805 if (from == 0) { // Constructor - loading and initialization
806 cout << " " << sContactType << " " << name << endl;
807 cout << " Location: " << vXYZ << endl;
808 cout << " Spring Constant: " << kSpring << endl;
810 if (eDampType == dtLinear)
811 cout << " Damping Constant: " << bDamp << " (linear)" << endl;
813 cout << " Damping Constant: " << bDamp << " (square law)" << endl;
815 if (eDampTypeRebound == dtLinear)
816 cout << " Rebound Damping Constant: " << bDampRebound << " (linear)" << endl;
818 cout << " Rebound Damping Constant: " << bDampRebound << " (square law)" << endl;
820 cout << " Dynamic Friction: " << dynamicFCoeff << endl;
821 cout << " Static Friction: " << staticFCoeff << endl;
822 if (eContactType == ctBOGEY) {
823 cout << " Rolling Friction: " << rollingFCoeff << endl;
824 cout << " Steering Type: " << sSteerType << endl;
825 cout << " Grouping: " << sBrakeGroup << endl;
826 cout << " Max Steer Angle: " << maxSteerAngle << endl;
827 cout << " Retractable: " << isRetractable << endl;
828 cout << " Relaxation Velocities:" << endl;
829 cout << " Rolling: " << RFRV << endl;
830 cout << " Side: " << SFRV << endl;
834 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
835 if (from == 0) cout << "Instantiated: FGLGear" << endl;
836 if (from == 1) cout << "Destroyed: FGLGear" << endl;
838 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
840 if (debug_lvl & 8 ) { // Runtime state variables
842 if (debug_lvl & 16) { // Sanity checking
844 if (debug_lvl & 64) {
845 if (from == 0) { // Constructor
846 cout << IdSrc << endl;
847 cout << IdHdr << endl;
852 } // namespace JSBSim