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),
53 *AC_cfg >> tmp >> name >> vXYZ(1) >> vXYZ(2) >> vXYZ(3)
54 >> kSpring >> bDamp>> dynamicFCoeff >> staticFCoeff
55 >> SteerType >> BrakeType >> GroupMember >> maxSteerAngle;
57 cout << " Name: " << name << endl;
58 cout << " Location: " << vXYZ << endl;
59 cout << " Spring Constant: " << kSpring << endl;
60 cout << " Damping Constant: " << bDamp << endl;
61 cout << " Dynamic Friction: " << dynamicFCoeff << endl;
62 cout << " Static Friction: " << staticFCoeff << endl;
63 cout << " Brake Type: " << BrakeType << endl;
64 cout << " Grouping: " << GroupMember << endl;
65 cout << " Steering Type: " << SteerType << endl;
66 cout << " Max Steer Angle: " << maxSteerAngle << endl;
68 State = Exec->GetState();
69 Aircraft = Exec->GetAircraft();
70 Position = Exec->GetPosition();
71 Rotation = Exec->GetRotation();
77 DistanceTraveled = 0.0;
78 MaximumStrutForce = MaximumStrutTravel = 0.0;
82 /******************************************************************************/
84 FGLGear::~FGLGear(void)
86 cout << "Destructing Landing Gear ..." << endl;
89 /******************************************************************************/
91 FGColumnVector FGLGear::Force(void)
93 FGColumnVector vForce(3);
94 FGColumnVector vLocalForce(3);
95 FGColumnVector vLocalGear(3); // Vector: CG to this wheel (Local)
96 FGColumnVector vWhlVelVec(3); // Velocity of this wheel (Local)
98 vWhlBodyVec = (vXYZ - Aircraft->GetXYZcg()) / 12.0;
99 vWhlBodyVec(eX) = -vWhlBodyVec(eX);
100 vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
102 vLocalGear = State->GetTb2l() * vWhlBodyVec;
104 compressLength = vLocalGear(eZ) - Position->GetDistanceAGL();
106 if (compressLength > 0.00) {
109 vWhlVelVec = State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
110 vWhlVelVec += Position->GetVel();
112 compressSpeed = vWhlVelVec(eZ);
116 SinkRate = compressSpeed;
117 GroundSpeed = Position->GetVel().Magnitude();
120 // The following code normalizes the wheel velocity vector, reverses it, and zeroes out
121 // the z component of the velocity. The question is, should the Z axis velocity be zeroed
122 // out first before the normalization takes place or not? Subsequent to that, the Wheel
123 // Velocity vector now points as a unit vector backwards and parallel to the wheel
124 // velocity vector. It acts AT the wheel.
126 vWhlVelVec = -1.0 * vWhlVelVec.Normalize();
127 vWhlVelVec(eZ) = 0.00;
129 // the following needs work regarding friction coefficients and braking and steering
131 vLocalForce(eZ) = min(-compressLength * kSpring - compressSpeed * bDamp, (float)0.0);
132 vLocalForce(eX) = fabs(vLocalForce(eZ) * staticFCoeff) * vWhlVelVec(eX);
133 vLocalForce(eY) = fabs(vLocalForce(eZ) * staticFCoeff) * vWhlVelVec(eY);
135 MaximumStrutForce = max(MaximumStrutForce, fabs(vLocalForce(eZ)));
136 MaximumStrutTravel = max(MaximumStrutTravel, fabs(compressLength));
138 vForce = State->GetTl2b() * vLocalForce ;
139 vMoment = vWhlBodyVec * vForce;
140 cout << " Force: " << vForce << endl;
141 cout << " Moment: " << vMoment << endl;
147 if (Position->GetDistanceAGL() > 200.0) {
148 FirstContact = false;
150 DistanceTraveled = 0.0;
151 MaximumStrutForce = MaximumStrutTravel = 0.0;
155 vMoment.InitMatrix();
159 DistanceTraveled += Position->GetVel().Magnitude()*State->Getdt()*Aircraft->GetRate();
162 if (ReportEnable && Position->GetVel().Magnitude() <= 0.05 && !Reported) {
168 /******************************************************************************/
170 void FGLGear::Report(void)
172 cout << endl << "Touchdown report for " << name << endl;
173 cout << " Sink rate at contact: " << SinkRate << " fps, "
174 << SinkRate*0.3408 << " mps" << endl;
175 cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, "
176 << GroundSpeed*0.3408 << " mps" << endl;
177 cout << " Maximum contact force: " << MaximumStrutForce << " lbs, "
178 << MaximumStrutForce*4.448 << " Newtons" << endl;
179 cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, "
180 << MaximumStrutTravel*30.48 << " cm" << endl;
181 cout << " Distance traveled: " << DistanceTraveled << " ft, "
182 << DistanceTraveled*0.3408 << " meters" << endl;