JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
FGLGear.h
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 (jon@jsbsim.org) -------------
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/FGColumnVector3.h"
45 #include "math/LagrangeMultiplier.h"
46 #include "FGSurface.h"
47 
48 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 FORWARD DECLARATIONS
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51 
52 namespace JSBSim {
53 
54 class FGTable;
55 class Element;
56 class FGPropertyManager;
57 
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS DOCUMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 
186 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
187 CLASS DECLARATION
188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
189 
190 class FGLGear : protected FGSurface, public FGForce
191 {
192 public:
193  struct Inputs {
194  double Vground;
195  double VcalibratedKts;
196  double Temperature;
197  double DistanceAGL;
198  double DistanceASL;
199  double TotalDeltaT;
200  bool TakeoffThrottle;
201  bool WOW;
202  FGMatrix33 Tb2l;
203  FGMatrix33 Tec2l;
204  FGMatrix33 Tec2b;
205  FGColumnVector3 PQR;
206  FGColumnVector3 UVW;
207  FGColumnVector3 vXYZcg; // CG coordinates expressed in the structural frame
208  FGLocation Location;
209  std::vector <double> BrakePos;
210  double FCSGearPos;
211  double EmptyWeight;
212  };
213 
215  enum BrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail, bgNumBrakeGroups };
217  enum SteerType {stSteer, stFixed, stCaster};
219  enum ContactType {ctBOGEY, ctSTRUCTURE};
221  enum ReportType {erNone=0, erTakeoff, erLand};
223  enum DampType {dtLinear=0, dtSquare};
225  enum FrictionType {ftRoll=0, ftSide, ftDynamic};
231  FGLGear(Element* el, FGFDMExec* Executive, int number, const struct Inputs& input);
233  ~FGLGear();
234 
238  const FGColumnVector3& GetBodyForces(FGSurface *surface = NULL);
239 
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 
253  const std::string& GetName(void) const {return name; }
255  bool GetWOW(void) const {return WOW; }
257  double GetCompLen(void) const {return compressLength;}
259  double GetCompVel(void) const {return compressSpeed; }
261  double GetCompForce(void) const {return StrutForce; }
262 
264  void SetWOW(bool wow) {WOW = wow;}
265 
268  void SetReport(bool flag) { ReportEnable = flag; }
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, Ts2b;
328  FGMatrix33 mTGear;
329  FGColumnVector3 vLocalGear;
330  FGColumnVector3 vWhlVelVec, vGroundWhlVel; // Velocity of this wheel
331  FGColumnVector3 vGroundNormal;
332  FGTable *ForceY_Table;
333  FGFunction *fStrutForce;
334  double SteerAngle;
335  double kSpring;
336  double bDamp;
337  double bDampRebound;
338  double compressLength;
339  double compressSpeed;
340  double rollingFCoeff;
341  double Stiffness, Shape, Peak, Curvature; // Pacejka factors
342  double BrakeFCoeff;
343  double maxCompLen;
344  double SinkRate;
345  double GroundSpeed;
346  double TakeoffDistanceTraveled;
347  double TakeoffDistanceTraveled50ft;
348  double LandingDistanceTraveled;
349  double MaximumStrutForce, StrutForce;
350  double MaximumStrutTravel;
351  double FCoeff;
352  double WheelSlip;
353  double GearPos;
354  bool WOW;
355  bool lastWOW;
356  bool FirstContact;
357  bool StartedGroundRun;
358  bool LandingReported;
359  bool TakeoffReported;
360  bool ReportEnable;
361  bool isRetractable;
362  bool Castered;
363  bool StaticFriction;
364  std::string name;
365 
366  BrakeGroup eBrakeGrp;
367  ContactType eContactType;
368  SteerType eSteerType;
369  DampType eDampType;
370  DampType eDampTypeRebound;
371  double maxSteerAngle;
372 
373  LagrangeMultiplier LMultiplier[3];
374 
375  FGGroundReactions* GroundReactions;
376  FGPropertyManager* PropertyManager;
377 
378  mutable bool useFCSGearPos;
379 
380  void ComputeBrakeForceCoefficient(void);
381  void ComputeSteeringAngle(void);
382  void ComputeSlipAngle(void);
383  void ComputeSideForceCoefficient(void);
384  void ComputeVerticalStrutForce(void);
385  void ComputeGroundFrame(void);
386  void ComputeJacobian(const FGColumnVector3& vWhlContactVec);
387  void UpdateForces(void);
388  void SetstaticFCoeff(double coeff);
389  void CrashDetect(void);
390  void InitializeReporting(void);
391  void ResetReporting(void);
392  void ReportTakeoffOrLanding(void);
393  void Report(ReportType rt);
394  void Debug(int from);
395 };
396 }
397 
398 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
399 
400 #endif
JSBSim::FGSurface
Base class for all surface properties.
Definition: FGSurface.h:61
JSBSim::FGFDMExec
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:185
JSBSim::FGLGear::SetReport
void SetReport(bool flag)
Set the console touchdown reporting feature.
Definition: FGLGear.h:268
JSBSim::FGLGear::GetCompLen
double GetCompLen(void) const
Gets the current compressed length of the gear in feet.
Definition: FGLGear.h:257
JSBSim::FGColumnVector3
This class implements a 3 element column vector.
Definition: FGColumnVector3.h:63
JSBSim::FGLocation
FGLocation holds an arbitrary location in the Earth centered Earth fixed reference frame (ECEF).
Definition: FGLocation.h:151
JSBSim::FGLGear::Inputs
Definition: FGLGear.h:193
JSBSim::FGLGear::FrictionType
FrictionType
Friction types.
Definition: FGLGear.h:225
JSBSim::FGLGear::GetBodyLocation
FGColumnVector3 GetBodyLocation(void) const
Gets the location of the gear in Body axes.
Definition: FGLGear.h:241
JSBSim::FGLGear::DampType
DampType
Damping types.
Definition: FGLGear.h:223
JSBSim::FGLGear
Landing gear model.
Definition: FGLGear.h:190
JSBSim::FGLGear::GetReport
bool GetReport(void) const
Get the console touchdown reporting feature.
Definition: FGLGear.h:271
JSBSim::FGLGear::SetWOW
void SetWOW(bool wow)
Sets the weight-on-wheels flag.
Definition: FGLGear.h:264
JSBSim::FGLGear::GetCompForce
double GetCompForce(void) const
Gets the gear compression force in pounds.
Definition: FGLGear.h:261
JSBSim::FGLGear::SteerType
SteerType
Steering group membership enumerators.
Definition: FGLGear.h:217
JSBSim::FGMatrix33
Handles matrix math operations.
Definition: FGMatrix33.h:69
JSBSim::FGLGear::GetWOW
bool GetWOW(void) const
Gets the Weight On Wheels flag value.
Definition: FGLGear.h:255
JSBSim::FGForce
Utility class that aids in the conversion of forces between coordinate systems and calculation of mom...
Definition: FGForce.h:221
JSBSim::FGLGear::ReportType
ReportType
Report type enumerators.
Definition: FGLGear.h:221
JSBSim::FGMatrix33::Transposed
FGMatrix33 Transposed(void) const
Transposed matrix.
Definition: FGMatrix33.h:221
JSBSim::FGLGear::GetCompVel
double GetCompVel(void) const
Gets the current gear compression velocity in ft/sec.
Definition: FGLGear.h:259
JSBSim::FGLGear::~FGLGear
~FGLGear()
Destructor.
Definition: FGLGear.cpp:238
JSBSim::FGLGear::BrakeGroup
BrakeGroup
Brake grouping enumerators.
Definition: FGLGear.h:215
JSBSim::FGLGear::FGLGear
FGLGear(Element *el, FGFDMExec *Executive, int number, const struct Inputs &input)
Constructor.
Definition: FGLGear.cpp:71
JSBSim::FGLGear::GetName
const std::string & GetName(void) const
Gets the name of the gear.
Definition: FGLGear.h:253
JSBSim::FGLGear::ContactType
ContactType
Contact point type.
Definition: FGLGear.h:219
JSBSim::Element
Definition: FGXMLElement.h:143