From 04e083083da4851c6dee74b98453da5624b9c899 Mon Sep 17 00:00:00 2001 From: andy Date: Sat, 1 Jun 2002 19:59:38 +0000 Subject: [PATCH] Need to call recalc() on the RigidBody during solution, or else it won't apply the right gross weight due to fuel differences. When solving for zero force, do so in the global frame, not the aircraft's. In principle, this shouldn't matter (zero is zero in all frames), but in practice this should help to avoid oscillations. Calculating lift as force perpendicular to the ground (and not the wing plane) is clearly the Right Thing, anyway. Also added support for a /yasim/gross-weight-lbs property, which should be generically useful. --- src/FDM/YASim/Airplane.cpp | 13 +++++++++++-- src/FDM/YASim/FGFDM.cpp | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/FDM/YASim/Airplane.cpp b/src/FDM/YASim/Airplane.cpp index 64997d2cd..77b13b56a 100644 --- a/src/FDM/YASim/Airplane.cpp +++ b/src/FDM/YASim/Airplane.cpp @@ -698,6 +698,7 @@ void Airplane::runCruise() updateGearState(); // Precompute thrust in the model, and calculate aerodynamic forces + _model.getBody()->recalc(); _model.getBody()->reset(); _model.initIteration(); _model.calcForces(&_cruiseState); @@ -738,6 +739,7 @@ void Airplane::runApproach() updateGearState(); // Precompute thrust in the model, and calculate aerodynamic forces + _model.getBody()->recalc(); _model.getBody()->reset(); _model.initIteration(); _model.calcForces(&_approachState); @@ -817,19 +819,23 @@ void Airplane::solve() float thrust = tmp[0]; _model.getBody()->getAccel(tmp); + Math::tmul33(_cruiseState.orient, tmp, tmp); float xforce = _cruiseWeight * tmp[0]; float clift0 = _cruiseWeight * tmp[2]; _model.getBody()->getAngularAccel(tmp); + Math::tmul33(_cruiseState.orient, tmp, tmp); float pitch0 = tmp[1]; // Run an approach iteration, and do likewise runApproach(); _model.getBody()->getAngularAccel(tmp); + Math::tmul33(_approachState.orient, tmp, tmp); double apitch0 = tmp[1]; _model.getBody()->getAccel(tmp); + Math::tmul33(_approachState.orient, tmp, tmp); float alift = _approachWeight * tmp[2]; // Modify the cruise AoA a bit to get a derivative @@ -838,6 +844,7 @@ void Airplane::solve() _cruiseAoA -= ARCMIN; _model.getBody()->getAccel(tmp); + Math::tmul33(_cruiseState.orient, tmp, tmp); float clift1 = _cruiseWeight * tmp[2]; // Do the same with the tail incidence @@ -846,6 +853,7 @@ void Airplane::solve() _tail->setIncidence(_tailIncidence); _model.getBody()->getAngularAccel(tmp); + Math::tmul33(_cruiseState.orient, tmp, tmp); float pitch1 = tmp[1]; // Now calculate: @@ -870,6 +878,7 @@ void Airplane::solve() _approachElevator.val -= ELEVDIDDLE; _model.getBody()->getAngularAccel(tmp); + Math::tmul33(_approachState.orient, tmp, tmp); double apitch1 = tmp[1]; float elevDelta = -apitch0 * (ELEVDIDDLE/(apitch1-apitch0)); @@ -894,8 +903,8 @@ void Airplane::solve() _cruiseAoA = clamp(_cruiseAoA, -0.175f, 0.175f); _tailIncidence = clamp(_tailIncidence, -0.175f, 0.175f); - if(norm(dragFactor) < 1.00001 && - norm(liftFactor) < 1.00001 && + if(abs(xforce/_cruiseWeight) < 0.0001 && + abs(alift/_approachWeight) < 0.0001 && abs(aoaDelta) < .000017 && abs(tailDelta) < .000017) { diff --git a/src/FDM/YASim/FGFDM.cpp b/src/FDM/YASim/FGFDM.cpp index 9c911a738..e2a38dc14 100644 --- a/src/FDM/YASim/FGFDM.cpp +++ b/src/FDM/YASim/FGFDM.cpp @@ -21,6 +21,7 @@ static const float DEG2RAD = 0.0174532925199; static const float RPM2RAD = 0.10471975512; static const float LBS2N = 4.44822; static const float LBS2KG = 0.45359237; +static const float KG2LBS = 2.2046225; static const float CM2GALS = 264.172037284; static const float HP2W = 745.700; static const float INHG2PA = 3386.389; @@ -309,6 +310,9 @@ void FGFDM::setOutputProperties() char buf[256]; int i; + float grossWgt = _airplane.getModel()->getBody()->getTotalMass() * KG2LBS; + fgSetFloat("/yasim/gross-weight-lbs", grossWgt); + ControlMap* cm = _airplane.getControlMap(); for(i=0; i<_controlProps.size(); i++) { PropOut* p = (PropOut*)_controlProps.get(i); -- 2.39.5