]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGLGear.h
sync with JSB JSBSim CVS
[flightgear.git] / src / FDM / JSBSim / models / FGLGear.h
index a62549f2899e42157c6b31fa53f44fb179a83dab..c2d38a0c4843034ec20da9bc3bd3f73a7c152c6c 100644 (file)
@@ -4,7 +4,7 @@
  Author:       Jon S. Berndt
  Date started: 11/18/99
 
- ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 1999  Jon S. Berndt (jon@jsbsim.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU Lesser General Public License as published by the Free Software
@@ -38,18 +38,17 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include <FGJSBBase.h>
-#include <FGFDMExec.h>
-#include <input_output/FGXMLElement.h>
-#include <math/FGColumnVector3.h>
-#include <math/FGTable.h>
 #include <string>
 
+#include "models/propulsion/FGForce.h"
+#include "math/FGColumnVector3.h"
+#include "math/LagrangeMultiplier.h"
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_LGEAR "$Id$"
+#define ID_LGEAR "$Id: FGLGear.h,v 1.54 2012/04/01 17:05:51 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -57,12 +56,9 @@ FORWARD DECLARATIONS
 
 namespace JSBSim {
 
-class FGAircraft;
-class FGPropagate;
-class FGFCS;
-class FGState;
-class FGMassBalance;
-class FGAuxiliary;
+class FGTable;
+class Element;
+class FGPropertyManager;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DOCUMENTATION
@@ -85,7 +81,6 @@ CLASS DOCUMENTATION
     <h3>Operational Properties</h3>
     <ol>
     <li>Name</li>
-    <li>Steerability attribute {one of STEERABLE | FIXED | CASTERED}</li>
     <li>Brake Group Membership {one of LEFT | CENTER | RIGHT | NOSE | TAIL | NONE}</li>
     <li>Max Steer Angle, in degrees</li>
     </ol></p>
@@ -163,30 +158,26 @@ CLASS DOCUMENTATION
                 <y> {number} </y>
                 <z> {number} </z>
             </location>
+            <orientation unit="{RAD | DEG}">
+                <pitch> {number} </pitch>
+                <roll> {number} </roll>
+                <yaw> {number} </yaw>
+            </orientation>
             <static_friction> {number} </static_friction>
             <dynamic_friction> {number} </dynamic_friction>
             <rolling_friction> {number} </rolling_friction>
             <spring_coeff unit="{LBS/FT | N/M}"> {number} </spring_coeff>
-            <damping_coeff unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff>
-            <damping_coeff_rebound unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff_rebound>
+            <damping_coeff [type="SQUARE"] unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff>
+            <damping_coeff_rebound [type="SQUARE"] unit="{LBS/FT/SEC | N/M/SEC}"> {number} </damping_coeff_rebound>
             <max_steer unit="DEG"> {number | 0 | 360} </max_steer>
             <brake_group> {NONE | LEFT | RIGHT | CENTER | NOSE | TAIL} </brake_group>
             <retractable>{0 | 1}</retractable>
             <table type="{CORNERING_COEFF}">
             </table>
-            <relaxation_velocity>
-               <rolling unit="{FT/SEC | KTS | M/S}"> {number} </rolling>
-               <side unit="{FT/SEC | KTS | M/S}"> {number} </side>
-            </relaxation_velocity>
-            <force_lag_filter>
-               <rolling> {number} </rolling>
-               <side> {number} </side>
-            </force_lag_filter>
-            <wheel_slip_filter> {number} </wheel_slip_filter>  
         </contact>
 @endcode
     @author Jon S. Berndt
-    @version $Id$
+    @version $Id: FGLGear.h,v 1.54 2012/04/01 17:05:51 bcoconni Exp $
     @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
      NASA-Ames", NASA CR-2497, January 1975
     @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
@@ -199,110 +190,129 @@ CLASS DOCUMENTATION
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGLGear : public FGJSBBase
+class FGLGear : public FGForce
 {
 public:
+  struct Inputs {
+    double Vground;
+    double VcalibratedKts;
+    double Temperature;
+    double DistanceAGL;
+    double DistanceASL;
+    double TotalDeltaT;
+    bool TakeoffThrottle;
+    bool WOW;
+    FGMatrix33 Tb2l;
+    FGMatrix33 Tec2l;
+    FGMatrix33 Tec2b;
+    FGColumnVector3 PQR;
+    FGColumnVector3 UVW;
+    FGColumnVector3 vXYZcg; // CG coordinates expressed in the structural frame
+    FGLocation Location;
+    std::vector <double> SteerPosDeg;
+    std::vector <double> BrakePos;
+    double FCSGearPos;
+    double EmptyWeight;
+  };
+
   /// Brake grouping enumerators
-  enum BrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail };
+  enum BrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail, bgNumBrakeGroups };
   /// Steering group membership enumerators
   enum SteerType {stSteer, stFixed, stCaster};
   /// Contact point type
-  enum ContactType {ctBOGEY, ctSTRUCTURE, ctUNKNOWN};
+  enum ContactType {ctBOGEY, ctSTRUCTURE};
   /// Report type enumerators
   enum ReportType {erNone=0, erTakeoff, erLand};
   /// Damping types
   enum DampType {dtLinear=0, dtSquare};
+  /// Friction types
+  enum FrictionType {ftRoll=0, ftSide, ftDynamic};
   /** Constructor
       @param el a pointer to the XML element that contains the CONTACT info.
       @param Executive a pointer to the parent executive object
       @param number integer identifier for this instance of FGLGear
   */
-  FGLGear(Element* el, FGFDMExec* Executive, int number);
+  FGLGear(Element* el, FGFDMExec* Executive, int number, const struct Inputs& input);
   /// Destructor
   ~FGLGear();
 
   /// The Force vector for this gear
-  FGColumnVector3& Force(void);
-  /// The Moment vector for this gear
-  FGColumnVector3& Moment(void) {return vMoment;}
+  const FGColumnVector3& GetBodyForces(void);
 
   /// Gets the location of the gear in Body axes
-  FGColumnVector3& GetBodyLocation(void) { return vWhlBodyVec; }
-  double GetBodyLocation(int idx) const { return vWhlBodyVec(idx); }
-
-  FGColumnVector3& GetLocalGear(void) { return vLocalGear; }
+  FGColumnVector3 GetBodyLocation(void) const {
+    return Ts2b * (vXYZn - in.vXYZcg);
+  }
+  double GetBodyLocation(int idx) const {
+    FGColumnVector3 vWhlBodyVec = Ts2b * (vXYZn - in.vXYZcg);
+    return vWhlBodyVec(idx);
+  }
+
+  const FGColumnVector3& GetLocalGear(void) const { return vLocalGear; }
   double GetLocalGear(int idx) const { return vLocalGear(idx); }
 
   /// Gets the name of the gear
-  inline string GetName(void) const {return name;          }
+  const string& GetName(void) const {return name; }
   /// Gets the Weight On Wheels flag value
-  inline bool   GetWOW(void) const {return WOW;           }
+  bool    GetWOW(void) const {return WOW; }
   /// Gets the current compressed length of the gear in feet
-  inline double  GetCompLen(void) const {return compressLength;}
+  double  GetCompLen(void) const {return compressLength;}
   /// Gets the current gear compression velocity in ft/sec
-  inline double  GetCompVel(void) const {return compressSpeed; }
+  double  GetCompVel(void) const {return compressSpeed; }
   /// Gets the gear compression force in pounds
-  inline double  GetCompForce(void) const {return vForce(eZ);    }
-  inline double  GetBrakeFCoeff(void) const {return BrakeFCoeff;}
-
-  /// Gets the current normalized tire pressure
-  inline double  GetTirePressure(void) const { return TirePressureNorm; }
-  /// Sets the new normalized tire pressure
-  inline void    SetTirePressure(double p) { TirePressureNorm = p; }
-
-  /// Sets the brake value in percent (0 - 100)
-  inline void SetBrake(double bp) {brakePct = bp;}
+  double  GetCompForce(void) const {return StrutForce;   }
 
   /// Sets the weight-on-wheels flag.
   void SetWOW(bool wow) {WOW = wow;}
 
   /** Set the console touchdown reporting feature
       @param flag true turns on touchdown reporting, false turns it off */
-  inline void SetReport(bool flag) { ReportEnable = flag; }
+  void SetReport(bool flag) { ReportEnable = flag; }
   /** Get the console touchdown reporting feature
       @return true if reporting is turned on */
-  inline bool GetReport(void) const  { return ReportEnable; }
-  double GetSteerNorm(void) const    { return radtodeg/maxSteerAngle*SteerAngle; }
+  bool GetReport(void) const  { return ReportEnable; }
+  double GetSteerNorm(void) const { return radtodeg/maxSteerAngle*SteerAngle; }
   double GetDefaultSteerAngle(double cmd) const { return cmd*maxSteerAngle; }
   double GetstaticFCoeff(void) const { return staticFCoeff; }
 
-  inline int GetBrakeGroup(void) const { return (int)eBrakeGrp; }
-  inline int GetSteerType(void) const  { return (int)eSteerType; }
-
-  inline double GetZPosition(void) const { return vXYZ(3); }
-  inline void SetZPosition(double z) { vXYZ(3) = z; }
-
-  bool GetSteerable(void) const { return eSteerType != stFixed; }
-  inline bool GetRetractable(void) const      { return isRetractable;   }
-  inline bool GetGearUnitUp(void) const       { return GearUp;          }
-  inline bool GetGearUnitDown(void) const     { return GearDown;        }
-  inline double GetWheelSideForce(void) const { return SideForce;       }
-  inline double GetWheelRollForce(void) const { return RollingForce;    }
-  inline double GetWheelSideVel(void) const   { return SideWhlVel;      }
-  inline double GetWheelRollVel(void) const   { return RollingWhlVel;   }
-  inline double GetBodyXForce(void) const     { return vLocalForce(eX); }
-  inline double GetBodyYForce(void) const     { return vLocalForce(eY); }
-  inline double GetWheelSlipAngle(void) const { return WheelSlip;       }
-  double GetWheelVel(int axis) const          { return vWhlVelVec(axis);}
-  bool IsBogey(void) const                    { return (eContactType == ctBOGEY);}
-  double GetGearUnitPos(void);
+  int  GetBrakeGroup(void) const   { return (int)eBrakeGrp; }
+  int  GetSteerType(void) const    { return (int)eSteerType; }
+
+  bool GetSteerable(void) const    { return eSteerType != stFixed; }
+  bool GetRetractable(void) const  { return isRetractable;   }
+  bool GetGearUnitUp(void) const   { return isRetractable ? (GetGearUnitPos() < 0.01) : false; }
+  bool GetGearUnitDown(void) const { return isRetractable ? (GetGearUnitPos() > 0.99) : true; }
+
+  double GetWheelRollForce(void) {
+    UpdateForces();
+    FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces();
+    return vForce(eX)*cos(SteerAngle) + vForce(eY)*sin(SteerAngle); }
+  double GetWheelSideForce(void) {
+    UpdateForces();
+    FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces();
+    return vForce(eY)*cos(SteerAngle) - vForce(eX)*sin(SteerAngle); }
+  double GetWheelRollVel(void) const   { return vWhlVelVec(eX)*cos(SteerAngle)
+                                              + vWhlVelVec(eY)*sin(SteerAngle);  }
+  double GetWheelSideVel(void) const   { return vWhlVelVec(eY)*cos(SteerAngle)
+                                              - vWhlVelVec(eX)*sin(SteerAngle);  }
+  double GetWheelSlipAngle(void) const { return WheelSlip;       }
+  double GetWheelVel(int axis) const   { return vWhlVelVec(axis);}
+  bool IsBogey(void) const             { return (eContactType == ctBOGEY);}
+  double GetGearUnitPos(void) const;
+  double GetSteerAngleDeg(void) const { return radtodeg*SteerAngle; }
+
+  const struct Inputs& in;
 
   void bind(void);
 
 private:
   int GearNumber;
-  FGColumnVector3 vXYZ;
-  FGColumnVector3 vMoment;
-  FGColumnVector3 vWhlBodyVec;
+  static const FGMatrix33 Tb2s, Ts2b;
+  FGMatrix33 mTGear;
   FGColumnVector3 vLocalGear;
-  FGColumnVector3 vForce;
-  FGColumnVector3 last_vForce; // remove this
-  FGColumnVector3 vLocalForce;
-  FGColumnVector3 vWhlVelVec;     // Velocity of this wheel (Local)
-  FGColumnVector3 normal, cvel;
-  FGLocation contact, gearLoc;
+  FGColumnVector3 vWhlVelVec, vGroundWhlVel;     // Velocity of this wheel
+  FGColumnVector3 vGroundNormal;
   FGTable *ForceY_Table;
-  double dT;
   double SteerAngle;
   double kSpring;
   double bDamp;
@@ -311,7 +321,6 @@ private:
   double compressSpeed;
   double staticFCoeff, dynamicFCoeff, rollingFCoeff;
   double Stiffness, Shape, Peak, Curvature; // Pacejka factors
-  double brakePct;
   double BrakeFCoeff;
   double maxCompLen;
   double SinkRate;
@@ -319,15 +328,11 @@ private:
   double TakeoffDistanceTraveled;
   double TakeoffDistanceTraveled50ft;
   double LandingDistanceTraveled;
-  double MaximumStrutForce;
+  double MaximumStrutForce, StrutForce;
   double MaximumStrutTravel;
-  double SideWhlVel, RollingWhlVel;
-  double RollingForce, SideForce, FCoeff;
+  double FCoeff;
   double WheelSlip;
-  double TirePressureNorm;
-  double SinWheel, CosWheel;
   double GearPos;
-  bool   useFCSGearPos;
   bool WOW;
   bool lastWOW;
   bool FirstContact;
@@ -336,13 +341,9 @@ private:
   bool TakeoffReported;
   bool ReportEnable;
   bool isRetractable;
-  bool GearUp, GearDown;
-  bool Servicable;
-  string name;
-  string sSteerType;
-  string sBrakeGroup;
-  string sRetractable;
-  string sContactType;
+  bool Castered;
+  bool StaticFriction;
+  std::string name;
 
   BrakeGroup  eBrakeGrp;
   ContactType eContactType;
@@ -350,30 +351,22 @@ private:
   DampType    eDampType;
   DampType    eDampTypeRebound;
   double  maxSteerAngle;
-  double RFRV;  // Rolling force relaxation velocity
-  double SFRV;  // Side force relaxation velocity
-  double LongForceLagFilterCoeff; // Longitudinal Force Lag Filter Coefficient
-  double LatForceLagFilterCoeff; // Lateral Force Lag Filter Coefficient
-  double WheelSlipLagFilterCoeff; // Wheel slip angle lag filter coefficient
-
-  Filter LongForceFilter;
-  Filter LatForceFilter;
-  Filter WheelSlipFilter;
-
-  FGFDMExec*     Exec;
-  FGState*       State;
-  FGAircraft*    Aircraft;
-  FGPropagate*   Propagate;
-  FGAuxiliary*   Auxiliary;
-  FGFCS*         FCS;
-  FGMassBalance* MassBalance;
-
-  void ComputeRetractionState(void);
+
+  LagrangeMultiplier LMultiplier[3];
+
+  FGGroundReactions* GroundReactions;
+  FGPropertyManager* PropertyManager;
+
+  mutable bool useFCSGearPos;
+
   void ComputeBrakeForceCoefficient(void);
   void ComputeSteeringAngle(void);
   void ComputeSlipAngle(void);
   void ComputeSideForceCoefficient(void);
   void ComputeVerticalStrutForce(void);
+  void ComputeGroundFrame(void);
+  void ComputeJacobian(const FGColumnVector3& vWhlContactVec);
+  void UpdateForces(void);
   void CrashDetect(void);
   void InitializeReporting(void);
   void ResetReporting(void);
@@ -382,12 +375,6 @@ private:
   void Debug(int from);
 };
 }
-#include "FGAircraft.h"
-#include "FGPropagate.h"
-#include "FGAuxiliary.h"
-#include "FGFCS.h"
-#include "FGMassBalance.h"
-#include "FGState.h"
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%