| 1 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 | |
| 3 | Header: FGLGear.h |
| 4 | Author: Jon S. Berndt |
| 5 | Date started: 11/18/99 |
| 6 | |
| 7 | ------------- Copyright (C) 1999 Jon S. Berndt ([email protected]) ------------- |
| 8 | |
| 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 |
| 11 | Software Foundation; either version 2 of the License, or (at your option) any |
| 12 | later version. |
| 13 | |
| 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 |
| 17 | details. |
| 18 | |
| 19 | You should have received a copy of the GNU Lesser General Public License along |
| 20 | with this program; if not, write to the Free Software Foundation, Inc., 59 |
| 21 | Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 22 | |
| 23 | Further information about the GNU Lesser General Public License can also be |
| 24 | found on the world wide web at http://www.gnu.org. |
| 25 | |
| 26 | HISTORY |
| 27 | -------------------------------------------------------------------------------- |
| 28 | 11/18/99 JSB Created |
| 29 | |
| 30 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 31 | SENTRY |
| 32 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 33 | |
| 34 | #ifndef FGLGEAR_H |
| 35 | #define FGLGEAR_H |
| 36 | |
| 37 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 38 | INCLUDES |
| 39 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 40 | |
| 41 | #include <string> |
| 42 | |
| 43 | #include "models/propulsion/FGForce.h" |
| 44 | #include "math/FGLocation.h" |
| 45 | #include "math/FGColumnVector3.h" |
| 46 | #include "math/LagrangeMultiplier.h" |
| 47 | |
| 48 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 49 | FORWARD DECLARATIONS |
| 50 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 51 | |
| 52 | namespace JSBSim { |
| 53 | |
| 54 | class FGTable; |
| 55 | class Element; |
| 56 | class FGPropertyManager; |
| 57 | class FGGroundReactions; |
| 58 | class FGFunction; |
| 59 | |
| 60 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 61 | CLASS DOCUMENTATION |
| 62 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 63 | |
| 64 | /** Landing gear model. |
| 65 | Calculates forces and moments due to landing gear reactions. This is done in |
| 66 | several steps, and is dependent on what kind of gear is being modeled. Here |
| 67 | are the parameters that can be specified in the config file for modeling |
| 68 | landing gear: |
| 69 | <p> |
| 70 | <h3>Physical Characteristics</h3> |
| 71 | <ol> |
| 72 | <li>X, Y, Z location, in inches in structural coordinate frame</li> |
| 73 | <li>Spring constant, in lbs/ft</li> |
| 74 | <li>Damping coefficient, in lbs/ft/sec</li> |
| 75 | <li>Dynamic Friction Coefficient</li> |
| 76 | <li>Static Friction Coefficient</li> |
| 77 | </ol></p><p> |
| 78 | <h3>Operational Properties</h3> |
| 79 | <ol> |
| 80 | <li>Name</li> |
| 81 | <li>Brake Group Membership {one of LEFT | CENTER | RIGHT | NOSE | TAIL | NONE}</li> |
| 82 | <li>Max Steer Angle, in degrees</li> |
| 83 | </ol></p> |
| 84 | <p> |
| 85 | <h3>Algorithm and Approach to Modeling</h3> |
| 86 | <ol> |
| 87 | <li>Find the location of the uncompressed landing gear relative to the CG of |
| 88 | the aircraft. Remember, the structural coordinate frame that the aircraft is |
| 89 | defined in is: X positive towards the tail, Y positive out the right side, Z |
| 90 | positive upwards. The locations of the various parts are given in inches in |
| 91 | the config file.</li> |
| 92 | <li>The vector giving the location of the gear (relative to the cg) is |
| 93 | rotated 180 degrees about the Y axis to put the coordinates in body frame (X |
| 94 | positive forwards, Y positive out the right side, Z positive downwards, with |
| 95 | the origin at the cg). The lengths are also now given in feet.</li> |
| 96 | <li>The new gear location is now transformed to the local coordinate frame |
| 97 | using the body-to-local matrix. (Mb2l).</li> |
| 98 | <li>Knowing the location of the center of gravity relative to the ground |
| 99 | (height above ground level or AGL) now enables gear deflection to be |
| 100 | calculated. The gear compression value is the local frame gear Z location |
| 101 | value minus the height AGL. [Currently, we make the assumption that the gear |
| 102 | is oriented - and the deflection occurs in - the Z axis only. Additionally, |
| 103 | the vector to the landing gear is currently not modified - which would |
| 104 | (correctly) move the point of contact to the actual compressed-gear point of |
| 105 | contact. Eventually, articulated gear may be modeled, but initially an |
| 106 | effort must be made to model a generic system.] As an example, say the |
| 107 | aircraft left main gear location (in local coordinates) is Z = 3 feet |
| 108 | (positive) and the height AGL is 2 feet. This tells us that the gear is |
| 109 | compressed 1 foot.</li> |
| 110 | <li>If the gear is compressed, a Weight-On-Wheels (WOW) flag is set.</li> |
| 111 | <li>With the compression length calculated, the compression velocity may now |
| 112 | be calculated. This will be used to determine the damping force in the |
| 113 | strut. The aircraft rotational rate is multiplied by the vector to the wheel |
| 114 | to get a wheel velocity in body frame. That velocity vector is then |
| 115 | transformed into the local coordinate frame.</li> |
| 116 | <li>The aircraft cg velocity in the local frame is added to the |
| 117 | just-calculated wheel velocity (due to rotation) to get a total wheel |
| 118 | velocity in the local frame.</li> |
| 119 | <li>The compression speed is the Z-component of the vector.</li> |
| 120 | <li>With the wheel velocity vector no longer needed, it is normalized and |
| 121 | multiplied by a -1 to reverse it. This will be used in the friction force |
| 122 | calculation.</li> |
| 123 | <li>Since the friction force takes place solely in the runway plane, the Z |
| 124 | coordinate of the normalized wheel velocity vector is set to zero.</li> |
| 125 | <li>The gear deflection force (the force on the aircraft acting along the |
| 126 | local frame Z axis) is now calculated given the spring and damper |
| 127 | coefficients, and the gear deflection speed and stroke length. Keep in mind |
| 128 | that gear forces always act in the negative direction (in both local and |
| 129 | body frames), and are not capable of generating a force in the positive |
| 130 | sense (one that would attract the aircraft to the ground). So, the gear |
| 131 | forces are always negative - they are limited to values of zero or less. The |
| 132 | gear force is simply the negative of the sum of the spring compression |
| 133 | length times the spring coefficient and the gear velocity times the damping |
| 134 | coefficient.</li> |
| 135 | <li>The lateral/directional force acting on the aircraft through the landing |
| 136 | |
| 137 | gear (along the local frame X and Y axes) is calculated next. First, the |
| 138 | friction coefficient is multiplied by the recently calculated Z-force. This |
| 139 | is the friction force. It must be given direction in addition to magnitude. |
| 140 | We want the components in the local frame X and Y axes. From step 9, above, |
| 141 | the conditioned wheel velocity vector is taken and the X and Y parts are |
| 142 | multiplied by the friction force to get the X and Y components of friction. |
| 143 | </li> |
| 144 | <li>The wheel force in local frame is next converted to body frame.</li> |
| 145 | <li>The moment due to the gear force is calculated by multiplying r x F |
| 146 | (radius to wheel crossed into the wheel force). Both of these operands are |
| 147 | in body frame.</li> |
| 148 | </ol> |
| 149 | |
| 150 | <h3>Configuration File Format for \<contact> Section:</h3> |
| 151 | @code{.xml} |
| 152 | <contact type="{BOGEY | STRUCTURE}" name="{string}"> |
| 153 | <location unit="{IN | M}"> |
| 154 | <x> {number} </x> |
| 155 | <y> {number} </y> |
| 156 | <z> {number} </z> |
| 157 | </location> |
| 158 | <orientation unit="{RAD | DEG}"> |
| 159 | <pitch> {number} </pitch> |
| 160 | <roll> {number} </roll> |
| 161 | <yaw> {number} </yaw> |
| 162 | </orientation> |
| 163 | <static_friction> {number} </static_friction> |
| 164 | <dynamic_friction> {number} </dynamic_friction> |
| 165 | <rolling_friction> {number} </rolling_friction> |
| 166 | <spring_coeff unit="{LBS/FT | N/M}"> {number} </spring_coeff> |
| 167 | <damping_coeff type="{ | SQUARE}" unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff> |
| 168 | <damping_coeff_rebound type="{ | SQUARE}" unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff_rebound> |
| 169 | <max_steer unit="DEG"> {number | 0 | 360} </max_steer> |
| 170 | <brake_group> {NONE | LEFT | RIGHT | CENTER | NOSE | TAIL} </brake_group> |
| 171 | <retractable>{0 | 1}</retractable> |
| 172 | <table name="{CORNERING_COEFF}" type="internal"> |
| 173 | <tableData> |
| 174 | {cornering parameters} |
| 175 | </tableData> |
| 176 | </table> |
| 177 | </contact> |
| 178 | @endcode |
| 179 | @author Jon S. Berndt |
| 180 | @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at |
| 181 | NASA-Ames", NASA CR-2497, January 1975 |
| 182 | @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics", |
| 183 | Wiley & Sons, 1979 ISBN 0-471-03032-5 |
| 184 | @see W. A. Ragsdale, "A Generic Landing Gear Dynamics Model for LASRS++", |
| 185 | AIAA-2000-4303 |
| 186 | */ |
| 187 | |
| 188 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 189 | CLASS DECLARATION |
| 190 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 191 | |
| 192 | class JSBSIM_API FGLGear : public FGForce |
| 193 | { |
| 194 | public: |
| 195 | struct Inputs { |
| 196 | double Vground; |
| 197 | double VcalibratedKts; |
| 198 | double Temperature; |
| 199 | double DistanceAGL; |
| 200 | double DistanceASL; |
| 201 | double TotalDeltaT; |
| 202 | bool TakeoffThrottle; |
| 203 | bool WOW; |
| 204 | FGMatrix33 Tb2l; |
| 205 | FGMatrix33 Tec2l; |
| 206 | FGMatrix33 Tec2b; |
| 207 | FGColumnVector3 PQR; |
| 208 | FGColumnVector3 UVW; |
| 209 | FGColumnVector3 vXYZcg; // CG coordinates expressed in the structural frame |
| 210 | FGLocation Location; |
| 211 | std::vector <double> BrakePos; |
| 212 | double FCSGearPos; |
| 213 | double EmptyWeight; |
| 214 | }; |
| 215 | |
| 216 | /// Brake grouping enumerators |
| 217 | enum BrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail, bgNumBrakeGroups }; |
| 218 | /// Steering group membership enumerators |
| 219 | enum SteerType {stSteer, stFixed, stCaster}; |
| 220 | /// Contact point type |
| 221 | enum ContactType {ctBOGEY, ctSTRUCTURE}; |
| 222 | /// Report type enumerators |
| 223 | enum ReportType {erNone=0, erTakeoff, erLand}; |
| 224 | /// Damping types |
| 225 | enum DampType {dtLinear=0, dtSquare}; |
| 226 | /// Friction types |
| 227 | enum FrictionType {ftRoll=0, ftSide, ftDynamic}; |
| 228 | /** Constructor |
| 229 | @param el a pointer to the XML element that contains the CONTACT info. |
| 230 | @param Executive a pointer to the parent executive object |
| 231 | @param number integer identifier for this instance of FGLGear |
| 232 | */ |
| 233 | FGLGear(Element* el, FGFDMExec* Executive, int number, const struct Inputs& input); |
| 234 | /// Destructor |
| 235 | ~FGLGear(); |
| 236 | |
| 237 | /// The Force vector for this gear |
| 238 | const FGColumnVector3& GetBodyForces(void) override; |
| 239 | |
| 240 | /// Gets the location of the gear in Body axes |
| 241 | FGColumnVector3 GetBodyLocation(void) const { |
| 242 | return Ts2b * (vXYZn - in.vXYZcg); |
| 243 | } |
| 244 | double GetBodyLocation(int idx) const { |
| 245 | FGColumnVector3 vWhlBodyVec = Ts2b * (vXYZn - in.vXYZcg); |
| 246 | return vWhlBodyVec(idx); |
| 247 | } |
| 248 | |
| 249 | const FGColumnVector3& GetLocalGear(void) const { return vLocalGear; } |
| 250 | double GetLocalGear(int idx) const { return vLocalGear(idx); } |
| 251 | |
| 252 | /// Gets the name of the gear |
| 253 | const std::string& GetName(void) const {return name; } |
| 254 | /// Gets the Weight On Wheels flag value |
| 255 | bool GetWOW(void) const {return WOW; } |
| 256 | /// Gets the current compressed length of the gear in feet |
| 257 | double GetCompLen(void) const {return compressLength;} |
| 258 | /// Gets the current gear compression velocity in ft/sec |
| 259 | double GetCompVel(void) const {return compressSpeed; } |
| 260 | /// Gets the gear compression force in pounds |
| 261 | double GetCompForce(void) const {return StrutForce; } |
| 262 | |
| 263 | /// Sets the weight-on-wheels flag. |
| 264 | void SetWOW(bool wow) {WOW = wow;} |
| 265 | |
| 266 | /** Set the console touchdown reporting feature |
| 267 | @param flag true turns on touchdown reporting, false turns it off */ |
| 268 | void SetReport(bool flag) { ReportEnable = flag; } |
| 269 | /** Get the console touchdown reporting feature |
| 270 | @return true if reporting is turned on */ |
| 271 | bool GetReport(void) const { return ReportEnable; } |
| 272 | double GetSteerNorm(void) const { |
| 273 | return maxSteerAngle == 0.0 ? 0.0 : radtodeg/maxSteerAngle*SteerAngle; |
| 274 | } |
| 275 | void SetSteerCmd(double cmd) { SetSteerAngleDeg(cmd * maxSteerAngle); } |
| 276 | double GetstaticFCoeff(void) const { return staticFCoeff; } |
| 277 | |
| 278 | int GetBrakeGroup(void) const { return (int)eBrakeGrp; } |
| 279 | int GetSteerType(void) const { return (int)eSteerType; } |
| 280 | |
| 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; } |
| 285 | |
| 286 | double GetWheelRollForce(void) { |
| 287 | UpdateForces(); |
| 288 | FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces(); |
| 289 | return vForce(eX)*cos(SteerAngle) + vForce(eY)*sin(SteerAngle); } |
| 290 | double GetWheelSideForce(void) { |
| 291 | UpdateForces(); |
| 292 | FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces(); |
| 293 | return vForce(eY)*cos(SteerAngle) - vForce(eX)*sin(SteerAngle); } |
| 294 | double GetBodyXForce(void) { |
| 295 | UpdateForces(); |
| 296 | return FGForce::GetBodyForces()(eX); |
| 297 | } |
| 298 | double GetBodyYForce(void) { |
| 299 | UpdateForces(); |
| 300 | return FGForce::GetBodyForces()(eY); |
| 301 | } |
| 302 | double GetBodyZForce(void) { |
| 303 | UpdateForces(); |
| 304 | return FGForce::GetBodyForces()(eZ); |
| 305 | } |
| 306 | double GetWheelRollVel(void) const { return vWhlVelVec(eX)*cos(SteerAngle) |
| 307 | + vWhlVelVec(eY)*sin(SteerAngle); } |
| 308 | double GetWheelSideVel(void) const { return vWhlVelVec(eY)*cos(SteerAngle) |
| 309 | - vWhlVelVec(eX)*sin(SteerAngle); } |
| 310 | double GetWheelSlipAngle(void) const { return WheelSlip; } |
| 311 | double GetWheelVel(int axis) const { return vWhlVelVec(axis);} |
| 312 | bool IsBogey(void) const { return (eContactType == ctBOGEY);} |
| 313 | double GetGearUnitPos(void) const; |
| 314 | double GetSteerAngleDeg(void) const { return radtodeg*SteerAngle; } |
| 315 | void SetSteerAngleDeg(double angle) { |
| 316 | if (eSteerType != stFixed && !Castered) |
| 317 | SteerAngle = degtorad * angle; |
| 318 | } |
| 319 | |
| 320 | const struct Inputs& in; |
| 321 | |
| 322 | void ResetToIC(void); |
| 323 | void bind(void); |
| 324 | |
| 325 | private: |
| 326 | int GearNumber; |
| 327 | static const FGMatrix33 Tb2s; |
| 328 | static const FGMatrix33 Ts2b; |
| 329 | FGMatrix33 mTGear; |
| 330 | FGColumnVector3 vLocalGear; |
| 331 | FGColumnVector3 vWhlVelVec, vGroundWhlVel; // Velocity of this wheel |
| 332 | FGColumnVector3 vGroundNormal; |
| 333 | FGTable *ForceY_Table; |
| 334 | FGFunction *fStrutForce; |
| 335 | double SteerAngle; |
| 336 | double kSpring; |
| 337 | double bDamp; |
| 338 | double bDampRebound; |
| 339 | double compressLength; |
| 340 | double compressSpeed; |
| 341 | double staticFCoeff, dynamicFCoeff, rollingFCoeff; |
| 342 | double Stiffness, Shape, Peak, Curvature; // Pacejka factors |
| 343 | double BrakeFCoeff; |
| 344 | double maxCompLen; |
| 345 | double SinkRate; |
| 346 | double GroundSpeed; |
| 347 | double TakeoffDistanceTraveled; |
| 348 | double TakeoffDistanceTraveled50ft; |
| 349 | double LandingDistanceTraveled; |
| 350 | double MaximumStrutForce, StrutForce; |
| 351 | double MaximumStrutTravel; |
| 352 | double FCoeff; |
| 353 | double WheelSlip; |
| 354 | double GearPos; |
| 355 | double staticFFactor = 1.0; |
| 356 | double rollingFFactor = 1.0; |
| 357 | double maximumForce = DBL_MAX; |
| 358 | double bumpiness = 0.0; |
| 359 | bool isSolid = true; |
| 360 | bool WOW; |
| 361 | bool lastWOW; |
| 362 | bool FirstContact; |
| 363 | bool StartedGroundRun; |
| 364 | bool LandingReported; |
| 365 | bool TakeoffReported; |
| 366 | bool ReportEnable; |
| 367 | bool isRetractable; |
| 368 | bool Castered; |
| 369 | bool StaticFriction; |
| 370 | std::string name; |
| 371 | |
| 372 | BrakeGroup eBrakeGrp; |
| 373 | ContactType eContactType; |
| 374 | SteerType eSteerType; |
| 375 | DampType eDampType; |
| 376 | DampType eDampTypeRebound; |
| 377 | double maxSteerAngle; |
| 378 | |
| 379 | LagrangeMultiplier LMultiplier[3]; |
| 380 | |
| 381 | FGGroundReactions* GroundReactions; |
| 382 | FGPropertyManager* PropertyManager; |
| 383 | |
| 384 | mutable bool useFCSGearPos; |
| 385 | |
| 386 | void ComputeBrakeForceCoefficient(void); |
| 387 | void ComputeSteeringAngle(void); |
| 388 | void ComputeSlipAngle(void); |
| 389 | void ComputeSideForceCoefficient(void); |
| 390 | void ComputeVerticalStrutForce(void); |
| 391 | void ComputeGroundFrame(void); |
| 392 | void ComputeJacobian(const FGColumnVector3& vWhlContactVec); |
| 393 | void UpdateForces(void); |
| 394 | void SetstaticFCoeff(double coeff); |
| 395 | void CrashDetect(void); |
| 396 | void InitializeReporting(void); |
| 397 | void ResetReporting(void); |
| 398 | void ReportTakeoffOrLanding(void); |
| 399 | void Report(ReportType rt); |
| 400 | void Debug(int from); |
| 401 | }; |
| 402 | } |
| 403 | |
| 404 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 405 | |
| 406 | #endif |