]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGLGear.cpp
05/30/2000 updates from Jon Berdnt. Landing gear code now is beginning to
[flightgear.git] / src / FDM / JSBSim / FGLGear.cpp
1 /*******************************************************************************
2
3  Module:       FGLGear.cpp
4  Author:       Jon S. Berndt
5  Date started: 11/18/99
6  Purpose:      Encapsulates the landing gear elements
7  Called by:    FGAircraft
8
9  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
10
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
14  version.
15
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
19  details.
20
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.
24
25  Further information about the GNU General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30
31 HISTORY
32 --------------------------------------------------------------------------------
33 11/18/99   JSB   Created
34
35 ********************************************************************************
36 INCLUDES
37 *******************************************************************************/
38
39 #include "FGLGear.h"
40 #include <algorithm>
41
42 /*******************************************************************************
43 ************************************ CODE **************************************
44 *******************************************************************************/
45
46
47 FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
48                                                            vMoment(3),
49                                                            Exec(fdmex)
50 {
51   string tmp;
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();
58
59   WOW = false;
60 }
61
62
63 /******************************************************************************/
64
65 FGLGear::~FGLGear(void)
66 {
67 }
68
69 /******************************************************************************/
70
71 FGColumnVector FGLGear::Force(void)
72 {
73   static FGColumnVector vForce(3);
74   static FGColumnVector vLocalForce(3);
75   static FGColumnVector vLocalGear(3);     // Vector: CG to this wheel (Local)
76   static FGColumnVector vWhlBodyVec(3);    // Vector: CG to this wheel (Body)
77   static FGColumnVector vWhlVelVec(3);     // Velocity of this wheel (Local)
78
79   vWhlBodyVec     = (vXYZ - Aircraft->GetXYZcg()) / 12.0;
80   vWhlBodyVec(eX) = -vWhlBodyVec(eX);
81   vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
82
83   vLocalGear = State->GetTb2l() * vWhlBodyVec;
84
85   compressLength = vLocalGear(eZ) - Position->GetDistanceAGL();
86
87   if (compressLength > 0.00) {
88
89     WOW = true;
90
91     vWhlVelVec      =  State->GetTb2l() * (Rotation->GetPQR() * vWhlBodyVec);
92     vWhlVelVec     +=  Position->GetVel();
93     compressSpeed   =  vWhlVelVec(eZ);
94
95     vWhlVelVec      = -1.0 * vWhlVelVec.Normalize();
96     vWhlVelVec(eZ)  =  0.00;
97
98     vLocalForce(eZ) =  min(-compressLength * kSpring - compressSpeed * bDamp, (float)0.0);
99     vLocalForce(eX) =  fabs(vLocalForce(eZ) * statFCoeff) * vWhlVelVec(eX);
100     vLocalForce(eY) =  fabs(vLocalForce(eZ) * statFCoeff) * vWhlVelVec(eY);
101
102     vForce  = State->GetTl2b() * vLocalForce ;
103     vMoment = vWhlBodyVec * vForce;
104
105   } else {
106
107     WOW = false;
108     vForce.InitMatrix();
109     vMoment.InitMatrix();
110   }
111
112
113   return vForce;
114 }
115
116 /******************************************************************************/
117