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 (el->FindElement("spring_coeff"))
73 kSpring = el->FindElementValueAsNumberConvertTo("spring_coeff", "LBS/FT");
74 if (el->FindElement("damping_coeff"))
75 bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT/SEC");
77 if (el->FindElement("damping_coeff_rebound"))
78 bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT/SEC");
82 if (el->FindElement("dynamic_friction"))
83 dynamicFCoeff = el->FindElementValueAsNumber("dynamic_friction");
84 if (el->FindElement("static_friction"))
85 staticFCoeff = el->FindElementValueAsNumber("static_friction");
86 if (el->FindElement("rolling_friction"))
87 rollingFCoeff = el->FindElementValueAsNumber("rolling_friction");
88 if (el->FindElement("max_steer"))
89 maxSteerAngle = el->FindElementValueAsNumberConvertTo("max_steer", "DEG");
90 if (el->FindElement("retractable"))
91 isRetractable = (int)el->FindElementValueAsNumber("retractable");
94 force_table = el->FindElement("table");
96 force_type = force_table->GetAttributeValue("type");
97 if (force_type == "CORNERING_COEFF") {
98 ForceY_Table = new FGTable(Exec->GetPropertyManager(), force_table);
100 cerr << "Undefined force table for " << name << " contact point" << endl;
102 force_table = el->FindNextElement("table");
105 sBrakeGroup = el->FindElementValue("brake_group");
107 if (maxSteerAngle == 360) sSteerType = "CASTERED";
108 else if (maxSteerAngle == 0.0) sSteerType = "FIXED";
109 else sSteerType = "STEERABLE";
111 Element* element = el->FindElement("location");
112 if (element) vXYZ = element->FindElementTripletConvertTo("IN");
113 else {cerr << "No location given for contact " << name << endl; exit(-1);}
115 if (sBrakeGroup == "LEFT" ) eBrakeGrp = bgLeft;
116 else if (sBrakeGroup == "RIGHT" ) eBrakeGrp = bgRight;
117 else if (sBrakeGroup == "CENTER") eBrakeGrp = bgCenter;
118 else if (sBrakeGroup == "NOSE" ) eBrakeGrp = bgNose;
119 else if (sBrakeGroup == "TAIL" ) eBrakeGrp = bgTail;
120 else if (sBrakeGroup == "NONE" ) eBrakeGrp = bgNone;
121 else if (sBrakeGroup.empty() ) {eBrakeGrp = bgNone;
122 sBrakeGroup = "NONE (defaulted)";}
124 cerr << "Improper braking group specification in config file: "
125 << sBrakeGroup << " is undefined." << endl;
128 if (sSteerType == "STEERABLE") eSteerType = stSteer;
129 else if (sSteerType == "FIXED" ) eSteerType = stFixed;
130 else if (sSteerType == "CASTERED" ) eSteerType = stCaster;
131 else if (sSteerType.empty() ) {eSteerType = stFixed;
132 sSteerType = "FIXED (defaulted)";}
134 cerr << "Improper steering type specification in config file: "
135 << sSteerType << " is undefined." << endl;
138 RFRV = 0.7; // Rolling force relaxation velocity, default value
139 SFRV = 0.7; // Side force relaxation velocity, default value
141 Element* relax_vel = el->FindElement("relaxation_velocity");
143 if (relax_vel->FindElement("rolling")) {
144 RFRV = relax_vel->FindElementValueAsNumberConvertTo("rolling", "FT/SEC");
146 if (relax_vel->FindElement("side")) {
147 SFRV = relax_vel->FindElementValueAsNumberConvertTo("side", "FT/SEC");
151 State = Exec->GetState();
152 LongForceLagFilterCoeff = 1/State->Getdt(); // default longitudinal force filter coefficient
153 LatForceLagFilterCoeff = 1/State->Getdt(); // default lateral force filter coefficient
155 Element* force_lag_filter_elem = el->FindElement("force_lag_filter");
156 if (force_lag_filter_elem) {
157 if (force_lag_filter_elem->FindElement("rolling")) {
158 LongForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("rolling");
160 if (force_lag_filter_elem->FindElement("side")) {
161 LatForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("side");
165 WheelSlipLagFilterCoeff = 1/State->Getdt();
167 Element *wheel_slip_angle_lag_elem = el->FindElement("wheel_slip_filter");
168 if (wheel_slip_angle_lag_elem) {
169 WheelSlipLagFilterCoeff = wheel_slip_angle_lag_elem->GetDataAsNumber();
176 // Add some AI here to determine if gear is located properly according to its
177 // brake group type ??
179 State = Exec->GetState();
180 Aircraft = Exec->GetAircraft();
181 Propagate = Exec->GetPropagate();
182 Auxiliary = Exec->GetAuxiliary();
183 FCS = Exec->GetFCS();
184 MassBalance = Exec->GetMassBalance();
186 WOW = lastWOW = true; // should the value be initialized to true?
188 FirstContact = false;
189 StartedGroundRun = false;
190 TakeoffReported = LandingReported = false;
191 LandingDistanceTraveled = TakeoffDistanceTraveled = TakeoffDistanceTraveled50ft = 0.0;
192 MaximumStrutForce = MaximumStrutTravel = 0.0;
193 SideForce = RollingForce = 0.0;
194 SinkRate = GroundSpeed = 0.0;
196 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ);
198 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec;
200 compressLength = 0.0;
206 TirePressureNorm = 1.0;
211 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
213 FGLGear::FGLGear(const FGLGear& lgear)
215 GearNumber = lgear.GearNumber;
217 Aircraft = lgear.Aircraft;
218 Propagate = lgear.Propagate;
219 Auxiliary = lgear.Auxiliary;
222 MassBalance = lgear.MassBalance;
225 vMoment = lgear.vMoment;
226 vWhlBodyVec = lgear.vWhlBodyVec;
227 vLocalGear = lgear.vLocalGear;
230 lastWOW = lgear.lastWOW;
231 ReportEnable = lgear.ReportEnable;
232 FirstContact = lgear.FirstContact;
233 StartedGroundRun = lgear.StartedGroundRun;
234 LandingDistanceTraveled = lgear.LandingDistanceTraveled;
235 TakeoffDistanceTraveled = lgear.TakeoffDistanceTraveled;
236 TakeoffDistanceTraveled50ft = lgear.TakeoffDistanceTraveled50ft;
237 MaximumStrutForce = lgear.MaximumStrutForce;
238 MaximumStrutTravel = lgear.MaximumStrutTravel;
239 SideForce = lgear.SideForce;
240 RollingForce = lgear.RollingForce;
242 kSpring = lgear.kSpring;
244 bDampRebound = lgear.bDampRebound;
245 compressLength = lgear.compressLength;
246 compressSpeed = lgear.compressSpeed;
247 staticFCoeff = lgear.staticFCoeff;
248 dynamicFCoeff = lgear.dynamicFCoeff;
249 rollingFCoeff = lgear.rollingFCoeff;
250 brakePct = lgear.brakePct;
251 maxCompLen = lgear.maxCompLen;
252 SinkRate = lgear.SinkRate;
253 GroundSpeed = lgear.GroundSpeed;
254 LandingReported = lgear.LandingReported;
255 TakeoffReported = lgear.TakeoffReported;
257 sSteerType = lgear.sSteerType;
258 sRetractable = lgear.sRetractable;
259 sContactType = lgear.sContactType;
260 sBrakeGroup = lgear.sBrakeGroup;
261 eSteerType = lgear.eSteerType;
262 eBrakeGrp = lgear.eBrakeGrp;
263 maxSteerAngle = lgear.maxSteerAngle;
264 isRetractable = lgear.isRetractable;
265 GearUp = lgear.GearUp;
266 GearDown = lgear.GearDown;
267 WheelSlip = lgear.WheelSlip;
268 TirePressureNorm = lgear.TirePressureNorm;
269 Servicable = lgear.Servicable;
270 ForceY_Table = lgear.ForceY_Table;
271 CosWheel = lgear.CosWheel;
272 SinWheel = lgear.SinWheel;
273 prevOut = lgear.prevOut;
274 prevIn = lgear.prevIn;
275 prevSlipIn = lgear.prevSlipIn;
276 prevSlipOut = lgear.prevSlipOut;
279 LongForceLagFilterCoeff = lgear.LongForceLagFilterCoeff;
280 LatForceLagFilterCoeff = lgear.LatForceLagFilterCoeff;
281 WheelSlipLagFilterCoeff = lgear.WheelSlipLagFilterCoeff;
284 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
291 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
293 FGColumnVector3& FGLGear::Force(void)
295 FGColumnVector3 normal, cvel;
296 FGLocation contact, gearLoc;
297 double t = Exec->GetState()->Getsim_time();
298 dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
301 vMoment.InitMatrix();
303 if (isRetractable) ComputeRetractionState();
305 if (GearUp) return vForce;
307 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ); // Get wheel in body frame
308 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec; // Get local frame wheel location
310 gearLoc = Propagate->GetLocation().LocalToLocation(vLocalGear);
311 compressLength = -Exec->GetGroundCallback()->GetAGLevel(t, gearLoc, contact, normal, cvel);
313 // The compression length is measured in the Z-axis, only, at this time.
315 if (compressLength > 0.00) {
319 // [The next equation should really use the vector to the contact patch of
320 // the tire including the strut compression and not the original vWhlBodyVec.]
322 vWhlVelVec = Propagate->GetTb2l() * (Propagate->GetPQR() * vWhlBodyVec);
323 vWhlVelVec += Propagate->GetVel() - cvel;
324 compressSpeed = vWhlVelVec(eZ);
326 InitializeReporting();
327 ComputeBrakeForceCoefficient();
328 ComputeSteeringAngle();
330 ComputeSideForceCoefficient();
331 ComputeVerticalStrutForce();
333 // Compute the forces in the wheel ground plane.
335 RollingForce = (1.0 - TirePressureNorm) * 30
336 + vLocalForce(eZ) * BrakeFCoeff * (RollingWhlVel>=0?1.0:-1.0);
337 SideForce = vLocalForce(eZ) * FCoeff;
339 // Transform these forces back to the local reference frame.
341 vLocalForce(eX) = RollingForce*CosWheel - SideForce*SinWheel;
342 vLocalForce(eY) = SideForce*CosWheel + RollingForce*SinWheel;
344 // Transform the forces back to the body frame and compute the moment.
346 vForce = Propagate->GetTl2b() * vLocalForce;
348 // Start experimental section for gear jitter reduction
350 // Lag and attenuate the XY-plane forces dependent on velocity
352 double ca, cb, denom;
353 FGColumnVector3 Output;
355 // This code implements a lag filter, C/(s + C) where
356 // "C" is the filter coefficient. When "C" is chosen at the
357 // frame rate (in Hz), the jittering is significantly reduced. This is because
358 // the jitter is present *at* the execution rate.
359 // If a coefficient is set to something equal to or less than zero, the filter
362 if (LongForceLagFilterCoeff > 0) {
363 denom = 2.00 + dT*LongForceLagFilterCoeff;
364 ca = dT*LongForceLagFilterCoeff / denom;
365 cb = (2.00 - dT*LongForceLagFilterCoeff) / denom;
366 Output(eX) = vForce(eX) * ca + prevIn(eX) * ca + prevOut(eX) * cb;
367 vForce(eX) = Output(eX);
369 if (LatForceLagFilterCoeff > 0) {
370 denom = 2.00 + dT*LatForceLagFilterCoeff;
371 ca = dT*LatForceLagFilterCoeff / denom;
372 cb = (2.00 - dT*LatForceLagFilterCoeff) / denom;
373 Output(eY) = vForce(eY) * ca + prevIn(eY) * ca + prevOut(eY) * cb;
374 vForce(eY) = Output(eY);
380 if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
381 if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) vForce(eY) *= fabs(SideWhlVel)/SFRV;
383 // End experimental section for attentuating gear jitter
385 vMoment = vWhlBodyVec * vForce;
387 } else { // Gear is NOT compressed
390 compressLength = 0.0;
392 // Return to neutral position between 1.0 and 0.8 gear pos.
393 SteerAngle *= max(FCS->GetGearPos()-0.8, 0.0)/0.2;
398 ReportTakeoffOrLanding();
404 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
406 void FGLGear::ComputeRetractionState(void)
408 if (FCS->GetGearPos() < 0.01) {
411 } else if (FCS->GetGearPos() > 0.99) {
420 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
422 void FGLGear::ComputeSlipAngle(void)
424 // Transform the wheel velocities from the local axis system to the wheel axis system.
425 RollingWhlVel = vWhlVelVec(eX)*CosWheel + vWhlVelVec(eY)*SinWheel;
426 SideWhlVel = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel;
428 // Calculate tire slip angle.
429 if (fabs(RollingWhlVel) < 0.02 && fabs(SideWhlVel) < 0.02) {
430 WheelSlip = -SteerAngle*radtodeg;
432 WheelSlip = atan2(SideWhlVel, fabs(RollingWhlVel))*radtodeg;
435 // Filter the wheel slip angle
437 double SlipOutput, ca, cb, denom;
439 if (WheelSlipLagFilterCoeff > 0) {
440 denom = 2.00 + dT*WheelSlipLagFilterCoeff;
441 ca = dT*WheelSlipLagFilterCoeff / denom;
442 cb = (2.00 - dT*WheelSlipLagFilterCoeff) / denom;
444 SlipOutput = ca * (WheelSlip + prevSlipIn) + cb * prevSlipOut;
446 prevSlipIn = WheelSlip;
447 WheelSlip = prevSlipOut = SlipOutput;
451 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
452 // Compute the steering angle in any case.
453 // This will also make sure that animations will look right.
455 void FGLGear::ComputeSteeringAngle(void)
457 switch (eSteerType) {
459 SteerAngle = degtorad * FCS->GetSteerPosDeg(GearNumber);
465 // This is not correct for castering gear. Should make steer angle parallel
466 // to the actual velocity vector of the wheel, given aircraft velocity vector
471 cerr << "Improper steering type membership detected for this gear." << endl;
475 SinWheel = sin(Propagate->GetEuler(ePsi) + SteerAngle);
476 CosWheel = cos(Propagate->GetEuler(ePsi) + SteerAngle);
479 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
480 // Reset reporting functionality after takeoff
482 void FGLGear::ResetReporting(void)
484 if (Propagate->GetDistanceAGL() > 200.0) {
485 FirstContact = false;
486 StartedGroundRun = false;
487 LandingReported = false;
488 LandingDistanceTraveled = 0.0;
489 MaximumStrutForce = MaximumStrutTravel = 0.0;
493 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
495 void FGLGear::InitializeReporting(void)
497 // If this is the first time the wheel has made contact, remember some values
498 // for later printout.
502 SinkRate = compressSpeed;
503 GroundSpeed = Propagate->GetVel().Magnitude();
504 TakeoffReported = false;
507 // If the takeoff run is starting, initialize.
509 if ((Propagate->GetVel().Magnitude() > 0.1) &&
510 (FCS->GetBrake(bgLeft) == 0) &&
511 (FCS->GetBrake(bgRight) == 0) &&
512 (FCS->GetThrottlePos(0) == 1) && !StartedGroundRun)
514 TakeoffDistanceTraveled = 0;
515 TakeoffDistanceTraveled50ft = 0;
516 StartedGroundRun = true;
520 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
521 // Takeoff and landing reporting functionality
523 void FGLGear::ReportTakeoffOrLanding(void)
525 double deltaT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
527 if (FirstContact) LandingDistanceTraveled += Auxiliary->GetVground()*deltaT;
529 if (StartedGroundRun) {
530 TakeoffDistanceTraveled50ft += Auxiliary->GetVground()*deltaT;
531 if (WOW) TakeoffDistanceTraveled += Auxiliary->GetVground()*deltaT;
534 if (ReportEnable && Auxiliary->GetVground() <= 0.05 && !LandingReported) {
535 if (debug_lvl > 0) Report(erLand);
538 if (ReportEnable && !TakeoffReported &&
539 (vLocalGear(eZ) - Propagate->GetDistanceAGL()) < -50.0)
541 if (debug_lvl > 0) Report(erTakeoff);
544 if (lastWOW != WOW) PutMessage("GEAR_CONTACT: " + name, WOW);
548 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
549 // Crash detection logic (really out-of-bounds detection)
551 void FGLGear::CrashDetect(void)
553 if ( (compressLength > 500.0 ||
554 vForce.Magnitude() > 100000000.0 ||
555 vMoment.Magnitude() > 5000000000.0 ||
556 SinkRate > 1.4666*30 ) && !State->IntegrationSuspended())
558 PutMessage("Crash Detected: Simulation FREEZE.");
559 State->SuspendIntegration();
563 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
564 // The following needs work regarding friction coefficients and braking and
565 // steering The BrakeFCoeff formula assumes that an anti-skid system is used.
566 // It also assumes that we won't be turning and braking at the same time.
567 // Will fix this later.
568 // [JSB] The braking force coefficients include normal rolling coefficient +
569 // a percentage of the static friction coefficient based on braking applied.
571 void FGLGear::ComputeBrakeForceCoefficient(void)
575 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
576 staticFCoeff*FCS->GetBrake(bgLeft) );
579 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
580 staticFCoeff*FCS->GetBrake(bgRight) );
583 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
584 staticFCoeff*FCS->GetBrake(bgCenter) );
587 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
588 staticFCoeff*FCS->GetBrake(bgCenter) );
591 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
592 staticFCoeff*FCS->GetBrake(bgCenter) );
595 BrakeFCoeff = rollingFCoeff;
598 cerr << "Improper brake group membership detected for this gear." << endl;
603 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
604 // Compute the sideforce coefficients using similar assumptions to LaRCSim for now.
605 // Allow a maximum of 10 degrees tire slip angle before wheel slides. At that point,
606 // transition from static to dynamic friction. There are more complicated formulations
607 // of this that avoid the discrete jump (similar to Pacejka). Will fix this later.
609 void FGLGear::ComputeSideForceCoefficient(void)
613 FCoeff = ForceY_Table->GetValue(WheelSlip);
617 if (fabs(WheelSlip) <= 10.0) {
618 FCoeff = staticFCoeff*WheelSlip/10.0;
619 } else if (fabs(WheelSlip) <= 40.0) {
620 FCoeff = (dynamicFCoeff*(fabs(WheelSlip) - 10.0)/10.0
621 + staticFCoeff*(40.0 - fabs(WheelSlip))/10.0)*(WheelSlip>=0?1.0:-1.0);
623 FCoeff = dynamicFCoeff*(WheelSlip>=0?1.0:-1.0);
628 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
629 // Compute the vertical force on the wheel using square-law damping (per comment
630 // in paper AIAA-2000-4303 - see header prologue comments). We might consider
631 // allowing for both square and linear damping force calculation. Also need to
632 // possibly give a "rebound damping factor" that differs from the compression
635 void FGLGear::ComputeVerticalStrutForce(void)
637 double springForce = 0;
638 double dampForce = 0;
640 springForce = -compressLength * kSpring;
642 if (compressSpeed >= 0.0) {
643 dampForce = -compressSpeed * bDamp;
645 dampForce = -compressSpeed * bDampRebound;
647 vLocalForce(eZ) = min(springForce + dampForce, (double)0.0);
649 // Remember these values for reporting
650 MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ)));
651 MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
654 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
656 void FGLGear::bind(void)
658 char property_name[80];
659 snprintf(property_name, 80, "gear/unit[%d]/slip-angle-deg", GearNumber);
660 Exec->GetPropertyManager()->Tie( property_name, &WheelSlip );
663 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
665 void FGLGear::unbind(void)
667 char property_name[80];
668 snprintf(property_name, 80, "gear/unit[%d]/slip-angle-deg", GearNumber);
669 Exec->GetPropertyManager()->Untie( property_name );
672 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
674 void FGLGear::Report(ReportType repType)
678 cout << endl << "Touchdown report for " << name << endl;
679 cout << " Sink rate at contact: " << SinkRate << " fps, "
680 << SinkRate*0.3048 << " mps" << endl;
681 cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, "
682 << GroundSpeed*0.3048 << " mps" << endl;
683 cout << " Maximum contact force: " << MaximumStrutForce << " lbs, "
684 << MaximumStrutForce*4.448 << " Newtons" << endl;
685 cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, "
686 << MaximumStrutTravel*30.48 << " cm" << endl;
687 cout << " Distance traveled: " << LandingDistanceTraveled << " ft, "
688 << LandingDistanceTraveled*0.3048 << " meters" << endl;
689 LandingReported = true;
692 cout << endl << "Takeoff report for " << name << endl;
693 cout << " Distance traveled: " << TakeoffDistanceTraveled
694 << " ft, " << TakeoffDistanceTraveled*0.3048 << " meters" << endl;
695 cout << " Distance traveled (over 50'): " << TakeoffDistanceTraveled50ft
696 << " ft, " << TakeoffDistanceTraveled50ft*0.3048 << " meters" << endl;
697 TakeoffReported = true;
702 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
703 // The bitmasked value choices are as follows:
704 // unset: In this case (the default) JSBSim would only print
705 // out the normally expected messages, essentially echoing
706 // the config files as they are read. If the environment
707 // variable is not set, debug_lvl is set to 1 internally
708 // 0: This requests JSBSim not to output any messages
710 // 1: This value explicity requests the normal JSBSim
712 // 2: This value asks for a message to be printed out when
713 // a class is instantiated
714 // 4: When this value is set, a message is displayed when a
715 // FGModel object executes its Run() method
716 // 8: When this value is set, various runtime state variables
717 // are printed out periodically
718 // 16: When set various parameters are sanity checked and
719 // a message is printed out when they go out of bounds
721 void FGLGear::Debug(int from)
723 if (debug_lvl <= 0) return;
725 if (debug_lvl & 1) { // Standard console startup message output
726 if (from == 0) { // Constructor - loading and initialization
727 cout << " " << sContactType << " " << name << endl;
728 cout << " Location: " << vXYZ << endl;
729 cout << " Spring Constant: " << kSpring << endl;
730 cout << " Damping Constant: " << bDamp << endl;
731 cout << " Dynamic Friction: " << dynamicFCoeff << endl;
732 cout << " Static Friction: " << staticFCoeff << endl;
733 if (sContactType == "BOGEY") {
734 cout << " Rolling Friction: " << rollingFCoeff << endl;
735 cout << " Steering Type: " << sSteerType << endl;
736 cout << " Grouping: " << sBrakeGroup << endl;
737 cout << " Max Steer Angle: " << maxSteerAngle << endl;
738 cout << " Retractable: " << isRetractable << endl;
739 cout << " Relaxation Velocities:" << endl;
740 cout << " Rolling: " << RFRV << endl;
741 cout << " Side: " << SFRV << endl;
745 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
746 if (from == 0) cout << "Instantiated: FGLGear" << endl;
747 if (from == 1) cout << "Destroyed: FGLGear" << endl;
749 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
751 if (debug_lvl & 8 ) { // Runtime state variables
753 if (debug_lvl & 16) { // Sanity checking
755 if (debug_lvl & 64) {
756 if (from == 0) { // Constructor
757 cout << IdSrc << endl;
758 cout << IdHdr << endl;
763 } // namespace JSBSim