]> git.mxchange.org Git - flightgear.git/commitdiff
Bertrand Coconnier:
authorehofman <ehofman>
Mon, 31 Aug 2009 07:06:26 +0000 (07:06 +0000)
committerTim Moore <timoore@redhat.com>
Wed, 2 Sep 2009 22:02:48 +0000 (00:02 +0200)
Additionally to the original fix (problem with the Tec2b matrix initialization) I have modified the code for the "STRUCTURE" contacts in order not to generate NaNs when the z direction of the body frame is normal to the ground normal. Now there should no longer be any NaN generated by the landing gear code.

src/FDM/JSBSim/models/FGLGear.cpp
src/FDM/JSBSim/models/FGPropagate.cpp

index c7a7534c7d1e84dd7f4bd735bd8576725847086e..e3cfeadf21f44c6eed4f0fa465332458e9b7c55b 100644 (file)
@@ -392,19 +392,37 @@ FGColumnVector3& FGLGear::Force(void)
 
 void FGLGear::ComputeGroundCoordSys(void)
 {
-  // Compute the rolling direction projected on the ground
-  // It consists in finding a vector 'r' such that 'r' lies in the plane (w,z) and r.n = 0 (scalar
-  // product) where:
-  // 'n' is the normal to the ground,
-  // (x,y,z) are the directions defined in the body coord system
-  // and 'w' is 'x' rotated by the steering angle (SteerAngle) in the plane (x,y). 
-  // r = u * w + v * z and r.n = 0 => v/u = -w.n/z.n = a
-  // We also want u**2+v**2=1 and u > 0 (i.e. r orientated in the same 'direction' than w)
-  // after some arithmetic, one finds that :
-  double a = -(vGroundNormal(eX)*cos(SteerAngle)+vGroundNormal(eY)*sin(SteerAngle)) / vGroundNormal(eZ);
-  double u = 1. / sqrt(1. + a*a);
-  double v = a * u;
-  FGColumnVector3 vRollingGroundVec = FGColumnVector3(u * cos(SteerAngle), u * sin(SteerAngle), v);
+  FGColumnVector3 vRollingGroundVec;
+
+  if (eContactType == ctBOGEY) {
+    // Compute the rolling direction projected on the ground
+    // It consists in finding a vector 'r' such that 'r' lies in the plane (w,z) and r.n = 0 (scalar
+    // product) where:
+    // 'n' is the normal to the ground,
+    // (x,y,z) are the directions defined in the body coord system
+    // and 'w' is 'x' rotated by the steering angle (SteerAngle) in the plane (x,y). 
+    // r = u * w + v * z and r.n = 0 => v/u = -w.n/z.n = a
+    // We also want u**2+v**2=1 and u > 0 (i.e. r orientated in the same 'direction' than w)
+    // after some arithmetic, one finds that :
+    double a = -(vGroundNormal(eX)*cos(SteerAngle)+vGroundNormal(eY)*sin(SteerAngle)) / vGroundNormal(eZ);
+    double u = 1. / sqrt(1. + a*a);
+    double v = a * u;
+    vRollingGroundVec = FGColumnVector3(u * cos(SteerAngle), u * sin(SteerAngle), v);
+  }
+  else {
+    // Here the only significant direction is the normal to the ground "vGroundNormal". Since there is
+    // no wheel the 2 other vectors of the orthonormal basis are not meaningful and are only used to
+    // create the transformation matrix Tg2b. So we are building vRollingGroundVec as an arbitrary
+    // vector normal to vGroundNormal
+    if (fabs(vGroundNormal(eX)) > 0.)
+      vRollingGroundVec = FGColumnVector3(-vGroundNormal(eZ)/vGroundNormal(eX), 0., 1.);
+    else if (fabs(vGroundNormal(eY)) > 0.)
+      vRollingGroundVec = FGColumnVector3(0., -vGroundNormal(eZ)/vGroundNormal(eY), 1.);
+    else
+      vRollingGroundVec = FGColumnVector3(1., 0., -vGroundNormal(eX)/vGroundNormal(eZ));
+
+    vRollingGroundVec.Normalize();
+  }
 
   // The sliping direction is the cross product multiplication of the ground normal and rolling
   // directions
index d665c3062e9915074645ef61c6b816cfde99c3f3..93d6d4749e89f14dc7d80ce6195d21547a4bec79 100644 (file)
@@ -189,6 +189,20 @@ void FGPropagate::SetInitialState(const FGInitialCondition *FGIC)
 
   // Recompute the LocalTerrainRadius.
   RecomputeLocalTerrainRadius();
+
+  // These local copies of the transformation matrices are for use for
+  // initial conditions only.
+
+  Tl2b = GetTl2b();           // local to body frame transform
+  Tb2l = Tl2b.Transposed();   // body to local frame transform
+  Tl2ec = GetTl2ec();         // local to ECEF transform
+  Tec2l = Tl2ec.Transposed(); // ECEF to local frame transform
+  Tec2b = Tl2b * Tec2l;       // ECEF to body frame transform
+  Tb2ec = Tec2b.Transposed(); // body to ECEF frame tranform
+  Ti2ec = GetTi2ec();         // ECI to ECEF transform
+  Tec2i = Ti2ec.Transposed(); // ECEF to ECI frame transform
+  Ti2b  = Tec2b*Ti2ec;        // ECI to body frame transform
+  Tb2i  = Ti2b.Transposed();  // body to ECI frame transform
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%