]> git.mxchange.org Git - flightgear.git/commitdiff
Need to call recalc() on the RigidBody during solution, or else it
authorandy <andy>
Sat, 1 Jun 2002 19:59:38 +0000 (19:59 +0000)
committerandy <andy>
Sat, 1 Jun 2002 19:59:38 +0000 (19:59 +0000)
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
src/FDM/YASim/FGFDM.cpp

index 64997d2cdcf749bc22a1944178fbd1902c97d4e3..77b13b56a377a9f10b2cbaee077ae898fcccb8c0 100644 (file)
@@ -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)
         {
index 9c911a7388afb7ffc07ddb32ce4b7a509d3670bf..e2a38dc147012574fb0daa206eaef07670d916f2 100644 (file)
@@ -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);