From cf86d37514ea000acc9b20284a1c1efe89f2697b Mon Sep 17 00:00:00 2001 From: "Curtis L. Olson" Date: Wed, 4 Jan 2012 19:17:32 -0600 Subject: [PATCH] Fix YASim's /accelerations/pilot/{x,y,z}-accel-fps_sec computations. These 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 | 11 +++++++---- src/FDM/YASim/YASim.cxx | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/FDM/YASim/Airplane.cpp b/src/FDM/YASim/Airplane.cpp index f63eaaa5e..50ceefefd 100644 --- a/src/FDM/YASim/Airplane.cpp +++ b/src/FDM/YASim/Airplane.cpp @@ -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 } diff --git a/src/FDM/YASim/YASim.cxx b/src/FDM/YASim/YASim.cxx index 24d62735d..3cfd050d0 100644 --- a/src/FDM/YASim/YASim.cxx +++ b/src/FDM/YASim/YASim.cxx @@ -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 -- 2.39.5