1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser 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 Lesser General Public License for more
19 You should have received a copy of the GNU Lesser 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 Lesser General Public License can also be found on
24 the world wide web at http://www.gnu.org.
27 --------------------------------------------------------------------------------
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41 #include "models/propulsion/FGForce.h"
42 #include "math/FGColumnVector3.h"
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49 #define ID_LGEAR "$Id: FGLGear.h,v 1.38 2010/03/23 22:44:36 andgi Exp $"
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
70 /** Landing gear model.
71 Calculates forces and moments due to landing gear reactions. This is done in
72 several steps, and is dependent on what kind of gear is being modeled. Here
73 are the parameters that can be specified in the config file for modeling
76 <h3>Physical Characteristics</h3>
78 <li>X, Y, Z location, in inches in structural coordinate frame</li>
79 <li>Spring constant, in lbs/ft</li>
80 <li>Damping coefficient, in lbs/ft/sec</li>
81 <li>Dynamic Friction Coefficient</li>
82 <li>Static Friction Coefficient</li>
84 <h3>Operational Properties</h3>
87 <li>Brake Group Membership {one of LEFT | CENTER | RIGHT | NOSE | TAIL | NONE}</li>
88 <li>Max Steer Angle, in degrees</li>
91 <h3>Algorithm and Approach to Modeling</h3>
93 <li>Find the location of the uncompressed landing gear relative to the CG of
94 the aircraft. Remember, the structural coordinate frame that the aircraft is
95 defined in is: X positive towards the tail, Y positive out the right side, Z
96 positive upwards. The locations of the various parts are given in inches in
98 <li>The vector giving the location of the gear (relative to the cg) is
99 rotated 180 degrees about the Y axis to put the coordinates in body frame (X
100 positive forwards, Y positive out the right side, Z positive downwards, with
101 the origin at the cg). The lengths are also now given in feet.</li>
102 <li>The new gear location is now transformed to the local coordinate frame
103 using the body-to-local matrix. (Mb2l).</li>
104 <li>Knowing the location of the center of gravity relative to the ground
105 (height above ground level or AGL) now enables gear deflection to be
106 calculated. The gear compression value is the local frame gear Z location
107 value minus the height AGL. [Currently, we make the assumption that the gear
108 is oriented - and the deflection occurs in - the Z axis only. Additionally,
109 the vector to the landing gear is currently not modified - which would
110 (correctly) move the point of contact to the actual compressed-gear point of
111 contact. Eventually, articulated gear may be modeled, but initially an
112 effort must be made to model a generic system.] As an example, say the
113 aircraft left main gear location (in local coordinates) is Z = 3 feet
114 (positive) and the height AGL is 2 feet. This tells us that the gear is
115 compressed 1 foot.</li>
116 <li>If the gear is compressed, a Weight-On-Wheels (WOW) flag is set.</li>
117 <li>With the compression length calculated, the compression velocity may now
118 be calculated. This will be used to determine the damping force in the
119 strut. The aircraft rotational rate is multiplied by the vector to the wheel
120 to get a wheel velocity in body frame. That velocity vector is then
121 transformed into the local coordinate frame.</li>
122 <li>The aircraft cg velocity in the local frame is added to the
123 just-calculated wheel velocity (due to rotation) to get a total wheel
124 velocity in the local frame.</li>
125 <li>The compression speed is the Z-component of the vector.</li>
126 <li>With the wheel velocity vector no longer needed, it is normalized and
127 multiplied by a -1 to reverse it. This will be used in the friction force
129 <li>Since the friction force takes place solely in the runway plane, the Z
130 coordinate of the normalized wheel velocity vector is set to zero.</li>
131 <li>The gear deflection force (the force on the aircraft acting along the
132 local frame Z axis) is now calculated given the spring and damper
133 coefficients, and the gear deflection speed and stroke length. Keep in mind
134 that gear forces always act in the negative direction (in both local and
135 body frames), and are not capable of generating a force in the positive
136 sense (one that would attract the aircraft to the ground). So, the gear
137 forces are always negative - they are limited to values of zero or less. The
138 gear force is simply the negative of the sum of the spring compression
139 length times the spring coefficient and the gear velocity times the damping
141 <li>The lateral/directional force acting on the aircraft through the landing
143 gear (along the local frame X and Y axes) is calculated next. First, the
144 friction coefficient is multiplied by the recently calculated Z-force. This
145 is the friction force. It must be given direction in addition to magnitude.
146 We want the components in the local frame X and Y axes. From step 9, above,
147 the conditioned wheel velocity vector is taken and the X and Y parts are
148 multiplied by the friction force to get the X and Y components of friction.
150 <li>The wheel force in local frame is next converted to body frame.</li>
151 <li>The moment due to the gear force is calculated by multiplying r x F
152 (radius to wheel crossed into the wheel force). Both of these operands are
156 <h3>Configuration File Format:</h3>
158 <contact type="{BOGEY | STRUCTURE}" name="{string}">
159 <location unit="{IN | M}">
164 <orientation unit="{RAD | DEG}">
165 <pitch> {number} </pitch>
166 <roll> {number} </roll>
167 <yaw> {number} </yaw>
169 <static_friction> {number} </static_friction>
170 <dynamic_friction> {number} </dynamic_friction>
171 <rolling_friction> {number} </rolling_friction>
172 <spring_coeff unit="{LBS/FT | N/M}"> {number} </spring_coeff>
173 <damping_coeff [type="SQUARE"] unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff>
174 <damping_coeff_rebound [type="SQUARE"] unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff_rebound>
175 <max_steer unit="DEG"> {number | 0 | 360} </max_steer>
176 <brake_group> {NONE | LEFT | RIGHT | CENTER | NOSE | TAIL} </brake_group>
177 <retractable>{0 | 1}</retractable>
178 <table type="{CORNERING_COEFF}">
180 <relaxation_velocity>
181 <rolling unit="{FT/SEC | KTS | M/S}"> {number} </rolling>
182 <side unit="{FT/SEC | KTS | M/S}"> {number} </side>
183 </relaxation_velocity>
185 <rolling> {number} </rolling>
186 <side> {number} </side>
188 <wheel_slip_filter> {number} </wheel_slip_filter>
191 @author Jon S. Berndt
192 @version $Id: FGLGear.h,v 1.38 2010/03/23 22:44:36 andgi Exp $
193 @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
194 NASA-Ames", NASA CR-2497, January 1975
195 @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
196 Wiley & Sons, 1979 ISBN 0-471-03032-5
197 @see W. A. Ragsdale, "A Generic Landing Gear Dynamics Model for LASRS++",
201 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
205 class FGLGear : public FGForce
208 /// Brake grouping enumerators
209 enum BrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail };
210 /// Steering group membership enumerators
211 enum SteerType {stSteer, stFixed, stCaster};
212 /// Contact point type
213 enum ContactType {ctBOGEY, ctSTRUCTURE};
214 /// Report type enumerators
215 enum ReportType {erNone=0, erTakeoff, erLand};
217 enum DampType {dtLinear=0, dtSquare};
219 @param el a pointer to the XML element that contains the CONTACT info.
220 @param Executive a pointer to the parent executive object
221 @param number integer identifier for this instance of FGLGear
223 FGLGear(Element* el, FGFDMExec* Executive, int number);
227 /// The Force vector for this gear
228 FGColumnVector3& GetBodyForces(void);
230 /// Gets the location of the gear in Body axes
231 FGColumnVector3& GetBodyLocation(void) { return vWhlBodyVec; }
232 double GetBodyLocation(int idx) const { return vWhlBodyVec(idx); }
234 FGColumnVector3& GetLocalGear(void) { return vLocalGear; }
235 double GetLocalGear(int idx) const { return vLocalGear(idx); }
237 /// Gets the name of the gear
238 string GetName(void) const {return name; }
239 /// Gets the Weight On Wheels flag value
240 bool GetWOW(void) const {return WOW; }
241 /// Gets the current compressed length of the gear in feet
242 double GetCompLen(void) const {return compressLength;}
243 /// Gets the current gear compression velocity in ft/sec
244 double GetCompVel(void) const {return compressSpeed; }
245 /// Gets the gear compression force in pounds
246 double GetCompForce(void) const {return StrutForce; }
247 double GetBrakeFCoeff(void) const {return BrakeFCoeff;}
249 /// Gets the current normalized tire pressure
250 double GetTirePressure(void) const { return TirePressureNorm; }
251 /// Sets the new normalized tire pressure
252 void SetTirePressure(double p) { TirePressureNorm = p; }
254 /// Sets the brake value in percent (0 - 100)
255 void SetBrake(double bp) {brakePct = bp;}
257 /// Sets the weight-on-wheels flag.
258 void SetWOW(bool wow) {WOW = wow;}
260 /** Set the console touchdown reporting feature
261 @param flag true turns on touchdown reporting, false turns it off */
262 void SetReport(bool flag) { ReportEnable = flag; }
263 /** Get the console touchdown reporting feature
264 @return true if reporting is turned on */
265 bool GetReport(void) const { return ReportEnable; }
266 double GetSteerNorm(void) const { return radtodeg/maxSteerAngle*SteerAngle; }
267 double GetDefaultSteerAngle(double cmd) const { return cmd*maxSteerAngle; }
268 double GetstaticFCoeff(void) const { return staticFCoeff; }
270 int GetBrakeGroup(void) const { return (int)eBrakeGrp; }
271 int GetSteerType(void) const { return (int)eSteerType; }
273 bool GetSteerable(void) const { return eSteerType != stFixed; }
274 bool GetRetractable(void) const { return isRetractable; }
275 bool GetGearUnitUp(void) const { return GearUp; }
276 bool GetGearUnitDown(void) const { return GearDown; }
277 double GetWheelRollForce(void) {
278 FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces();
279 return vForce(eX)*cos(SteerAngle) + vForce(eY)*sin(SteerAngle); }
280 double GetWheelSideForce(void) {
281 FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces();
282 return vForce(eY)*cos(SteerAngle) - vForce(eX)*sin(SteerAngle); }
283 double GetWheelRollVel(void) const { return vWhlVelVec(eX)*cos(SteerAngle)
284 + vWhlVelVec(eY)*sin(SteerAngle); }
285 double GetWheelSideVel(void) const { return vWhlVelVec(eY)*cos(SteerAngle)
286 - vWhlVelVec(eX)*sin(SteerAngle); }
287 double GetWheelSlipAngle(void) const { return WheelSlip; }
288 double GetWheelVel(int axis) const { return vWhlVelVec(axis);}
289 bool IsBogey(void) const { return (eContactType == ctBOGEY);}
290 double GetGearUnitPos(void);
291 double GetSteerAngleDeg(void) const { return radtodeg*SteerAngle; }
297 static const FGMatrix33 Tb2s;
299 FGColumnVector3 vGearOrient;
300 FGColumnVector3 vWhlBodyVec;
301 FGColumnVector3 vLocalGear;
302 FGColumnVector3 vWhlVelVec, vLocalWhlVel; // Velocity of this wheel
303 FGColumnVector3 normal, cvel, vGroundNormal;
304 FGLocation contact, gearLoc;
305 FGTable *ForceY_Table;
311 double compressLength;
312 double compressSpeed;
313 double staticFCoeff, dynamicFCoeff, rollingFCoeff;
314 double Stiffness, Shape, Peak, Curvature; // Pacejka factors
320 double TakeoffDistanceTraveled;
321 double TakeoffDistanceTraveled50ft;
322 double LandingDistanceTraveled;
323 double MaximumStrutForce, StrutForce;
324 double MaximumStrutTravel;
327 double TirePressureNorm;
333 bool StartedGroundRun;
334 bool LandingReported;
335 bool TakeoffReported;
338 bool GearUp, GearDown;
342 std::string sSteerType;
343 std::string sBrakeGroup;
344 std::string sRetractable;
345 std::string sContactType;
347 BrakeGroup eBrakeGrp;
348 ContactType eContactType;
349 SteerType eSteerType;
351 DampType eDampTypeRebound;
352 double maxSteerAngle;
353 double RFRV; // Rolling force relaxation velocity
354 double SFRV; // Side force relaxation velocity
355 double LongForceLagFilterCoeff; // Longitudinal Force Lag Filter Coefficient
356 double LatForceLagFilterCoeff; // Lateral Force Lag Filter Coefficient
357 double WheelSlipLagFilterCoeff; // Wheel slip angle lag filter coefficient
359 Filter LongForceFilter;
360 Filter LatForceFilter;
361 Filter WheelSlipFilter;
364 FGAircraft* Aircraft;
365 FGPropagate* Propagate;
366 FGAuxiliary* Auxiliary;
368 FGMassBalance* MassBalance;
370 void ComputeRetractionState(void);
371 void ComputeBrakeForceCoefficient(void);
372 void ComputeSteeringAngle(void);
373 void ComputeSlipAngle(void);
374 void ComputeSideForceCoefficient(void);
375 void ComputeVerticalStrutForce(void);
376 void ComputeGroundCoordSys(void);
377 void CrashDetect(void);
378 void InitializeReporting(void);
379 void ResetReporting(void);
380 void ReportTakeoffOrLanding(void);
381 void Report(ReportType rt);
382 void Debug(int from);
386 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%