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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55 static const char *IdSrc = "$Id$";
56 static const char *IdHdr = ID_LGEAR;
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62 FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) : Exec(fdmex),
65 Element *force_table=0;
68 kSpring = bDamp = bDampRebound = dynamicFCoeff = staticFCoeff = rollingFCoeff = maxSteerAngle = 0;
69 sSteerType = sBrakeGroup = sSteerType = "";
72 name = el->GetAttributeValue("name");
73 sContactType = el->GetAttributeValue("type");
74 if (el->FindElement("spring_coeff"))
75 kSpring = el->FindElementValueAsNumberConvertTo("spring_coeff", "LBS/FT");
76 if (el->FindElement("damping_coeff"))
77 bDamp = el->FindElementValueAsNumberConvertTo("damping_coeff", "LBS/FT/SEC");
79 if (el->FindElement("damping_coeff_rebound"))
80 bDampRebound = el->FindElementValueAsNumberConvertTo("damping_coeff_rebound", "LBS/FT/SEC");
84 if (el->FindElement("dynamic_friction"))
85 dynamicFCoeff = el->FindElementValueAsNumber("dynamic_friction");
86 if (el->FindElement("static_friction"))
87 staticFCoeff = el->FindElementValueAsNumber("static_friction");
88 if (el->FindElement("rolling_friction"))
89 rollingFCoeff = el->FindElementValueAsNumber("rolling_friction");
90 if (el->FindElement("max_steer"))
91 maxSteerAngle = el->FindElementValueAsNumberConvertTo("max_steer", "DEG");
92 if (el->FindElement("retractable"))
93 isRetractable = ((unsigned int)el->FindElementValueAsNumber("retractable"))>0.0?true:false;
96 force_table = el->FindElement("table");
98 force_type = force_table->GetAttributeValue("type");
99 if (force_type == "CORNERING_COEFF") {
100 ForceY_Table = new FGTable(Exec->GetPropertyManager(), force_table);
102 cerr << "Undefined force table for " << name << " contact point" << endl;
104 force_table = el->FindNextElement("table");
107 sBrakeGroup = el->FindElementValue("brake_group");
109 if (maxSteerAngle == 360) sSteerType = "CASTERED";
110 else if (maxSteerAngle == 0.0) sSteerType = "FIXED";
111 else sSteerType = "STEERABLE";
113 Element* element = el->FindElement("location");
114 if (element) vXYZ = element->FindElementTripletConvertTo("IN");
115 else {cerr << "No location given for contact " << name << endl; exit(-1);}
117 if (sBrakeGroup == "LEFT" ) eBrakeGrp = bgLeft;
118 else if (sBrakeGroup == "RIGHT" ) eBrakeGrp = bgRight;
119 else if (sBrakeGroup == "CENTER") eBrakeGrp = bgCenter;
120 else if (sBrakeGroup == "NOSE" ) eBrakeGrp = bgNose;
121 else if (sBrakeGroup == "TAIL" ) eBrakeGrp = bgTail;
122 else if (sBrakeGroup == "NONE" ) eBrakeGrp = bgNone;
123 else if (sBrakeGroup.empty() ) {eBrakeGrp = bgNone;
124 sBrakeGroup = "NONE (defaulted)";}
126 cerr << "Improper braking group specification in config file: "
127 << sBrakeGroup << " is undefined." << endl;
130 if (sSteerType == "STEERABLE") eSteerType = stSteer;
131 else if (sSteerType == "FIXED" ) eSteerType = stFixed;
132 else if (sSteerType == "CASTERED" ) eSteerType = stCaster;
133 else if (sSteerType.empty() ) {eSteerType = stFixed;
134 sSteerType = "FIXED (defaulted)";}
136 cerr << "Improper steering type specification in config file: "
137 << sSteerType << " is undefined." << endl;
140 RFRV = 0.7; // Rolling force relaxation velocity, default value
141 SFRV = 0.7; // Side force relaxation velocity, default value
143 Element* relax_vel = el->FindElement("relaxation_velocity");
145 if (relax_vel->FindElement("rolling")) {
146 RFRV = relax_vel->FindElementValueAsNumberConvertTo("rolling", "FT/SEC");
148 if (relax_vel->FindElement("side")) {
149 SFRV = relax_vel->FindElementValueAsNumberConvertTo("side", "FT/SEC");
153 State = Exec->GetState();
154 LongForceLagFilterCoeff = 1/State->Getdt(); // default longitudinal force filter coefficient
155 LatForceLagFilterCoeff = 1/State->Getdt(); // default lateral force filter coefficient
157 Element* force_lag_filter_elem = el->FindElement("force_lag_filter");
158 if (force_lag_filter_elem) {
159 if (force_lag_filter_elem->FindElement("rolling")) {
160 LongForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("rolling");
162 if (force_lag_filter_elem->FindElement("side")) {
163 LatForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("side");
167 WheelSlipLagFilterCoeff = 1/State->Getdt();
169 Element *wheel_slip_angle_lag_elem = el->FindElement("wheel_slip_filter");
170 if (wheel_slip_angle_lag_elem) {
171 WheelSlipLagFilterCoeff = wheel_slip_angle_lag_elem->GetDataAsNumber();
178 // Add some AI here to determine if gear is located properly according to its
179 // brake group type ??
181 State = Exec->GetState();
182 Aircraft = Exec->GetAircraft();
183 Propagate = Exec->GetPropagate();
184 Auxiliary = Exec->GetAuxiliary();
185 FCS = Exec->GetFCS();
186 MassBalance = Exec->GetMassBalance();
188 WOW = lastWOW = false;
190 FirstContact = false;
191 StartedGroundRun = false;
192 TakeoffReported = LandingReported = false;
193 LandingDistanceTraveled = TakeoffDistanceTraveled = TakeoffDistanceTraveled50ft = 0.0;
194 MaximumStrutForce = MaximumStrutTravel = 0.0;
195 SideForce = RollingForce = 0.0;
196 SinkRate = GroundSpeed = 0.0;
198 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ);
200 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec;
202 compressLength = 0.0;
208 TirePressureNorm = 1.0;
222 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
224 FGLGear::FGLGear(const FGLGear& lgear)
226 GearNumber = lgear.GearNumber;
228 Aircraft = lgear.Aircraft;
229 Propagate = lgear.Propagate;
230 Auxiliary = lgear.Auxiliary;
233 MassBalance = lgear.MassBalance;
236 vMoment = lgear.vMoment;
237 vWhlBodyVec = lgear.vWhlBodyVec;
238 vLocalGear = lgear.vLocalGear;
241 lastWOW = lgear.lastWOW;
242 ReportEnable = lgear.ReportEnable;
243 FirstContact = lgear.FirstContact;
244 StartedGroundRun = lgear.StartedGroundRun;
245 LandingDistanceTraveled = lgear.LandingDistanceTraveled;
246 TakeoffDistanceTraveled = lgear.TakeoffDistanceTraveled;
247 TakeoffDistanceTraveled50ft = lgear.TakeoffDistanceTraveled50ft;
248 MaximumStrutForce = lgear.MaximumStrutForce;
249 MaximumStrutTravel = lgear.MaximumStrutTravel;
250 SideForce = lgear.SideForce;
251 RollingForce = lgear.RollingForce;
253 kSpring = lgear.kSpring;
255 bDampRebound = lgear.bDampRebound;
256 compressLength = lgear.compressLength;
257 compressSpeed = lgear.compressSpeed;
258 staticFCoeff = lgear.staticFCoeff;
259 dynamicFCoeff = lgear.dynamicFCoeff;
260 rollingFCoeff = lgear.rollingFCoeff;
261 brakePct = lgear.brakePct;
262 maxCompLen = lgear.maxCompLen;
263 SinkRate = lgear.SinkRate;
264 GroundSpeed = lgear.GroundSpeed;
265 LandingReported = lgear.LandingReported;
266 TakeoffReported = lgear.TakeoffReported;
268 sSteerType = lgear.sSteerType;
269 sRetractable = lgear.sRetractable;
270 sContactType = lgear.sContactType;
271 sBrakeGroup = lgear.sBrakeGroup;
272 eSteerType = lgear.eSteerType;
273 eBrakeGrp = lgear.eBrakeGrp;
274 maxSteerAngle = lgear.maxSteerAngle;
275 isRetractable = lgear.isRetractable;
276 GearUp = lgear.GearUp;
277 GearDown = lgear.GearDown;
278 WheelSlip = lgear.WheelSlip;
279 TirePressureNorm = lgear.TirePressureNorm;
280 Servicable = lgear.Servicable;
281 ForceY_Table = lgear.ForceY_Table;
282 CosWheel = lgear.CosWheel;
283 SinWheel = lgear.SinWheel;
284 prevOut = lgear.prevOut;
285 prevIn = lgear.prevIn;
286 prevSlipIn = lgear.prevSlipIn;
287 prevSlipOut = lgear.prevSlipOut;
290 LongForceLagFilterCoeff = lgear.LongForceLagFilterCoeff;
291 LatForceLagFilterCoeff = lgear.LatForceLagFilterCoeff;
292 WheelSlipLagFilterCoeff = lgear.WheelSlipLagFilterCoeff;
295 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
302 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
304 FGColumnVector3& FGLGear::Force(void)
306 FGColumnVector3 normal, cvel;
307 FGLocation contact, gearLoc;
308 double t = Exec->GetState()->Getsim_time();
309 dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
312 vMoment.InitMatrix();
314 if (isRetractable) ComputeRetractionState();
316 if (GearUp) return vForce;
318 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ); // Get wheel in body frame
319 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec; // Get local frame wheel location
321 gearLoc = Propagate->GetLocation().LocalToLocation(vLocalGear);
322 compressLength = -Exec->GetGroundCallback()->GetAGLevel(t, gearLoc, contact, normal, cvel);
324 // The compression length is measured in the Z-axis, only, at this time.
326 if (compressLength > 0.00) {
330 // [The next equation should really use the vector to the contact patch of
331 // the tire including the strut compression and not the original vWhlBodyVec.]
333 vWhlVelVec = Propagate->GetTb2l() * (Propagate->GetPQR() * vWhlBodyVec);
334 vWhlVelVec += Propagate->GetVel() - cvel;
335 compressSpeed = vWhlVelVec(eZ);
337 InitializeReporting();
338 ComputeBrakeForceCoefficient();
339 ComputeSteeringAngle();
341 ComputeSideForceCoefficient();
342 ComputeVerticalStrutForce();
344 // Compute the forces in the wheel ground plane.
346 RollingForce = ((1.0 - TirePressureNorm) * 30
347 + vLocalForce(eZ) * BrakeFCoeff) * (RollingWhlVel>=0?1.0:-1.0);
349 SideForce = vLocalForce(eZ) * FCoeff;
351 // Transform these forces back to the local reference frame.
353 vLocalForce(eX) = RollingForce*CosWheel - SideForce*SinWheel;
354 vLocalForce(eY) = SideForce*CosWheel + RollingForce*SinWheel;
356 // Transform the forces back to the body frame and compute the moment.
358 vForce = Propagate->GetTl2b() * vLocalForce;
360 // Start experimental section for gear jitter reduction
362 // Lag and attenuate the XY-plane forces dependent on velocity
364 double ca, cb, denom;
365 FGColumnVector3 Output;
367 // This code implements a lag filter, C/(s + C) where
368 // "C" is the filter coefficient. When "C" is chosen at the
369 // frame rate (in Hz), the jittering is significantly reduced. This is because
370 // the jitter is present *at* the execution rate.
371 // If a coefficient is set to something equal to or less than zero, the filter
374 if (LongForceLagFilterCoeff > 0) {
375 denom = 2.00 + dT*LongForceLagFilterCoeff;
376 ca = dT*LongForceLagFilterCoeff / denom;
377 cb = (2.00 - dT*LongForceLagFilterCoeff) / denom;
378 Output(eX) = vForce(eX) * ca + prevIn(eX) * ca + prevOut(eX) * cb;
379 vForce(eX) = Output(eX);
381 if (LatForceLagFilterCoeff > 0) {
382 denom = 2.00 + dT*LatForceLagFilterCoeff;
383 ca = dT*LatForceLagFilterCoeff / denom;
384 cb = (2.00 - dT*LatForceLagFilterCoeff) / denom;
385 Output(eY) = vForce(eY) * ca + prevIn(eY) * ca + prevOut(eY) * cb;
386 vForce(eY) = Output(eY);
392 if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
393 if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) vForce(eY) *= fabs(SideWhlVel)/SFRV;
395 // End section for attentuating gear jitter
397 vMoment = vWhlBodyVec * vForce;
399 } else { // Gear is NOT compressed
402 compressLength = 0.0;
404 // Return to neutral position between 1.0 and 0.8 gear pos.
405 SteerAngle *= max(FCS->GetGearPos()-0.8, 0.0)/0.2;
410 ReportTakeoffOrLanding();
416 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
418 void FGLGear::ComputeRetractionState(void)
420 if (FCS->GetGearPos() < 0.01) {
423 } else if (FCS->GetGearPos() > 0.99) {
432 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
434 void FGLGear::ComputeSlipAngle(void)
436 // Transform the wheel velocities from the local axis system to the wheel axis system.
437 RollingWhlVel = vWhlVelVec(eX)*CosWheel + vWhlVelVec(eY)*SinWheel;
438 SideWhlVel = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel;
440 // Calculate tire slip angle.
441 WheelSlip = atan2(SideWhlVel, fabs(RollingWhlVel))*radtodeg;
443 // Filter the wheel slip angle
445 double SlipOutput, ca, cb, denom;
447 if (WheelSlipLagFilterCoeff > 0) {
448 denom = 2.00 + dT*WheelSlipLagFilterCoeff;
449 ca = dT*WheelSlipLagFilterCoeff / denom;
450 cb = (2.00 - dT*WheelSlipLagFilterCoeff) / denom;
452 SlipOutput = ca * (WheelSlip + prevSlipIn) + cb * prevSlipOut;
454 prevSlipIn = WheelSlip;
455 WheelSlip = prevSlipOut = SlipOutput;
459 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
460 // Compute the steering angle in any case.
461 // This will also make sure that animations will look right.
463 void FGLGear::ComputeSteeringAngle(void)
465 switch (eSteerType) {
467 SteerAngle = degtorad * FCS->GetSteerPosDeg(GearNumber);
473 // This is not correct for castering gear. Should make steer angle parallel
474 // to the actual velocity vector of the wheel, given aircraft velocity vector
479 cerr << "Improper steering type membership detected for this gear." << endl;
483 SinWheel = sin(Propagate->GetEuler(ePsi) + SteerAngle);
484 CosWheel = cos(Propagate->GetEuler(ePsi) + SteerAngle);
487 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
488 // Reset reporting functionality after takeoff
490 void FGLGear::ResetReporting(void)
492 if (Propagate->GetDistanceAGL() > 200.0) {
493 FirstContact = false;
494 StartedGroundRun = false;
495 LandingReported = false;
496 LandingDistanceTraveled = 0.0;
497 MaximumStrutForce = MaximumStrutTravel = 0.0;
501 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
503 void FGLGear::InitializeReporting(void)
505 // If this is the first time the wheel has made contact, remember some values
506 // for later printout.
510 SinkRate = compressSpeed;
511 GroundSpeed = Propagate->GetVel().Magnitude();
512 TakeoffReported = false;
515 // If the takeoff run is starting, initialize.
517 if ((Propagate->GetVel().Magnitude() > 0.1) &&
518 (FCS->GetBrake(bgLeft) == 0) &&
519 (FCS->GetBrake(bgRight) == 0) &&
520 (FCS->GetThrottlePos(0) == 1) && !StartedGroundRun)
522 TakeoffDistanceTraveled = 0;
523 TakeoffDistanceTraveled50ft = 0;
524 StartedGroundRun = true;
528 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
529 // Takeoff and landing reporting functionality
531 void FGLGear::ReportTakeoffOrLanding(void)
533 double deltaT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
535 if (FirstContact) LandingDistanceTraveled += Auxiliary->GetVground()*deltaT;
537 if (StartedGroundRun) {
538 TakeoffDistanceTraveled50ft += Auxiliary->GetVground()*deltaT;
539 if (WOW) TakeoffDistanceTraveled += Auxiliary->GetVground()*deltaT;
542 if (ReportEnable && Auxiliary->GetVground() <= 0.05 && !LandingReported) {
543 if (debug_lvl > 0) Report(erLand);
546 if (ReportEnable && !TakeoffReported &&
547 (vLocalGear(eZ) - Propagate->GetDistanceAGL()) < -50.0)
549 if (debug_lvl > 0) Report(erTakeoff);
552 if (lastWOW != WOW) PutMessage("GEAR_CONTACT: " + name, WOW);
556 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
557 // Crash detection logic (really out-of-bounds detection)
559 void FGLGear::CrashDetect(void)
561 if ( (compressLength > 500.0 ||
562 vForce.Magnitude() > 100000000.0 ||
563 vMoment.Magnitude() > 5000000000.0 ||
564 SinkRate > 1.4666*30 ) && !State->IntegrationSuspended())
566 PutMessage("Crash Detected: Simulation FREEZE.");
567 State->SuspendIntegration();
571 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
572 // The following needs work regarding friction coefficients and braking and
573 // steering The BrakeFCoeff formula assumes that an anti-skid system is used.
574 // It also assumes that we won't be turning and braking at the same time.
575 // Will fix this later.
576 // [JSB] The braking force coefficients include normal rolling coefficient +
577 // a percentage of the static friction coefficient based on braking applied.
579 void FGLGear::ComputeBrakeForceCoefficient(void)
583 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
584 staticFCoeff*FCS->GetBrake(bgLeft) );
587 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
588 staticFCoeff*FCS->GetBrake(bgRight) );
591 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
592 staticFCoeff*FCS->GetBrake(bgCenter) );
595 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
596 staticFCoeff*FCS->GetBrake(bgCenter) );
599 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
600 staticFCoeff*FCS->GetBrake(bgCenter) );
603 BrakeFCoeff = rollingFCoeff;
606 cerr << "Improper brake group membership detected for this gear." << endl;
611 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
612 // Compute the sideforce coefficients using similar assumptions to LaRCSim for now.
613 // Allow a maximum of 10 degrees tire slip angle before wheel slides. At that point,
614 // transition from static to dynamic friction. There are more complicated formulations
615 // of this that avoid the discrete jump (similar to Pacejka). Will fix this later.
617 void FGLGear::ComputeSideForceCoefficient(void)
621 FCoeff = ForceY_Table->GetValue(WheelSlip);
625 if (fabs(WheelSlip) <= 10.0) {
626 FCoeff = staticFCoeff*WheelSlip/10.0;
627 } else if (fabs(WheelSlip) <= 40.0) {
628 FCoeff = (dynamicFCoeff*(fabs(WheelSlip) - 10.0)/10.0
629 + staticFCoeff*(40.0 - fabs(WheelSlip))/10.0)*(WheelSlip>=0?1.0:-1.0);
631 FCoeff = dynamicFCoeff*(WheelSlip>=0?1.0:-1.0);
636 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
637 // Compute the vertical force on the wheel using square-law damping (per comment
638 // in paper AIAA-2000-4303 - see header prologue comments). We might consider
639 // allowing for both square and linear damping force calculation. Also need to
640 // possibly give a "rebound damping factor" that differs from the compression
643 void FGLGear::ComputeVerticalStrutForce(void)
645 double springForce = 0;
646 double dampForce = 0;
648 springForce = -compressLength * kSpring;
650 if (compressSpeed >= 0.0) {
651 dampForce = -compressSpeed * bDamp;
653 dampForce = -compressSpeed * bDampRebound;
655 vLocalForce(eZ) = std::min(springForce + dampForce, (double)0.0);
657 // Remember these values for reporting
658 MaximumStrutForce = std::max(MaximumStrutForce, fabs(vLocalForce(eZ)));
659 MaximumStrutTravel = std::max(MaximumStrutTravel, fabs(compressLength));
662 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
664 void FGLGear::bind(void)
666 char property_name[80];
667 snprintf(property_name, 80, "gear/unit[%d]/slip-angle-deg", GearNumber);
668 Exec->GetPropertyManager()->Tie( property_name, &WheelSlip );
671 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
673 void FGLGear::unbind(void)
675 char property_name[80];
676 snprintf(property_name, 80, "gear/unit[%d]/slip-angle-deg", GearNumber);
677 Exec->GetPropertyManager()->Untie( property_name );
680 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
682 void FGLGear::Report(ReportType repType)
686 cout << endl << "Touchdown report for " << name << endl;
687 cout << " Sink rate at contact: " << SinkRate << " fps, "
688 << SinkRate*0.3048 << " mps" << endl;
689 cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, "
690 << GroundSpeed*0.3048 << " mps" << endl;
691 cout << " Maximum contact force: " << MaximumStrutForce << " lbs, "
692 << MaximumStrutForce*4.448 << " Newtons" << endl;
693 cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, "
694 << MaximumStrutTravel*30.48 << " cm" << endl;
695 cout << " Distance traveled: " << LandingDistanceTraveled << " ft, "
696 << LandingDistanceTraveled*0.3048 << " meters" << endl;
697 LandingReported = true;
700 cout << endl << "Takeoff report for " << name << endl;
701 cout << " Distance traveled: " << TakeoffDistanceTraveled
702 << " ft, " << TakeoffDistanceTraveled*0.3048 << " meters" << endl;
703 cout << " Distance traveled (over 50'): " << TakeoffDistanceTraveled50ft
704 << " ft, " << TakeoffDistanceTraveled50ft*0.3048 << " meters" << endl;
705 TakeoffReported = true;
710 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
711 // The bitmasked value choices are as follows:
712 // unset: In this case (the default) JSBSim would only print
713 // out the normally expected messages, essentially echoing
714 // the config files as they are read. If the environment
715 // variable is not set, debug_lvl is set to 1 internally
716 // 0: This requests JSBSim not to output any messages
718 // 1: This value explicity requests the normal JSBSim
720 // 2: This value asks for a message to be printed out when
721 // a class is instantiated
722 // 4: When this value is set, a message is displayed when a
723 // FGModel object executes its Run() method
724 // 8: When this value is set, various runtime state variables
725 // are printed out periodically
726 // 16: When set various parameters are sanity checked and
727 // a message is printed out when they go out of bounds
729 void FGLGear::Debug(int from)
731 if (debug_lvl <= 0) return;
733 if (debug_lvl & 1) { // Standard console startup message output
734 if (from == 0) { // Constructor - loading and initialization
735 cout << " " << sContactType << " " << name << endl;
736 cout << " Location: " << vXYZ << endl;
737 cout << " Spring Constant: " << kSpring << endl;
738 cout << " Damping Constant: " << bDamp << endl;
739 cout << " Dynamic Friction: " << dynamicFCoeff << endl;
740 cout << " Static Friction: " << staticFCoeff << endl;
741 if (sContactType == "BOGEY") {
742 cout << " Rolling Friction: " << rollingFCoeff << endl;
743 cout << " Steering Type: " << sSteerType << endl;
744 cout << " Grouping: " << sBrakeGroup << endl;
745 cout << " Max Steer Angle: " << maxSteerAngle << endl;
746 cout << " Retractable: " << isRetractable << endl;
747 cout << " Relaxation Velocities:" << endl;
748 cout << " Rolling: " << RFRV << endl;
749 cout << " Side: " << SFRV << endl;
753 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
754 if (from == 0) cout << "Instantiated: FGLGear" << endl;
755 if (from == 1) cout << "Destroyed: FGLGear" << endl;
757 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
759 if (debug_lvl & 8 ) { // Runtime state variables
761 if (debug_lvl & 16) { // Sanity checking
763 if (debug_lvl & 64) {
764 if (from == 0) { // Constructor
765 cout << IdSrc << endl;
766 cout << IdHdr << endl;
771 } // namespace JSBSim