]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGLGear.h
Merge branch 'next' of git://gitorious.org/fg/flightgear into next
[flightgear.git] / src / FDM / JSBSim / models / FGLGear.h
index 95b1d11d27a351a642fb3cab9f43f704ca97dd32..f1828f8cf840b17c4c7ffebc6ea90ac5022d8fec 100644 (file)
@@ -4,23 +4,23 @@
  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 General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.
 
  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  Place - Suite 330, Boston, MA  02111-1307, USA.
 
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -38,22 +38,16 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#ifdef FGFS
-#  include <simgear/compiler.h>
-#endif
-
-#include <FGJSBBase.h>
-#include <FGFDMExec.h>
-#include <input_output/FGXMLElement.h>
-#include <math/FGColumnVector3.h>
-#include <math/FGTable.h>
+#include "models/propulsion/FGForce.h"
+#include "models/FGPropagate.h"
+#include "math/FGColumnVector3.h"
 #include <string>
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_LGEAR "$Id$"
+#define ID_LGEAR "$Id: FGLGear.h,v 1.41 2010/09/22 11:33:40 jberndt Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -64,9 +58,10 @@ namespace JSBSim {
 class FGAircraft;
 class FGPropagate;
 class FGFCS;
-class FGState;
 class FGMassBalance;
 class FGAuxiliary;
+class FGTable;
+class Element;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DOCUMENTATION
@@ -78,7 +73,7 @@ CLASS DOCUMENTATION
     are the parameters that can be specified in the config file for modeling
     landing gear:
     <p>
-    <b><u>Physical Characteristics</u></b><br>
+    <h3>Physical Characteristics</h3>
     <ol>
     <li>X, Y, Z location, in inches in structural coordinate frame</li>
     <li>Spring constant, in lbs/ft</li>
@@ -86,15 +81,14 @@ CLASS DOCUMENTATION
     <li>Dynamic Friction Coefficient</li>
     <li>Static Friction Coefficient</li>
     </ol></p><p>
-    <b><u>Operational Properties</b></u><br>
+    <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>
     <p>
-    <b><u>Algorithm and Approach to Modeling</u></b><br>
+    <h3>Algorithm and Approach to Modeling</h3>
     <ol>
     <li>Find the location of the uncompressed landing gear relative to the CG of
     the aircraft. Remember, the structural coordinate frame that the aircraft is
@@ -158,8 +152,35 @@ CLASS DOCUMENTATION
     (radius to wheel crossed into the wheel force). Both of these operands are
     in body frame.</li>
     </ol>
+
+    <h3>Configuration File Format:</h3>
+@code
+        <contact type="{BOGEY | STRUCTURE}" name="{string}">
+            <location unit="{IN | M}">
+                <x> {number} </x>
+                <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 [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>
+        </contact>
+@endcode
     @author Jon S. Berndt
-    @version $Id$
+    @version $Id: FGLGear.h,v 1.41 2010/09/22 11:33:40 jberndt 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",
@@ -172,102 +193,113 @@ CLASS DOCUMENTATION
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGLGear : public FGJSBBase
+class FGLGear : public FGForce
 {
 public:
   /// Brake grouping enumerators
   enum BrakeGroup {bgNone=0, bgLeft, bgRight, bgCenter, bgNose, bgTail };
   /// Steering group membership enumerators
   enum SteerType {stSteer, stFixed, stCaster};
+  /// Contact point type
+  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 File a pointer to the config file instance */
+      @param number integer identifier for this instance of FGLGear
+  */
   FGLGear(Element* el, FGFDMExec* Executive, int number);
-  /** Constructor
-      @param lgear a reference to an existing FGLGear object     */
-  FGLGear(const FGLGear& lgear);
   /// Destructor
   ~FGLGear();
 
-
   /// The Force vector for this gear
-  FGColumnVector3& Force(void);
-  /// The Moment vector for this gear
-  FGColumnVector3& Moment(void) {return vMoment;}
+  FGColumnVector3& GetBodyForces(void);
 
   /// Gets the location of the gear in Body axes
   FGColumnVector3& GetBodyLocation(void) { return vWhlBodyVec; }
-  double GetBodyLocation(int idx) { return vWhlBodyVec(idx); }
+  double GetBodyLocation(int idx) const { return vWhlBodyVec(idx); }
 
   FGColumnVector3& GetLocalGear(void) { return vLocalGear; }
-  double GetLocalGear(int idx) { return vLocalGear(idx); }
+  double GetLocalGear(int idx) const { return vLocalGear(idx); }
 
   /// Gets the name of the gear
-  inline string GetName(void)      {return name;          }
+  string GetName(void) const {return name;          }
   /// Gets the Weight On Wheels flag value
-  inline bool   GetWOW(void)       {return WOW;           }
+  bool   GetWOW(void) const {return WOW;           }
   /// Gets the current compressed length of the gear in feet
-  inline double  GetCompLen(void)   {return compressLength;}
+  double  GetCompLen(void) const {return compressLength;}
   /// Gets the current gear compression velocity in ft/sec
-  inline double  GetCompVel(void)   {return compressSpeed; }
+  double  GetCompVel(void) const {return compressSpeed; }
   /// Gets the gear compression force in pounds
-  inline double  GetCompForce(void) {return Force()(3);    }
-  inline double  GetBrakeFCoeff(void) {return BrakeFCoeff;}
+  double  GetCompForce(void) const {return StrutForce;   }
+  double  GetBrakeFCoeff(void) const {return BrakeFCoeff;}
 
   /// Gets the current normalized tire pressure
-  inline double  GetTirePressure(void) { return TirePressureNorm; }
+  double  GetTirePressure(void) const { return TirePressureNorm; }
   /// Sets the new normalized tire pressure
-  inline void    SetTirePressure(double p) { TirePressureNorm = p; }
+  void    SetTirePressure(double p) { TirePressureNorm = p; }
 
   /// Sets the brake value in percent (0 - 100)
-  inline void SetBrake(double bp) {brakePct = bp;}
+  void SetBrake(double bp) {brakePct = bp;}
+
+  /// 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)    { 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) { return staticFCoeff; }
-
-  inline int GetBrakeGroup(void) { return (int)eBrakeGrp; }
-  inline int GetSteerType(void)  { return (int)eSteerType; }
-
-  bool GetSteerable(void) const { return eSteerType != stFixed; }
-  inline bool GetRetractable(void)         { return isRetractable;   }
-  inline bool GetGearUnitUp(void)          { return GearUp;          }
-  inline bool GetGearUnitDown(void)        { return GearDown;        }
-  inline double GetWheelSideForce(void)    { return SideForce;       }
-  inline double GetWheelRollForce(void)    { return RollingForce;    }
-  inline double GetBodyXForce(void)        { return vLocalForce(eX); }
-  inline double GetBodyYForce(void)        { return vLocalForce(eY); }
-  inline double GetWheelSlipAngle(void)    { return WheelSlip;       }
-  double GetWheelVel(int axis)             { return vWhlVelVec(axis);}
-
-  bool IsBogey(void) {return (sContactType == string("BOGEY"));}
+  double GetstaticFCoeff(void) const { return staticFCoeff; }
+
+  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 GearUp;          }
+  bool GetGearUnitDown(void) const     { return GearDown;        }
+  double GetWheelRollForce(void) {
+    FGColumnVector3 vForce = mTGear.Transposed() * FGForce::GetBodyForces();
+    return vForce(eX)*cos(SteerAngle) + vForce(eY)*sin(SteerAngle); }
+  double GetWheelSideForce(void) {
+    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);
+  double GetSteerAngleDeg(void) const { return radtodeg*SteerAngle; }
+  FGPropagate::LagrangeMultiplier* GetMultiplierEntry(int entry);
+  void SetLagrangeMultiplier(double lambda, int entry);
+  FGColumnVector3& UpdateForces(void);
 
   void bind(void);
-  void unbind(void);
 
 private:
   int GearNumber;
-  FGColumnVector3 vXYZ;
-  FGColumnVector3 vMoment;
+  static const FGMatrix33 Tb2s;
+  FGMatrix33 mTGear;
+  FGColumnVector3 vGearOrient;
   FGColumnVector3 vWhlBodyVec;
   FGColumnVector3 vLocalGear;
-  FGColumnVector3 vForce;
-  FGColumnVector3 last_vForce; // remove this
-  FGColumnVector3 vLocalForce;
-  FGColumnVector3 vWhlVelVec;     // Velocity of this wheel (Local)
-  FGColumnVector3 In;
-  FGColumnVector3 prevIn;
-  FGColumnVector3 prevOut;
+  FGColumnVector3 vWhlVelVec, vLocalWhlVel;     // Velocity of this wheel
+  FGColumnVector3 normal, cvel, vGroundNormal;
+  FGLocation contact, gearLoc;
   FGTable *ForceY_Table;
+  double dT;
   double SteerAngle;
   double kSpring;
   double bDamp;
@@ -275,6 +307,7 @@ private:
   double compressLength;
   double compressSpeed;
   double staticFCoeff, dynamicFCoeff, rollingFCoeff;
+  double Stiffness, Shape, Peak, Curvature; // Pacejka factors
   double brakePct;
   double BrakeFCoeff;
   double maxCompLen;
@@ -283,16 +316,13 @@ 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 last_WheelSlip;
-  double slipIn;
-  double last_SlipIn;
   double TirePressureNorm;
-  double SinWheel, CosWheel;
+  double GearPos;
+  bool   useFCSGearPos;
   bool WOW;
   bool lastWOW;
   bool FirstContact;
@@ -303,23 +333,28 @@ private:
   bool isRetractable;
   bool GearUp, GearDown;
   bool Servicable;
-  string name;
-  string sSteerType;
-  string sBrakeGroup;
-  string sRetractable;
-  string sContactType;
-
-  BrakeGroup eBrakeGrp;
-  SteerType  eSteerType;
+  bool Castered;
+  bool StaticFriction;
+  std::string name;
+  std::string sSteerType;
+  std::string sBrakeGroup;
+  std::string sRetractable;
+  std::string sContactType;
+
+  BrakeGroup  eBrakeGrp;
+  ContactType eContactType;
+  SteerType   eSteerType;
+  DampType    eDampType;
+  DampType    eDampTypeRebound;
   double  maxSteerAngle;
 
-  FGFDMExec*     Exec;
-  FGState*       State;
-  FGAircraft*    Aircraft;
-  FGPropagate*   Propagate;
-  FGAuxiliary*   Auxiliary;
-  FGFCS*         FCS;
-  FGMassBalance* MassBalance;
+  FGPropagate::LagrangeMultiplier LMultiplier[3];
+
+  FGAuxiliary*       Auxiliary;
+  FGPropagate*       Propagate;
+  FGFCS*             FCS;
+  FGMassBalance*     MassBalance;
+  FGGroundReactions* GroundReactions;
 
   void ComputeRetractionState(void);
   void ComputeBrakeForceCoefficient(void);
@@ -327,6 +362,8 @@ private:
   void ComputeSlipAngle(void);
   void ComputeSideForceCoefficient(void);
   void ComputeVerticalStrutForce(void);
+  void ComputeGroundCoordSys(void);
+  void ComputeJacobian(const FGColumnVector3& vWhlContactVec);
   void CrashDetect(void);
   void InitializeReporting(void);
   void ResetReporting(void);
@@ -335,12 +372,6 @@ private:
   void Debug(int from);
 };
 }
-#include "FGAircraft.h"
-#include "FGPropagate.h"
-#include "FGAuxiliary.h"
-#include "FGFCS.h"
-#include "FGMassBalance.h"
-#include "FGState.h"
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%