JSBSim Flight Dynamics Model  1.0 (02 March 2017)
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 Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  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 with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA 02111-1307, USA.
22 
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.
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 DEFINITIONS
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51 
52 #define ID_LGEAR "$Id: FGLGear.h,v 1.65 2016/05/16 18:19:57 bcoconni Exp $"
53 
54 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 FORWARD DECLARATIONS
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57 
58 namespace JSBSim {
59 
60 class FGTable;
61 class Element;
62 class FGPropertyManager;
63 
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 CLASS DOCUMENTATION
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 
190 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
191 CLASS DECLARATION
192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
193 
194 class FGLGear : protected FGSurface, public FGForce
195 {
196 public:
197  struct Inputs {
198  double Vground;
199  double VcalibratedKts;
200  double Temperature;
201  double DistanceAGL;
202  double DistanceASL;
203  double TotalDeltaT;
204  bool TakeoffThrottle;
205  bool WOW;
206  FGMatrix33 Tb2l;
207  FGMatrix33 Tec2l;
208  FGMatrix33 Tec2b;
209  FGColumnVector3 PQR;
210  FGColumnVector3 UVW;
211  FGColumnVector3 vXYZcg; // CG coordinates expressed in the structural frame
212  FGLocation Location;
213  std::vector <double> BrakePos;
214  double FCSGearPos;
215  double EmptyWeight;
216  };
217 
219  enum BrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail, bgNumBrakeGroups };
221  enum SteerType {stSteer, stFixed, stCaster};
223  enum ContactType {ctBOGEY, ctSTRUCTURE};
225  enum ReportType {erNone=0, erTakeoff, erLand};
227  enum DampType {dtLinear=0, dtSquare};
229  enum FrictionType {ftRoll=0, ftSide, ftDynamic};
235  FGLGear(Element* el, FGFDMExec* Executive, int number, const struct Inputs& input);
237  ~FGLGear();
238 
242  const FGColumnVector3& GetBodyForces(FGSurface *surface = NULL);
243 
246  return Ts2b * (vXYZn - in.vXYZcg);
247  }
248  double GetBodyLocation(int idx) const {
249  FGColumnVector3 vWhlBodyVec = Ts2b * (vXYZn - in.vXYZcg);
250  return vWhlBodyVec(idx);
251  }
252 
253  const FGColumnVector3& GetLocalGear(void) const { return vLocalGear; }
254  double GetLocalGear(int idx) const { return vLocalGear(idx); }
255 
257  const std::string& GetName(void) const {return name; }
259  bool GetWOW(void) const {return WOW; }
261  double GetCompLen(void) const {return compressLength;}
263  double GetCompVel(void) const {return compressSpeed; }
265  double GetCompForce(void) const {return StrutForce; }
266 
268  void SetWOW(bool wow) {WOW = wow;}
269 
272  void SetReport(bool flag) { ReportEnable = flag; }
275  bool GetReport(void) const { return ReportEnable; }
276  double GetSteerNorm(void) const { return radtodeg/maxSteerAngle*SteerAngle; }
277  void SetSteerCmd(double cmd) { SetSteerAngleDeg(cmd * maxSteerAngle); }
278  double GetstaticFCoeff(void) const { return staticFCoeff; }
279 
280  int GetBrakeGroup(void) const { return (int)eBrakeGrp; }
281  int GetSteerType(void) const { return (int)eSteerType; }
282 
283  bool GetSteerable(void) const { return eSteerType != stFixed; }
284  bool GetRetractable(void) const { return isRetractable; }
285  bool GetGearUnitUp(void) const { return isRetractable ? (GetGearUnitPos() < 0.01) : false; }
286  bool GetGearUnitDown(void) const { return isRetractable ? (GetGearUnitPos() > 0.99) : true; }
287 
288  double GetWheelRollForce(void) {
289  UpdateForces();
290  FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces();
291  return vForce(eX)*cos(SteerAngle) + vForce(eY)*sin(SteerAngle); }
292  double GetWheelSideForce(void) {
293  UpdateForces();
294  FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces();
295  return vForce(eY)*cos(SteerAngle) - vForce(eX)*sin(SteerAngle); }
296  double GetBodyXForce(void) {
297  UpdateForces();
298  return FGForce::GetBodyForces()(eX);
299  }
300  double GetBodyYForce(void) {
301  UpdateForces();
302  return FGForce::GetBodyForces()(eY);
303  }
304  double GetBodyZForce(void) {
305  UpdateForces();
306  return FGForce::GetBodyForces()(eZ);
307  }
308  double GetWheelRollVel(void) const { return vWhlVelVec(eX)*cos(SteerAngle)
309  + vWhlVelVec(eY)*sin(SteerAngle); }
310  double GetWheelSideVel(void) const { return vWhlVelVec(eY)*cos(SteerAngle)
311  - vWhlVelVec(eX)*sin(SteerAngle); }
312  double GetWheelSlipAngle(void) const { return WheelSlip; }
313  double GetWheelVel(int axis) const { return vWhlVelVec(axis);}
314  bool IsBogey(void) const { return (eContactType == ctBOGEY);}
315  double GetGearUnitPos(void) const;
316  double GetSteerAngleDeg(void) const { return radtodeg*SteerAngle; }
317  void SetSteerAngleDeg(double angle) {
318  if (eSteerType != stFixed && !Castered)
319  SteerAngle = degtorad * angle;
320  }
321 
322  const struct Inputs& in;
323 
324  void ResetToIC(void);
325  void bind(void);
326 
327 private:
328  int GearNumber;
329  static const FGMatrix33 Tb2s, Ts2b;
330  FGMatrix33 mTGear;
331  FGColumnVector3 vLocalGear;
332  FGColumnVector3 vWhlVelVec, vGroundWhlVel; // Velocity of this wheel
333  FGColumnVector3 vGroundNormal;
334  FGTable *ForceY_Table;
335  FGFunction *fStrutForce;
336  double SteerAngle;
337  double kSpring;
338  double bDamp;
339  double bDampRebound;
340  double compressLength;
341  double compressSpeed;
342  double rollingFCoeff;
343  double Stiffness, Shape, Peak, Curvature; // Pacejka factors
344  double BrakeFCoeff;
345  double maxCompLen;
346  double SinkRate;
347  double GroundSpeed;
348  double TakeoffDistanceTraveled;
349  double TakeoffDistanceTraveled50ft;
350  double LandingDistanceTraveled;
351  double MaximumStrutForce, StrutForce;
352  double MaximumStrutTravel;
353  double FCoeff;
354  double WheelSlip;
355  double GearPos;
356  bool WOW;
357  bool lastWOW;
358  bool FirstContact;
359  bool StartedGroundRun;
360  bool LandingReported;
361  bool TakeoffReported;
362  bool ReportEnable;
363  bool isRetractable;
364  bool Castered;
365  bool StaticFriction;
366  std::string name;
367 
368  BrakeGroup eBrakeGrp;
369  ContactType eContactType;
370  SteerType eSteerType;
371  DampType eDampType;
372  DampType eDampTypeRebound;
373  double maxSteerAngle;
374 
375  LagrangeMultiplier LMultiplier[3];
376 
377  FGGroundReactions* GroundReactions;
378  FGPropertyManager* PropertyManager;
379 
380  mutable bool useFCSGearPos;
381 
382  void ComputeBrakeForceCoefficient(void);
383  void ComputeSteeringAngle(void);
384  void ComputeSlipAngle(void);
385  void ComputeSideForceCoefficient(void);
386  void ComputeVerticalStrutForce(void);
387  void ComputeGroundFrame(void);
388  void ComputeJacobian(const FGColumnVector3& vWhlContactVec);
389  void UpdateForces(void);
390  void SetstaticFCoeff(double coeff);
391  void CrashDetect(void);
392  void InitializeReporting(void);
393  void ResetReporting(void);
394  void ReportTakeoffOrLanding(void);
395  void Report(ReportType rt);
396  void Debug(int from);
397 };
398 }
399 
400 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
401 
402 #endif
ReportType
Report type enumerators.
Definition: FGLGear.h:225
FGColumnVector3 GetBodyLocation(void) const
Gets the location of the gear in Body axes.
Definition: FGLGear.h:245
ContactType
Contact point type.
Definition: FGLGear.h:223
FGLGear(Element *el, FGFDMExec *Executive, int number, const struct Inputs &input)
Constructor.
Definition: FGLGear.cpp:76
double GetCompLen(void) const
Gets the current compressed length of the gear in feet.
Definition: FGLGear.h:261
BrakeGroup
Brake grouping enumerators.
Definition: FGLGear.h:219
FrictionType
Friction types.
Definition: FGLGear.h:229
double GetCompVel(void) const
Gets the current gear compression velocity in ft/sec.
Definition: FGLGear.h:263
FGLocation holds an arbitrary location in the Earth centered Earth fixed reference frame (ECEF)...
Definition: FGLocation.h:160
void SetWOW(bool wow)
Sets the weight-on-wheels flag.
Definition: FGLGear.h:268
const std::string & GetName(void) const
Gets the name of the gear.
Definition: FGLGear.h:257
bool GetReport(void) const
Get the console touchdown reporting feature.
Definition: FGLGear.h:275
Represents a mathematical function.
Definition: FGFunction.h:699
SteerType
Steering group membership enumerators.
Definition: FGLGear.h:221
This class implements a 3 element column vector.
Manages ground reactions modeling.
Handles matrix math operations.
Definition: FGMatrix33.h:92
double GetCompForce(void) const
Gets the gear compression force in pounds.
Definition: FGLGear.h:265
DampType
Damping types.
Definition: FGLGear.h:227
Base class for all surface properties.
Definition: FGSurface.h:67
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189
Utility class that aids in the conversion of forces between coordinate systems and calculation of mom...
Definition: FGForce.h:225
Lookup table class.
Definition: FGTable.h:243
void SetReport(bool flag)
Set the console touchdown reporting feature.
Definition: FGLGear.h:272
bool GetWOW(void) const
Gets the Weight On Wheels flag value.
Definition: FGLGear.h:259
~FGLGear()
Destructor.
Definition: FGLGear.cpp:238
Landing gear model.
Definition: FGLGear.h:194