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 = ((unsigned int)el->FindElementValueAsNumber("retractable"))>0.0?true:false;
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 = false;
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;
220 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
222 FGLGear::FGLGear(const FGLGear& lgear)
224 GearNumber = lgear.GearNumber;
226 Aircraft = lgear.Aircraft;
227 Propagate = lgear.Propagate;
228 Auxiliary = lgear.Auxiliary;
231 MassBalance = lgear.MassBalance;
234 vMoment = lgear.vMoment;
235 vWhlBodyVec = lgear.vWhlBodyVec;
236 vLocalGear = lgear.vLocalGear;
239 lastWOW = lgear.lastWOW;
240 ReportEnable = lgear.ReportEnable;
241 FirstContact = lgear.FirstContact;
242 StartedGroundRun = lgear.StartedGroundRun;
243 LandingDistanceTraveled = lgear.LandingDistanceTraveled;
244 TakeoffDistanceTraveled = lgear.TakeoffDistanceTraveled;
245 TakeoffDistanceTraveled50ft = lgear.TakeoffDistanceTraveled50ft;
246 MaximumStrutForce = lgear.MaximumStrutForce;
247 MaximumStrutTravel = lgear.MaximumStrutTravel;
248 SideForce = lgear.SideForce;
249 RollingForce = lgear.RollingForce;
251 kSpring = lgear.kSpring;
253 bDampRebound = lgear.bDampRebound;
254 compressLength = lgear.compressLength;
255 compressSpeed = lgear.compressSpeed;
256 staticFCoeff = lgear.staticFCoeff;
257 dynamicFCoeff = lgear.dynamicFCoeff;
258 rollingFCoeff = lgear.rollingFCoeff;
259 brakePct = lgear.brakePct;
260 maxCompLen = lgear.maxCompLen;
261 SinkRate = lgear.SinkRate;
262 GroundSpeed = lgear.GroundSpeed;
263 LandingReported = lgear.LandingReported;
264 TakeoffReported = lgear.TakeoffReported;
266 sSteerType = lgear.sSteerType;
267 sRetractable = lgear.sRetractable;
268 sContactType = lgear.sContactType;
269 sBrakeGroup = lgear.sBrakeGroup;
270 eSteerType = lgear.eSteerType;
271 eBrakeGrp = lgear.eBrakeGrp;
272 maxSteerAngle = lgear.maxSteerAngle;
273 isRetractable = lgear.isRetractable;
274 GearUp = lgear.GearUp;
275 GearDown = lgear.GearDown;
276 WheelSlip = lgear.WheelSlip;
277 TirePressureNorm = lgear.TirePressureNorm;
278 Servicable = lgear.Servicable;
279 ForceY_Table = lgear.ForceY_Table;
280 CosWheel = lgear.CosWheel;
281 SinWheel = lgear.SinWheel;
282 prevOut = lgear.prevOut;
283 prevIn = lgear.prevIn;
284 prevSlipIn = lgear.prevSlipIn;
285 prevSlipOut = lgear.prevSlipOut;
288 LongForceLagFilterCoeff = lgear.LongForceLagFilterCoeff;
289 LatForceLagFilterCoeff = lgear.LatForceLagFilterCoeff;
290 WheelSlipLagFilterCoeff = lgear.WheelSlipLagFilterCoeff;
293 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
300 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
302 FGColumnVector3& FGLGear::Force(void)
304 FGColumnVector3 normal, cvel;
305 FGLocation contact, gearLoc;
306 double t = Exec->GetState()->Getsim_time();
307 dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
310 vMoment.InitMatrix();
312 if (isRetractable) ComputeRetractionState();
314 if (GearUp) return vForce;
316 vWhlBodyVec = MassBalance->StructuralToBody(vXYZ); // Get wheel in body frame
317 vLocalGear = Propagate->GetTb2l() * vWhlBodyVec; // Get local frame wheel location
319 gearLoc = Propagate->GetLocation().LocalToLocation(vLocalGear);
320 compressLength = -Exec->GetGroundCallback()->GetAGLevel(t, gearLoc, contact, normal, cvel);
322 // The compression length is measured in the Z-axis, only, at this time.
324 if (compressLength > 0.00) {
328 // [The next equation should really use the vector to the contact patch of
329 // the tire including the strut compression and not the original vWhlBodyVec.]
331 vWhlVelVec = Propagate->GetTb2l() * (Propagate->GetPQR() * vWhlBodyVec);
332 vWhlVelVec += Propagate->GetVel() - cvel;
333 compressSpeed = vWhlVelVec(eZ);
335 InitializeReporting();
336 ComputeBrakeForceCoefficient();
337 ComputeSteeringAngle();
339 ComputeSideForceCoefficient();
340 ComputeVerticalStrutForce();
342 // Compute the forces in the wheel ground plane.
344 RollingForce = ((1.0 - TirePressureNorm) * 30
345 + vLocalForce(eZ) * BrakeFCoeff) * (RollingWhlVel>=0?1.0:-1.0);
347 SideForce = vLocalForce(eZ) * FCoeff;
349 // Transform these forces back to the local reference frame.
351 vLocalForce(eX) = RollingForce*CosWheel - SideForce*SinWheel;
352 vLocalForce(eY) = SideForce*CosWheel + RollingForce*SinWheel;
354 // Transform the forces back to the body frame and compute the moment.
356 vForce = Propagate->GetTl2b() * vLocalForce;
358 // Start experimental section for gear jitter reduction
360 // Lag and attenuate the XY-plane forces dependent on velocity
362 double ca, cb, denom;
363 FGColumnVector3 Output;
365 // This code implements a lag filter, C/(s + C) where
366 // "C" is the filter coefficient. When "C" is chosen at the
367 // frame rate (in Hz), the jittering is significantly reduced. This is because
368 // the jitter is present *at* the execution rate.
369 // If a coefficient is set to something equal to or less than zero, the filter
372 if (LongForceLagFilterCoeff > 0) {
373 denom = 2.00 + dT*LongForceLagFilterCoeff;
374 ca = dT*LongForceLagFilterCoeff / denom;
375 cb = (2.00 - dT*LongForceLagFilterCoeff) / denom;
376 Output(eX) = vForce(eX) * ca + prevIn(eX) * ca + prevOut(eX) * cb;
377 vForce(eX) = Output(eX);
379 if (LatForceLagFilterCoeff > 0) {
380 denom = 2.00 + dT*LatForceLagFilterCoeff;
381 ca = dT*LatForceLagFilterCoeff / denom;
382 cb = (2.00 - dT*LatForceLagFilterCoeff) / denom;
383 Output(eY) = vForce(eY) * ca + prevIn(eY) * ca + prevOut(eY) * cb;
384 vForce(eY) = Output(eY);
390 if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
391 if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) vForce(eY) *= fabs(SideWhlVel)/SFRV;
393 // End section for attentuating gear jitter
395 vMoment = vWhlBodyVec * vForce;
397 } else { // Gear is NOT compressed
400 compressLength = 0.0;
402 // Return to neutral position between 1.0 and 0.8 gear pos.
403 SteerAngle *= max(FCS->GetGearPos()-0.8, 0.0)/0.2;
408 ReportTakeoffOrLanding();
414 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
416 void FGLGear::ComputeRetractionState(void)
418 if (FCS->GetGearPos() < 0.01) {
421 } else if (FCS->GetGearPos() > 0.99) {
430 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
432 void FGLGear::ComputeSlipAngle(void)
434 // Transform the wheel velocities from the local axis system to the wheel axis system.
435 RollingWhlVel = vWhlVelVec(eX)*CosWheel + vWhlVelVec(eY)*SinWheel;
436 SideWhlVel = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel;
438 // Calculate tire slip angle.
439 WheelSlip = atan2(SideWhlVel, fabs(RollingWhlVel))*radtodeg;
441 // Filter the wheel slip angle
443 double SlipOutput, ca, cb, denom;
445 if (WheelSlipLagFilterCoeff > 0) {
446 denom = 2.00 + dT*WheelSlipLagFilterCoeff;
447 ca = dT*WheelSlipLagFilterCoeff / denom;
448 cb = (2.00 - dT*WheelSlipLagFilterCoeff) / denom;
450 SlipOutput = ca * (WheelSlip + prevSlipIn) + cb * prevSlipOut;
452 prevSlipIn = WheelSlip;
453 WheelSlip = prevSlipOut = SlipOutput;
457 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
458 // Compute the steering angle in any case.
459 // This will also make sure that animations will look right.
461 void FGLGear::ComputeSteeringAngle(void)
463 switch (eSteerType) {
465 SteerAngle = degtorad * FCS->GetSteerPosDeg(GearNumber);
471 // This is not correct for castering gear. Should make steer angle parallel
472 // to the actual velocity vector of the wheel, given aircraft velocity vector
477 cerr << "Improper steering type membership detected for this gear." << endl;
481 SinWheel = sin(Propagate->GetEuler(ePsi) + SteerAngle);
482 CosWheel = cos(Propagate->GetEuler(ePsi) + SteerAngle);
485 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
486 // Reset reporting functionality after takeoff
488 void FGLGear::ResetReporting(void)
490 if (Propagate->GetDistanceAGL() > 200.0) {
491 FirstContact = false;
492 StartedGroundRun = false;
493 LandingReported = false;
494 LandingDistanceTraveled = 0.0;
495 MaximumStrutForce = MaximumStrutTravel = 0.0;
499 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
501 void FGLGear::InitializeReporting(void)
503 // If this is the first time the wheel has made contact, remember some values
504 // for later printout.
508 SinkRate = compressSpeed;
509 GroundSpeed = Propagate->GetVel().Magnitude();
510 TakeoffReported = false;
513 // If the takeoff run is starting, initialize.
515 if ((Propagate->GetVel().Magnitude() > 0.1) &&
516 (FCS->GetBrake(bgLeft) == 0) &&
517 (FCS->GetBrake(bgRight) == 0) &&
518 (FCS->GetThrottlePos(0) == 1) && !StartedGroundRun)
520 TakeoffDistanceTraveled = 0;
521 TakeoffDistanceTraveled50ft = 0;
522 StartedGroundRun = true;
526 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
527 // Takeoff and landing reporting functionality
529 void FGLGear::ReportTakeoffOrLanding(void)
531 double deltaT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
533 if (FirstContact) LandingDistanceTraveled += Auxiliary->GetVground()*deltaT;
535 if (StartedGroundRun) {
536 TakeoffDistanceTraveled50ft += Auxiliary->GetVground()*deltaT;
537 if (WOW) TakeoffDistanceTraveled += Auxiliary->GetVground()*deltaT;
540 if (ReportEnable && Auxiliary->GetVground() <= 0.05 && !LandingReported) {
541 if (debug_lvl > 0) Report(erLand);
544 if (ReportEnable && !TakeoffReported &&
545 (vLocalGear(eZ) - Propagate->GetDistanceAGL()) < -50.0)
547 if (debug_lvl > 0) Report(erTakeoff);
550 if (lastWOW != WOW) PutMessage("GEAR_CONTACT: " + name, WOW);
554 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
555 // Crash detection logic (really out-of-bounds detection)
557 void FGLGear::CrashDetect(void)
559 if ( (compressLength > 500.0 ||
560 vForce.Magnitude() > 100000000.0 ||
561 vMoment.Magnitude() > 5000000000.0 ||
562 SinkRate > 1.4666*30 ) && !State->IntegrationSuspended())
564 PutMessage("Crash Detected: Simulation FREEZE.");
565 State->SuspendIntegration();
569 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
570 // The following needs work regarding friction coefficients and braking and
571 // steering The BrakeFCoeff formula assumes that an anti-skid system is used.
572 // It also assumes that we won't be turning and braking at the same time.
573 // Will fix this later.
574 // [JSB] The braking force coefficients include normal rolling coefficient +
575 // a percentage of the static friction coefficient based on braking applied.
577 void FGLGear::ComputeBrakeForceCoefficient(void)
581 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgLeft)) +
582 staticFCoeff*FCS->GetBrake(bgLeft) );
585 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgRight)) +
586 staticFCoeff*FCS->GetBrake(bgRight) );
589 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
590 staticFCoeff*FCS->GetBrake(bgCenter) );
593 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
594 staticFCoeff*FCS->GetBrake(bgCenter) );
597 BrakeFCoeff = ( rollingFCoeff*(1.0 - FCS->GetBrake(bgCenter)) +
598 staticFCoeff*FCS->GetBrake(bgCenter) );
601 BrakeFCoeff = rollingFCoeff;
604 cerr << "Improper brake group membership detected for this gear." << endl;
609 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
610 // Compute the sideforce coefficients using similar assumptions to LaRCSim for now.
611 // Allow a maximum of 10 degrees tire slip angle before wheel slides. At that point,
612 // transition from static to dynamic friction. There are more complicated formulations
613 // of this that avoid the discrete jump (similar to Pacejka). Will fix this later.
615 void FGLGear::ComputeSideForceCoefficient(void)
619 FCoeff = ForceY_Table->GetValue(WheelSlip);
623 if (fabs(WheelSlip) <= 10.0) {
624 FCoeff = staticFCoeff*WheelSlip/10.0;
625 } else if (fabs(WheelSlip) <= 40.0) {
626 FCoeff = (dynamicFCoeff*(fabs(WheelSlip) - 10.0)/10.0
627 + staticFCoeff*(40.0 - fabs(WheelSlip))/10.0)*(WheelSlip>=0?1.0:-1.0);
629 FCoeff = dynamicFCoeff*(WheelSlip>=0?1.0:-1.0);
634 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
635 // Compute the vertical force on the wheel using square-law damping (per comment
636 // in paper AIAA-2000-4303 - see header prologue comments). We might consider
637 // allowing for both square and linear damping force calculation. Also need to
638 // possibly give a "rebound damping factor" that differs from the compression
641 void FGLGear::ComputeVerticalStrutForce(void)
643 double springForce = 0;
644 double dampForce = 0;
646 springForce = -compressLength * kSpring;
648 if (compressSpeed >= 0.0) {
649 dampForce = -compressSpeed * bDamp;
651 dampForce = -compressSpeed * bDampRebound;
653 vLocalForce(eZ) = min(springForce + dampForce, (double)0.0);
655 // Remember these values for reporting
656 MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ)));
657 MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
660 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
662 void FGLGear::bind(void)
664 char property_name[80];
665 snprintf(property_name, 80, "gear/unit[%d]/slip-angle-deg", GearNumber);
666 Exec->GetPropertyManager()->Tie( property_name, &WheelSlip );
669 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
671 void FGLGear::unbind(void)
673 char property_name[80];
674 snprintf(property_name, 80, "gear/unit[%d]/slip-angle-deg", GearNumber);
675 Exec->GetPropertyManager()->Untie( property_name );
678 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
680 void FGLGear::Report(ReportType repType)
684 cout << endl << "Touchdown report for " << name << endl;
685 cout << " Sink rate at contact: " << SinkRate << " fps, "
686 << SinkRate*0.3048 << " mps" << endl;
687 cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, "
688 << GroundSpeed*0.3048 << " mps" << endl;
689 cout << " Maximum contact force: " << MaximumStrutForce << " lbs, "
690 << MaximumStrutForce*4.448 << " Newtons" << endl;
691 cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, "
692 << MaximumStrutTravel*30.48 << " cm" << endl;
693 cout << " Distance traveled: " << LandingDistanceTraveled << " ft, "
694 << LandingDistanceTraveled*0.3048 << " meters" << endl;
695 LandingReported = true;
698 cout << endl << "Takeoff report for " << name << endl;
699 cout << " Distance traveled: " << TakeoffDistanceTraveled
700 << " ft, " << TakeoffDistanceTraveled*0.3048 << " meters" << endl;
701 cout << " Distance traveled (over 50'): " << TakeoffDistanceTraveled50ft
702 << " ft, " << TakeoffDistanceTraveled50ft*0.3048 << " meters" << endl;
703 TakeoffReported = true;
708 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
709 // The bitmasked value choices are as follows:
710 // unset: In this case (the default) JSBSim would only print
711 // out the normally expected messages, essentially echoing
712 // the config files as they are read. If the environment
713 // variable is not set, debug_lvl is set to 1 internally
714 // 0: This requests JSBSim not to output any messages
716 // 1: This value explicity requests the normal JSBSim
718 // 2: This value asks for a message to be printed out when
719 // a class is instantiated
720 // 4: When this value is set, a message is displayed when a
721 // FGModel object executes its Run() method
722 // 8: When this value is set, various runtime state variables
723 // are printed out periodically
724 // 16: When set various parameters are sanity checked and
725 // a message is printed out when they go out of bounds
727 void FGLGear::Debug(int from)
729 if (debug_lvl <= 0) return;
731 if (debug_lvl & 1) { // Standard console startup message output
732 if (from == 0) { // Constructor - loading and initialization
733 cout << " " << sContactType << " " << name << endl;
734 cout << " Location: " << vXYZ << endl;
735 cout << " Spring Constant: " << kSpring << endl;
736 cout << " Damping Constant: " << bDamp << endl;
737 cout << " Dynamic Friction: " << dynamicFCoeff << endl;
738 cout << " Static Friction: " << staticFCoeff << endl;
739 if (sContactType == "BOGEY") {
740 cout << " Rolling Friction: " << rollingFCoeff << endl;
741 cout << " Steering Type: " << sSteerType << endl;
742 cout << " Grouping: " << sBrakeGroup << endl;
743 cout << " Max Steer Angle: " << maxSteerAngle << endl;
744 cout << " Retractable: " << isRetractable << endl;
745 cout << " Relaxation Velocities:" << endl;
746 cout << " Rolling: " << RFRV << endl;
747 cout << " Side: " << SFRV << endl;
751 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
752 if (from == 0) cout << "Instantiated: FGLGear" << endl;
753 if (from == 1) cout << "Destroyed: FGLGear" << endl;
755 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
757 if (debug_lvl & 8 ) { // Runtime state variables
759 if (debug_lvl & 16) { // Sanity checking
761 if (debug_lvl & 64) {
762 if (from == 0) { // Constructor
763 cout << IdSrc << endl;
764 cout << IdHdr << endl;
769 } // namespace JSBSim