]> git.mxchange.org Git - flightgear.git/commitdiff
Fix YASim's /accelerations/pilot/{x,y,z}-accel-fps_sec computations. These
authorCurtis L. Olson <curt0001@flightgear.org>
Thu, 5 Jan 2012 01:17:32 +0000 (19:17 -0600)
committerCurtis L. Olson <curt0001@flightgear.org>
Thu, 5 Jan 2012 01:17:32 +0000 (19:17 -0600)
are the accelerations (forces) as felt from the pilot's perspective.  This
combines the accelerations due to change in velocity vector and gravity.

Previosly the gravity part was right, but the body accelerations were being
transformed incorrectly.  The error was very subtle and basically amounted to
the fact that inverting an axis of a vector before transforming it is not
equivalent to transforming the vector and then inverting that axis.

After this fix, pilot accelerations + gyro + gps can be fed into an external
kalman filter and it will converge properly (extra confirmation that there
was a problem and this fix corrects it.)

src/FDM/YASim/Airplane.cpp
src/FDM/YASim/YASim.cxx

index f63eaaa5e0e03848a2b4111e4d353e30702cbe5e..50ceefefd7c50d7da994265a16134e8cd0e54636 100644 (file)
@@ -126,14 +126,17 @@ void Airplane::getPilotAccel(float* out)
     // Gravity
     Glue::geodUp(s->pos, out);
     Math::mul3(-9.8f, out, out);
+    Math::vmul33(s->orient, out, out);
+    out[0] = -out[0];
 
     // The regular acceleration
     float tmp[3];
-    Math::mul3(-1, s->acc, tmp);
-    Math::add3(tmp, out, out);
-
     // Convert to aircraft coordinates
-    Math::vmul33(s->orient, out, out);
+    Math::vmul33(s->orient, s->acc, tmp);
+    tmp[1] = -tmp[1];
+    tmp[2] = -tmp[2];
+
+    Math::add3(tmp, out, out);
 
     // FIXME: rotational & centripetal acceleration needed
 }
index 24d62735d66bf654979c802b8a61ce09a74e67d1..3cfd050d09c00ef451363f028e846759233d8009 100644 (file)
@@ -448,7 +448,7 @@ void YASim::copyFromYASim()
     _set_Accels_CG_Body(M2FT*v[0], -M2FT*v[1], -M2FT*v[2]);
 
     _fdm->getAirplane()->getPilotAccel(v);
-    _set_Accels_Pilot_Body(-M2FT*v[0], M2FT*v[1], M2FT*v[2]);
+    _set_Accels_Pilot_Body(M2FT*v[0], M2FT*v[1], M2FT*v[2]);
 
     // There is no property for pilot G's, but I need it for a panel
     // instrument.  Hack this in here, and REMOVE IT WHEN IT FINDS A