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/LagrangeMultiplier.h"
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51 #define ID_LGEAR "$Id: FGLGear.h,v 1.54 2012/04/01 17:05:51 bcoconni Exp $"
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 class FGPropertyManager;
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 /** Landing gear model.
68 Calculates forces and moments due to landing gear reactions. This is done in
69 several steps, and is dependent on what kind of gear is being modeled. Here
70 are the parameters that can be specified in the config file for modeling
73 <h3>Physical Characteristics</h3>
75 <li>X, Y, Z location, in inches in structural coordinate frame</li>
76 <li>Spring constant, in lbs/ft</li>
77 <li>Damping coefficient, in lbs/ft/sec</li>
78 <li>Dynamic Friction Coefficient</li>
79 <li>Static Friction Coefficient</li>
81 <h3>Operational Properties</h3>
84 <li>Brake Group Membership {one of LEFT | CENTER | RIGHT | NOSE | TAIL | NONE}</li>
85 <li>Max Steer Angle, in degrees</li>
88 <h3>Algorithm and Approach to Modeling</h3>
90 <li>Find the location of the uncompressed landing gear relative to the CG of
91 the aircraft. Remember, the structural coordinate frame that the aircraft is
92 defined in is: X positive towards the tail, Y positive out the right side, Z
93 positive upwards. The locations of the various parts are given in inches in
95 <li>The vector giving the location of the gear (relative to the cg) is
96 rotated 180 degrees about the Y axis to put the coordinates in body frame (X
97 positive forwards, Y positive out the right side, Z positive downwards, with
98 the origin at the cg). The lengths are also now given in feet.</li>
99 <li>The new gear location is now transformed to the local coordinate frame
100 using the body-to-local matrix. (Mb2l).</li>
101 <li>Knowing the location of the center of gravity relative to the ground
102 (height above ground level or AGL) now enables gear deflection to be
103 calculated. The gear compression value is the local frame gear Z location
104 value minus the height AGL. [Currently, we make the assumption that the gear
105 is oriented - and the deflection occurs in - the Z axis only. Additionally,
106 the vector to the landing gear is currently not modified - which would
107 (correctly) move the point of contact to the actual compressed-gear point of
108 contact. Eventually, articulated gear may be modeled, but initially an
109 effort must be made to model a generic system.] As an example, say the
110 aircraft left main gear location (in local coordinates) is Z = 3 feet
111 (positive) and the height AGL is 2 feet. This tells us that the gear is
112 compressed 1 foot.</li>
113 <li>If the gear is compressed, a Weight-On-Wheels (WOW) flag is set.</li>
114 <li>With the compression length calculated, the compression velocity may now
115 be calculated. This will be used to determine the damping force in the
116 strut. The aircraft rotational rate is multiplied by the vector to the wheel
117 to get a wheel velocity in body frame. That velocity vector is then
118 transformed into the local coordinate frame.</li>
119 <li>The aircraft cg velocity in the local frame is added to the
120 just-calculated wheel velocity (due to rotation) to get a total wheel
121 velocity in the local frame.</li>
122 <li>The compression speed is the Z-component of the vector.</li>
123 <li>With the wheel velocity vector no longer needed, it is normalized and
124 multiplied by a -1 to reverse it. This will be used in the friction force
126 <li>Since the friction force takes place solely in the runway plane, the Z
127 coordinate of the normalized wheel velocity vector is set to zero.</li>
128 <li>The gear deflection force (the force on the aircraft acting along the
129 local frame Z axis) is now calculated given the spring and damper
130 coefficients, and the gear deflection speed and stroke length. Keep in mind
131 that gear forces always act in the negative direction (in both local and
132 body frames), and are not capable of generating a force in the positive
133 sense (one that would attract the aircraft to the ground). So, the gear
134 forces are always negative - they are limited to values of zero or less. The
135 gear force is simply the negative of the sum of the spring compression
136 length times the spring coefficient and the gear velocity times the damping
138 <li>The lateral/directional force acting on the aircraft through the landing
140 gear (along the local frame X and Y axes) is calculated next. First, the
141 friction coefficient is multiplied by the recently calculated Z-force. This
142 is the friction force. It must be given direction in addition to magnitude.
143 We want the components in the local frame X and Y axes. From step 9, above,
144 the conditioned wheel velocity vector is taken and the X and Y parts are
145 multiplied by the friction force to get the X and Y components of friction.
147 <li>The wheel force in local frame is next converted to body frame.</li>
148 <li>The moment due to the gear force is calculated by multiplying r x F
149 (radius to wheel crossed into the wheel force). Both of these operands are
153 <h3>Configuration File Format:</h3>
155 <contact type="{BOGEY | STRUCTURE}" name="{string}">
156 <location unit="{IN | M}">
161 <orientation unit="{RAD | DEG}">
162 <pitch> {number} </pitch>
163 <roll> {number} </roll>
164 <yaw> {number} </yaw>
166 <static_friction> {number} </static_friction>
167 <dynamic_friction> {number} </dynamic_friction>
168 <rolling_friction> {number} </rolling_friction>
169 <spring_coeff unit="{LBS/FT | N/M}"> {number} </spring_coeff>
170 <damping_coeff [type="SQUARE"] unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff>
171 <damping_coeff_rebound [type="SQUARE"] unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff_rebound>
172 <max_steer unit="DEG"> {number | 0 | 360} </max_steer>
173 <brake_group> {NONE | LEFT | RIGHT | CENTER | NOSE | TAIL} </brake_group>
174 <retractable>{0 | 1}</retractable>
175 <table type="{CORNERING_COEFF}">
179 @author Jon S. Berndt
180 @version $Id: FGLGear.h,v 1.54 2012/04/01 17:05:51 bcoconni Exp $
181 @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
182 NASA-Ames", NASA CR-2497, January 1975
183 @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
184 Wiley & Sons, 1979 ISBN 0-471-03032-5
185 @see W. A. Ragsdale, "A Generic Landing Gear Dynamics Model for LASRS++",
189 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
193 class FGLGear : public FGForce
198 double VcalibratedKts;
203 bool TakeoffThrottle;
210 FGColumnVector3 vXYZcg; // CG coordinates expressed in the structural frame
212 std::vector <double> SteerPosDeg;
213 std::vector <double> BrakePos;
218 /// Brake grouping enumerators
219 enum BrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail, bgNumBrakeGroups };
220 /// Steering group membership enumerators
221 enum SteerType {stSteer, stFixed, stCaster};
222 /// Contact point type
223 enum ContactType {ctBOGEY, ctSTRUCTURE};
224 /// Report type enumerators
225 enum ReportType {erNone=0, erTakeoff, erLand};
227 enum DampType {dtLinear=0, dtSquare};
229 enum FrictionType {ftRoll=0, ftSide, ftDynamic};
231 @param el a pointer to the XML element that contains the CONTACT info.
232 @param Executive a pointer to the parent executive object
233 @param number integer identifier for this instance of FGLGear
235 FGLGear(Element* el, FGFDMExec* Executive, int number, const struct Inputs& input);
239 /// The Force vector for this gear
240 const FGColumnVector3& GetBodyForces(void);
242 /// Gets the location of the gear in Body axes
243 FGColumnVector3 GetBodyLocation(void) const {
244 return Ts2b * (vXYZn - in.vXYZcg);
246 double GetBodyLocation(int idx) const {
247 FGColumnVector3 vWhlBodyVec = Ts2b * (vXYZn - in.vXYZcg);
248 return vWhlBodyVec(idx);
251 const FGColumnVector3& GetLocalGear(void) const { return vLocalGear; }
252 double GetLocalGear(int idx) const { return vLocalGear(idx); }
254 /// Gets the name of the gear
255 const string& GetName(void) const {return name; }
256 /// Gets the Weight On Wheels flag value
257 bool GetWOW(void) const {return WOW; }
258 /// Gets the current compressed length of the gear in feet
259 double GetCompLen(void) const {return compressLength;}
260 /// Gets the current gear compression velocity in ft/sec
261 double GetCompVel(void) const {return compressSpeed; }
262 /// Gets the gear compression force in pounds
263 double GetCompForce(void) const {return StrutForce; }
265 /// Sets the weight-on-wheels flag.
266 void SetWOW(bool wow) {WOW = wow;}
268 /** Set the console touchdown reporting feature
269 @param flag true turns on touchdown reporting, false turns it off */
270 void SetReport(bool flag) { ReportEnable = flag; }
271 /** Get the console touchdown reporting feature
272 @return true if reporting is turned on */
273 bool GetReport(void) const { return ReportEnable; }
274 double GetSteerNorm(void) const { return radtodeg/maxSteerAngle*SteerAngle; }
275 double GetDefaultSteerAngle(double cmd) const { return cmd*maxSteerAngle; }
276 double GetstaticFCoeff(void) const { return staticFCoeff; }
278 int GetBrakeGroup(void) const { return (int)eBrakeGrp; }
279 int GetSteerType(void) const { return (int)eSteerType; }
281 bool GetSteerable(void) const { return eSteerType != stFixed; }
282 bool GetRetractable(void) const { return isRetractable; }
283 bool GetGearUnitUp(void) const { return isRetractable ? (GetGearUnitPos() < 0.01) : false; }
284 bool GetGearUnitDown(void) const { return isRetractable ? (GetGearUnitPos() > 0.99) : true; }
286 double GetWheelRollForce(void) {
288 FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces();
289 return vForce(eX)*cos(SteerAngle) + vForce(eY)*sin(SteerAngle); }
290 double GetWheelSideForce(void) {
292 FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces();
293 return vForce(eY)*cos(SteerAngle) - vForce(eX)*sin(SteerAngle); }
294 double GetWheelRollVel(void) const { return vWhlVelVec(eX)*cos(SteerAngle)
295 + vWhlVelVec(eY)*sin(SteerAngle); }
296 double GetWheelSideVel(void) const { return vWhlVelVec(eY)*cos(SteerAngle)
297 - vWhlVelVec(eX)*sin(SteerAngle); }
298 double GetWheelSlipAngle(void) const { return WheelSlip; }
299 double GetWheelVel(int axis) const { return vWhlVelVec(axis);}
300 bool IsBogey(void) const { return (eContactType == ctBOGEY);}
301 double GetGearUnitPos(void) const;
302 double GetSteerAngleDeg(void) const { return radtodeg*SteerAngle; }
304 const struct Inputs& in;
310 static const FGMatrix33 Tb2s, Ts2b;
312 FGColumnVector3 vLocalGear;
313 FGColumnVector3 vWhlVelVec, vGroundWhlVel; // Velocity of this wheel
314 FGColumnVector3 vGroundNormal;
315 FGTable *ForceY_Table;
320 double compressLength;
321 double compressSpeed;
322 double staticFCoeff, dynamicFCoeff, rollingFCoeff;
323 double Stiffness, Shape, Peak, Curvature; // Pacejka factors
328 double TakeoffDistanceTraveled;
329 double TakeoffDistanceTraveled50ft;
330 double LandingDistanceTraveled;
331 double MaximumStrutForce, StrutForce;
332 double MaximumStrutTravel;
339 bool StartedGroundRun;
340 bool LandingReported;
341 bool TakeoffReported;
348 BrakeGroup eBrakeGrp;
349 ContactType eContactType;
350 SteerType eSteerType;
352 DampType eDampTypeRebound;
353 double maxSteerAngle;
355 LagrangeMultiplier LMultiplier[3];
357 FGGroundReactions* GroundReactions;
358 FGPropertyManager* PropertyManager;
360 mutable bool useFCSGearPos;
362 void ComputeBrakeForceCoefficient(void);
363 void ComputeSteeringAngle(void);
364 void ComputeSlipAngle(void);
365 void ComputeSideForceCoefficient(void);
366 void ComputeVerticalStrutForce(void);
367 void ComputeGroundFrame(void);
368 void ComputeJacobian(const FGColumnVector3& vWhlContactVec);
369 void UpdateForces(void);
370 void CrashDetect(void);
371 void InitializeReporting(void);
372 void ResetReporting(void);
373 void ReportTakeoffOrLanding(void);
374 void Report(ReportType rt);
375 void Debug(int from);
379 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%