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.
This commit is contained in:
parent
713920356b
commit
04e083083d
2 changed files with 15 additions and 2 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue