1 /*******************************************************************************
6 Purpose: Encapsulates the landing gear elements
9 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
11 This program is free software; you can redistribute it and/or modify it under
12 the terms of the GNU General Public License as published by the Free Software
13 Foundation; either version 2 of the License, or (at your option) any later
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23 Place - Suite 330, Boston, MA 02111-1307, USA.
25 Further information about the GNU General Public License can also be found on
26 the world wide web at http://www.gnu.org.
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
32 --------------------------------------------------------------------------------
35 ********************************************************************************
37 *******************************************************************************/
42 /*******************************************************************************
43 ************************************ CODE **************************************
44 *******************************************************************************/
47 FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
52 *AC_cfg >> tmp >> name >> vXYZ(1) >> vXYZ(2) >> vXYZ(3) >> kSpring >> bDamp
53 >> statFCoeff >> brakeCoeff;
54 State = Exec->GetState();
55 Aircraft = Exec->GetAircraft();
56 Position = Exec->GetPosition();
57 Rotation = Exec->GetRotation();
62 DistanceTraveled = 0.0;
63 MaximumStrutForce = MaximumStrutTravel = 0.0;
67 /******************************************************************************/
69 FGLGear::~FGLGear(void)
73 /******************************************************************************/
75 FGColumnVector FGLGear::Force(void)
77 static FGColumnVector vForce(3);
78 static FGColumnVector vLocalForce(3);
79 static FGColumnVector vLocalGear(3); // Vector: CG to this wheel (Local)
80 static FGColumnVector vWhlBodyVec(3); // Vector: CG to this wheel (Body)
81 static FGColumnVector vWhlVelVec(3); // Velocity of this wheel (Local)
83 vWhlBodyVec = (vXYZ - Aircraft->GetXYZcg()) / 12.0;
84 vWhlBodyVec(eX) = -vWhlBodyVec(eX);
85 vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
87 vLocalGear = State->GetTb2l() * vWhlBodyVec;
89 compressLength = vLocalGear(eZ) - Position->GetDistanceAGL();
91 if (compressLength > 0.00) {
94 vWhlVelVec = State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
95 vWhlVelVec += Position->GetVel();
97 compressSpeed = vWhlVelVec(eZ);
101 SinkRate = compressSpeed;
102 GroundSpeed = Position->GetVel().Magnitude();
105 vWhlVelVec = -1.0 * vWhlVelVec.Normalize();
106 vWhlVelVec(eZ) = 0.00;
108 vLocalForce(eZ) = min(-compressLength * kSpring - compressSpeed * bDamp, (float)0.0);
109 vLocalForce(eX) = fabs(vLocalForce(eZ) * statFCoeff) * vWhlVelVec(eX);
110 vLocalForce(eY) = fabs(vLocalForce(eZ) * statFCoeff) * vWhlVelVec(eY);
112 MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ)));
113 MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
115 vForce = State->GetTl2b() * vLocalForce ;
116 vMoment = vWhlBodyVec * vForce;
122 if (Position->GetDistanceAGL() > 200.0) {
123 FirstContact = false;
125 DistanceTraveled = 0.0;
126 MaximumStrutForce = MaximumStrutTravel = 0.0;
130 vMoment.InitMatrix();
134 DistanceTraveled += Position->GetVel().Magnitude()*State->Getdt()*Aircraft->GetRate();
137 if (Position->GetVel().Magnitude() <= 0.05 && !Reported) {
144 /******************************************************************************/
146 void FGLGear::Report(void)
148 cout << endl << "Touchdown report for " << name << endl;
149 cout << " Sink rate at contact: " << SinkRate << " fps, "
150 << SinkRate*0.3408 << " mps" << endl;
151 cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, "
152 << GroundSpeed*0.3408 << " mps" << endl;
153 cout << " Maximum contact force: " << MaximumStrutForce << " lbs, "
154 << MaximumStrutForce*4.448 << " Newtons" << endl;
155 cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, "
156 << MaximumStrutTravel*30.48 << " cm" << endl;
157 cout << " Distance traveled: " << DistanceTraveled << " ft, "
158 << DistanceTraveled*0.3408 << " meters" << endl;