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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43 #include "models/propulsion/FGForce.h"
44 #include "math/FGColumnVector3.h"
45 #include "math/FGMatrix33.h"
46 #include "math/LagrangeMultiplier.h"
48 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52 #define ID_LGEAR "$Id: FGLGear.h,v 1.47 2011/08/30 21:05:56 bcoconni Exp $"
54 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62 class FGPropertyManager;
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68 /** Landing gear model.
69 Calculates forces and moments due to landing gear reactions. This is done in
70 several steps, and is dependent on what kind of gear is being modeled. Here
71 are the parameters that can be specified in the config file for modeling
74 <h3>Physical Characteristics</h3>
76 <li>X, Y, Z location, in inches in structural coordinate frame</li>
77 <li>Spring constant, in lbs/ft</li>
78 <li>Damping coefficient, in lbs/ft/sec</li>
79 <li>Dynamic Friction Coefficient</li>
80 <li>Static Friction Coefficient</li>
82 <h3>Operational Properties</h3>
85 <li>Brake Group Membership {one of LEFT | CENTER | RIGHT | NOSE | TAIL | NONE}</li>
86 <li>Max Steer Angle, in degrees</li>
89 <h3>Algorithm and Approach to Modeling</h3>
91 <li>Find the location of the uncompressed landing gear relative to the CG of
92 the aircraft. Remember, the structural coordinate frame that the aircraft is
93 defined in is: X positive towards the tail, Y positive out the right side, Z
94 positive upwards. The locations of the various parts are given in inches in
96 <li>The vector giving the location of the gear (relative to the cg) is
97 rotated 180 degrees about the Y axis to put the coordinates in body frame (X
98 positive forwards, Y positive out the right side, Z positive downwards, with
99 the origin at the cg). The lengths are also now given in feet.</li>
100 <li>The new gear location is now transformed to the local coordinate frame
101 using the body-to-local matrix. (Mb2l).</li>
102 <li>Knowing the location of the center of gravity relative to the ground
103 (height above ground level or AGL) now enables gear deflection to be
104 calculated. The gear compression value is the local frame gear Z location
105 value minus the height AGL. [Currently, we make the assumption that the gear
106 is oriented - and the deflection occurs in - the Z axis only. Additionally,
107 the vector to the landing gear is currently not modified - which would
108 (correctly) move the point of contact to the actual compressed-gear point of
109 contact. Eventually, articulated gear may be modeled, but initially an
110 effort must be made to model a generic system.] As an example, say the
111 aircraft left main gear location (in local coordinates) is Z = 3 feet
112 (positive) and the height AGL is 2 feet. This tells us that the gear is
113 compressed 1 foot.</li>
114 <li>If the gear is compressed, a Weight-On-Wheels (WOW) flag is set.</li>
115 <li>With the compression length calculated, the compression velocity may now
116 be calculated. This will be used to determine the damping force in the
117 strut. The aircraft rotational rate is multiplied by the vector to the wheel
118 to get a wheel velocity in body frame. That velocity vector is then
119 transformed into the local coordinate frame.</li>
120 <li>The aircraft cg velocity in the local frame is added to the
121 just-calculated wheel velocity (due to rotation) to get a total wheel
122 velocity in the local frame.</li>
123 <li>The compression speed is the Z-component of the vector.</li>
124 <li>With the wheel velocity vector no longer needed, it is normalized and
125 multiplied by a -1 to reverse it. This will be used in the friction force
127 <li>Since the friction force takes place solely in the runway plane, the Z
128 coordinate of the normalized wheel velocity vector is set to zero.</li>
129 <li>The gear deflection force (the force on the aircraft acting along the
130 local frame Z axis) is now calculated given the spring and damper
131 coefficients, and the gear deflection speed and stroke length. Keep in mind
132 that gear forces always act in the negative direction (in both local and
133 body frames), and are not capable of generating a force in the positive
134 sense (one that would attract the aircraft to the ground). So, the gear
135 forces are always negative - they are limited to values of zero or less. The
136 gear force is simply the negative of the sum of the spring compression
137 length times the spring coefficient and the gear velocity times the damping
139 <li>The lateral/directional force acting on the aircraft through the landing
141 gear (along the local frame X and Y axes) is calculated next. First, the
142 friction coefficient is multiplied by the recently calculated Z-force. This
143 is the friction force. It must be given direction in addition to magnitude.
144 We want the components in the local frame X and Y axes. From step 9, above,
145 the conditioned wheel velocity vector is taken and the X and Y parts are
146 multiplied by the friction force to get the X and Y components of friction.
148 <li>The wheel force in local frame is next converted to body frame.</li>
149 <li>The moment due to the gear force is calculated by multiplying r x F
150 (radius to wheel crossed into the wheel force). Both of these operands are
154 <h3>Configuration File Format:</h3>
156 <contact type="{BOGEY | STRUCTURE}" name="{string}">
157 <location unit="{IN | M}">
162 <orientation unit="{RAD | DEG}">
163 <pitch> {number} </pitch>
164 <roll> {number} </roll>
165 <yaw> {number} </yaw>
167 <static_friction> {number} </static_friction>
168 <dynamic_friction> {number} </dynamic_friction>
169 <rolling_friction> {number} </rolling_friction>
170 <spring_coeff unit="{LBS/FT | N/M}"> {number} </spring_coeff>
171 <damping_coeff [type="SQUARE"] unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff>
172 <damping_coeff_rebound [type="SQUARE"] unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff_rebound>
173 <max_steer unit="DEG"> {number | 0 | 360} </max_steer>
174 <brake_group> {NONE | LEFT | RIGHT | CENTER | NOSE | TAIL} </brake_group>
175 <retractable>{0 | 1}</retractable>
176 <table type="{CORNERING_COEFF}">
180 @author Jon S. Berndt
181 @version $Id: FGLGear.h,v 1.47 2011/08/30 21:05:56 bcoconni Exp $
182 @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
183 NASA-Ames", NASA CR-2497, January 1975
184 @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
185 Wiley & Sons, 1979 ISBN 0-471-03032-5
186 @see W. A. Ragsdale, "A Generic Landing Gear Dynamics Model for LASRS++",
190 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
194 class FGLGear : public FGForce
199 double VcalibratedKts;
204 bool TakeoffThrottle;
212 std::vector <double> SteerPosDeg;
213 std::vector <double> BrakePos;
214 std::vector <FGColumnVector3> vWhlBodyVec;
219 /// Brake grouping enumerators
220 enum BrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail, bgNumBrakeGroups };
221 /// Steering group membership enumerators
222 enum SteerType {stSteer, stFixed, stCaster};
223 /// Contact point type
224 enum ContactType {ctBOGEY, ctSTRUCTURE};
225 /// Report type enumerators
226 enum ReportType {erNone=0, erTakeoff, erLand};
228 enum DampType {dtLinear=0, dtSquare};
230 enum FrictionType {ftRoll=0, ftSide, ftDynamic};
232 @param el a pointer to the XML element that contains the CONTACT info.
233 @param Executive a pointer to the parent executive object
234 @param number integer identifier for this instance of FGLGear
236 FGLGear(Element* el, FGFDMExec* Executive, int number, const struct Inputs& input);
240 /// The Force vector for this gear
241 FGColumnVector3& GetBodyForces(void);
243 /// Gets the location of the gear in Body axes
244 FGColumnVector3 GetBodyLocation(void) const { return in.vWhlBodyVec[GearNumber]; }
245 double GetBodyLocation(int idx) const { return in.vWhlBodyVec[GearNumber](idx); }
247 FGColumnVector3& GetLocalGear(void) { return vLocalGear; }
248 double GetLocalGear(int idx) const { return vLocalGear(idx); }
250 /// Gets the name of the gear
251 string GetName(void) const {return name; }
252 /// Gets the Weight On Wheels flag value
253 bool GetWOW(void) const {return WOW; }
254 /// Gets the current compressed length of the gear in feet
255 double GetCompLen(void) const {return compressLength;}
256 /// Gets the current gear compression velocity in ft/sec
257 double GetCompVel(void) const {return compressSpeed; }
258 /// Gets the gear compression force in pounds
259 double GetCompForce(void) const {return StrutForce; }
260 double GetBrakeFCoeff(void) const {return BrakeFCoeff;}
262 /// Gets the current normalized tire pressure
263 double GetTirePressure(void) const { return TirePressureNorm; }
264 /// Sets the new normalized tire pressure
265 void SetTirePressure(double p) { TirePressureNorm = p; }
267 /// Sets the brake value in percent (0 - 100)
268 void SetBrake(double bp) {brakePct = bp;}
270 /// Sets the weight-on-wheels flag.
271 void SetWOW(bool wow) {WOW = wow;}
273 /** Set the console touchdown reporting feature
274 @param flag true turns on touchdown reporting, false turns it off */
275 void SetReport(bool flag) { ReportEnable = flag; }
276 /** Get the console touchdown reporting feature
277 @return true if reporting is turned on */
278 bool GetReport(void) const { return ReportEnable; }
279 double GetSteerNorm(void) const { return radtodeg/maxSteerAngle*SteerAngle; }
280 double GetDefaultSteerAngle(double cmd) const { return cmd*maxSteerAngle; }
281 double GetstaticFCoeff(void) const { return staticFCoeff; }
283 int GetBrakeGroup(void) const { return (int)eBrakeGrp; }
284 int GetSteerType(void) const { return (int)eSteerType; }
286 bool GetSteerable(void) const { return eSteerType != stFixed; }
287 bool GetRetractable(void) const { return isRetractable; }
288 bool GetGearUnitUp(void) const { return GearUp; }
289 bool GetGearUnitDown(void) const { return GearDown; }
290 double GetWheelRollForce(void) {
292 FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces();
293 return vForce(eX)*cos(SteerAngle) + vForce(eY)*sin(SteerAngle); }
294 double GetWheelSideForce(void) {
296 FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces();
297 return vForce(eY)*cos(SteerAngle) - vForce(eX)*sin(SteerAngle); }
298 double GetWheelRollVel(void) const { return vWhlVelVec(eX)*cos(SteerAngle)
299 + vWhlVelVec(eY)*sin(SteerAngle); }
300 double GetWheelSideVel(void) const { return vWhlVelVec(eY)*cos(SteerAngle)
301 - vWhlVelVec(eX)*sin(SteerAngle); }
302 double GetWheelSlipAngle(void) const { return WheelSlip; }
303 double GetWheelVel(int axis) const { return vWhlVelVec(axis);}
304 bool IsBogey(void) const { return (eContactType == ctBOGEY);}
305 double GetGearUnitPos(void);
306 double GetSteerAngleDeg(void) const { return radtodeg*SteerAngle; }
308 const struct Inputs& in;
314 static const FGMatrix33 Tb2s;
316 FGColumnVector3 vGearOrient;
317 FGColumnVector3 vLocalGear;
318 FGColumnVector3 vWhlVelVec, vLocalWhlVel; // Velocity of this wheel
319 FGColumnVector3 normal, vGroundNormal;
320 FGLocation contact, gearLoc;
321 FGTable *ForceY_Table;
326 double compressLength;
327 double compressSpeed;
328 double staticFCoeff, dynamicFCoeff, rollingFCoeff;
329 double Stiffness, Shape, Peak, Curvature; // Pacejka factors
335 double TakeoffDistanceTraveled;
336 double TakeoffDistanceTraveled50ft;
337 double LandingDistanceTraveled;
338 double MaximumStrutForce, StrutForce;
339 double MaximumStrutTravel;
342 double TirePressureNorm;
348 bool StartedGroundRun;
349 bool LandingReported;
350 bool TakeoffReported;
353 bool GearUp, GearDown;
358 std::string sSteerType;
359 std::string sBrakeGroup;
360 std::string sRetractable;
361 std::string sContactType;
363 BrakeGroup eBrakeGrp;
364 ContactType eContactType;
365 SteerType eSteerType;
367 DampType eDampTypeRebound;
368 double maxSteerAngle;
370 LagrangeMultiplier LMultiplier[3];
372 FGGroundReactions* GroundReactions;
373 FGPropertyManager* PropertyManager;
375 void ComputeRetractionState(void);
376 void ComputeBrakeForceCoefficient(void);
377 void ComputeSteeringAngle(void);
378 void ComputeSlipAngle(void);
379 void ComputeSideForceCoefficient(void);
380 void ComputeVerticalStrutForce(void);
381 void ComputeGroundCoordSys(void);
382 void ComputeJacobian(const FGColumnVector3& vWhlContactVec);
383 void UpdateForces(void);
384 void CrashDetect(void);
385 void InitializeReporting(void);
386 void ResetReporting(void);
387 void ReportTakeoffOrLanding(void);
388 void Report(ReportType rt);
389 void Debug(int from);
393 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%