1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 You should have received a copy of the GNU General Public License along with
20 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 Place - Suite 330, Boston, MA 02111-1307, USA.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
27 --------------------------------------------------------------------------------
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 # include <simgear/compiler.h>
45 #include "FGJSBBase.h"
46 #include "FGFDMExec.h"
47 #include "FGConfigFile.h"
48 #include "FGColumnVector3.h"
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55 #define ID_LGEAR "$Id$"
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
70 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
74 /** Landing gear model.
75 Calculates forces and moments due to landing gear reactions. This is done in
76 several steps, and is dependent on what kind of gear is being modeled. Here
77 are the parameters that can be specified in the config file for modeling
80 <b><u>Physical Characteristics</u></b><br>
82 <li>X, Y, Z location, in inches in structural coordinate frame</li>
83 <li>Spring constant, in lbs/ft</li>
84 <li>Damping coefficient, in lbs/ft/sec</li>
85 <li>Dynamic Friction Coefficient</li>
86 <li>Static Friction Coefficient</li>
88 <b><u>Operational Properties</b></u><br>
91 <li>Steerability attribute {one of STEERABLE | FIXED | CASTERED}</li>
92 <li>Brake Group Membership {one of LEFT | CENTER | RIGHT | NOSE | TAIL | NONE}</li>
93 <li>Max Steer Angle, in degrees</li>
96 <b><u>Algorithm and Approach to Modeling</u></b><br>
98 <li>Find the location of the uncompressed landing gear relative to the CG of
99 the aircraft. Remember, the structural coordinate frame that the aircraft is
100 defined in is: X positive towards the tail, Y positive out the right side, Z
101 positive upwards. The locations of the various parts are given in inches in
102 the config file.</li>
103 <li>The vector giving the location of the gear (relative to the cg) is
104 rotated 180 degrees about the Y axis to put the coordinates in body frame (X
105 positive forwards, Y positive out the right side, Z positive downwards, with
106 the origin at the cg). The lengths are also now given in feet.</li>
107 <li>The new gear location is now transformed to the local coordinate frame
108 using the body-to-local matrix. (Mb2l).</li>
109 <li>Knowing the location of the center of gravity relative to the ground
110 (height above ground level or AGL) now enables gear deflection to be
111 calculated. The gear compression value is the local frame gear Z location
112 value minus the height AGL. [Currently, we make the assumption that the gear
113 is oriented - and the deflection occurs in - the Z axis only. Additionally,
114 the vector to the landing gear is currently not modified - which would
115 (correctly) move the point of contact to the actual compressed-gear point of
116 contact. Eventually, articulated gear may be modeled, but initially an
117 effort must be made to model a generic system.] As an example, say the
118 aircraft left main gear location (in local coordinates) is Z = 3 feet
119 (positive) and the height AGL is 2 feet. This tells us that the gear is
120 compressed 1 foot.</li>
121 <li>If the gear is compressed, a Weight-On-Wheels (WOW) flag is set.</li>
122 <li>With the compression length calculated, the compression velocity may now
123 be calculated. This will be used to determine the damping force in the
124 strut. The aircraft rotational rate is multiplied by the vector to the wheel
125 to get a wheel velocity in body frame. That velocity vector is then
126 transformed into the local coordinate frame.</li>
127 <li>The aircraft cg velocity in the local frame is added to the
128 just-calculated wheel velocity (due to rotation) to get a total wheel
129 velocity in the local frame.</li>
130 <li>The compression speed is the Z-component of the vector.</li>
131 <li>With the wheel velocity vector no longer needed, it is normalized and
132 multiplied by a -1 to reverse it. This will be used in the friction force
134 <li>Since the friction force takes place solely in the runway plane, the Z
135 coordinate of the normalized wheel velocity vector is set to zero.</li>
136 <li>The gear deflection force (the force on the aircraft acting along the
137 local frame Z axis) is now calculated given the spring and damper
138 coefficients, and the gear deflection speed and stroke length. Keep in mind
139 that gear forces always act in the negative direction (in both local and
140 body frames), and are not capable of generating a force in the positive
141 sense (one that would attract the aircraft to the ground). So, the gear
142 forces are always negative - they are limited to values of zero or less. The
143 gear force is simply the negative of the sum of the spring compression
144 length times the spring coefficient and the gear velocity times the damping
146 <li>The lateral/directional force acting on the aircraft through the landing
148 gear (along the local frame X and Y axes) is calculated next. First, the
149 friction coefficient is multiplied by the recently calculated Z-force. This
150 is the friction force. It must be given direction in addition to magnitude.
151 We want the components in the local frame X and Y axes. From step 9, above,
152 the conditioned wheel velocity vector is taken and the X and Y parts are
153 multiplied by the friction force to get the X and Y components of friction.
155 <li>The wheel force in local frame is next converted to body frame.</li>
156 <li>The moment due to the gear force is calculated by multiplying r x F
157 (radius to wheel crossed into the wheel force). Both of these operands are
160 @author Jon S. Berndt
162 @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
163 NASA-Ames", NASA CR-2497, January 1975
164 @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
165 Wiley & Sons, 1979 ISBN 0-471-03032-5
166 @see W. A. Ragsdale, "A Generic Landing Gear Dynamics Model for LASRS++",
170 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
174 class FGLGear : public FGJSBBase
177 /// Brake grouping enumerators
178 enum BrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail };
179 /// Steering group membership enumerators
180 enum SteerType {stSteer, stFixed, stCaster};
181 /// Report type enumerators
182 enum ReportType {erNone=0, erTakeoff, erLand};
184 @param Executive a pointer to the parent executive object
185 @param File a pointer to the config file instance */
186 FGLGear(FGConfigFile* File, FGFDMExec* Executive, int number);
188 @param lgear a reference to an existing FGLGear object */
189 FGLGear(const FGLGear& lgear);
194 /// The Force vector for this gear
195 FGColumnVector3& Force(void);
196 /// The Moment vector for this gear
197 FGColumnVector3& Moment(void) {return vMoment;}
199 /// Gets the location of the gear in Body axes
200 FGColumnVector3& GetBodyLocation(void) { return vWhlBodyVec; }
201 double GetBodyLocation(int idx) { return vWhlBodyVec(idx); }
203 FGColumnVector3& GetLocalGear(void) { return vLocalGear; }
204 double GetLocalGear(int idx) { return vLocalGear(idx); }
206 /// Gets the name of the gear
207 inline string GetName(void) {return name; }
208 /// Gets the Weight On Wheels flag value
209 inline bool GetWOW(void) {return WOW; }
210 /// Gets the current compressed length of the gear in feet
211 inline double GetCompLen(void) {return compressLength;}
212 /// Gets the current gear compression velocity in ft/sec
213 inline double GetCompVel(void) {return compressSpeed; }
214 /// Gets the gear compression force in pounds
215 inline double GetCompForce(void) {return Force()(3); }
216 inline double GetBrakeFCoeff(void) {return BrakeFCoeff;}
217 inline double GetXYZ(int i) {return vXYZ(i);}
219 /// Gets the current normalized tire pressure
220 inline double GetTirePressure(void) { return TirePressureNorm; }
221 /// Sets the new normalized tire pressure
222 inline void SetTirePressure(double p) { TirePressureNorm = p; }
224 /// Sets the brake value in percent (0 - 100)
225 inline void SetBrake(double bp) {brakePct = bp;}
227 /** Set the console touchdown reporting feature
228 @param flag true turns on touchdown reporting, false turns it off */
229 inline void SetReport(bool flag) { ReportEnable = flag; }
230 /** Get the console touchdown reporting feature
231 @return true if reporting is turned on */
232 inline bool GetReport(void) { return ReportEnable; }
233 double GetSteerNorm(void) const { return radtodeg/maxSteerAngle*SteerAngle; }
234 double GetDefaultSteerAngle(double cmd) const { return cmd*maxSteerAngle; }
235 double GetstaticFCoeff(void) { return staticFCoeff; }
236 double GetdynamicFCoeff(void) { return dynamicFCoeff; }
237 double GetrollingFCoeff(void) { return rollingFCoeff; }
239 inline int GetBrakeGroup(void) { return (int)eBrakeGrp; }
240 inline int GetSteerType(void) { return (int)eSteerType; }
242 bool GetSteerable(void) const { return eSteerType != stFixed; }
243 inline bool GetRetractable(void) const { return isRetractable; }
244 inline bool GetGearUnitUp(void) const { return GearUp; }
245 inline bool GetGearUnitDown(void) const { return GearDown; }
246 inline double GetWheelSideForce(void) const { return SideForce; }
247 inline double GetWheelRollForce(void) const { return RollingForce; }
248 inline double GetBodyXForce(void) const { return vLocalForce(eX); }
249 inline double GetBodyYForce(void) const { return vLocalForce(eY); }
250 inline double GetWheelSlipAngle(void) const { return WheelSlip; }
251 double GetWheelVel(int axis) const { return vWhlVelVec(axis);}
252 double GetkSpring(void) const { return kSpring; }
253 double GetbDamp(void) const { return bDamp; }
254 double GetmaxSteerAngle(void) const { return maxSteerAngle; }
255 string GetsBrakeGroup(void) const { return sBrakeGroup; }
256 string GetsRetractable(void) const { return sRetractable; }
257 string GetsSteerType(void) const { return sSteerType; }
261 FGColumnVector3 vXYZ;
262 FGColumnVector3 vMoment;
263 FGColumnVector3 vWhlBodyVec;
264 FGColumnVector3 vLocalGear;
265 FGColumnVector3 vForce;
266 FGColumnVector3 vLocalForce;
267 FGColumnVector3 vWhlVelVec; // Velocity of this wheel (Local)
271 double compressLength;
272 double compressSpeed;
273 double staticFCoeff, dynamicFCoeff, rollingFCoeff;
279 double TakeoffDistanceTraveled;
280 double TakeoffDistanceTraveled50ft;
281 double LandingDistanceTraveled;
282 double MaximumStrutForce;
283 double MaximumStrutTravel;
284 double SideWhlVel, RollingWhlVel;
285 double RollingForce, SideForce, FCoeff;
287 double lastWheelSlip;
288 double TirePressureNorm;
292 bool StartedGroundRun;
293 bool LandingReported;
294 bool TakeoffReported;
297 bool GearUp, GearDown;
304 BrakeGroup eBrakeGrp;
305 SteerType eSteerType;
306 double maxSteerAngle;
310 FGAircraft* Aircraft;
311 FGPropagate* Propagate;
312 FGAuxiliary* Auxiliary;
314 FGMassBalance* MassBalance;
316 void Report(ReportType rt);
317 void Debug(int from);
320 #include "FGAircraft.h"
321 #include "FGPropagate.h"
322 #include "FGAuxiliary.h"
324 #include "FGMassBalance.h"
327 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%