1
0
Fork 0

YASim: Airplane solver uses standard atmosphere so we can replaced atmosphere members with floats for altitude and pass those to setup atmo where needed directly from altitude.

This commit is contained in:
Henning Stahlke 2017-04-25 08:58:51 +02:00
parent 8064135665
commit add6c6b8a8
5 changed files with 13 additions and 15 deletions

View file

@ -125,7 +125,7 @@ void Airplane::updateGearState()
void Airplane::setApproach(float speed, float altitude, float aoa, float fuel, float gla)
{
_approachSpeed = speed;
_approachAtmo.setStandard(altitude);
_approachAltitude = altitude;
_approachAoA = aoa;
_approachFuel = fuel;
_approachGlideAngle = gla;
@ -134,7 +134,7 @@ void Airplane::setApproach(float speed, float altitude, float aoa, float fuel, f
void Airplane::setCruise(float speed, float altitude, float fuel, float gla)
{
_cruiseSpeed = speed;
_cruiseAtmo.setStandard(altitude);
_cruiseAltitude = altitude;
_cruiseAoA = 0;
_tailIncidence = 0;
_cruiseFuel = fuel;
@ -758,7 +758,7 @@ void Airplane::runCruise()
{
_cruiseState.setupState(_cruiseAoA, _cruiseSpeed,_cruiseGlideAngle);
_model.setState(&_cruiseState);
_model.setAtmosphere(_cruiseAtmo);
_model.setStandardAtmosphere(_cruiseAltitude);
// The control configuration
loadControls(_cruiseControls);
@ -776,8 +776,7 @@ void Airplane::runCruise()
for(int i=0; i<_thrusters.size(); i++) {
Thruster* t = ((ThrustRec*)_thrusters.get(i))->thruster;
t->setWind(wind);
t->setAir(_cruiseAtmo);
//Atmosphere::calcStdDensity(_cruiseP, _cruiseT));
t->setStandardAtmosphere(_cruiseAltitude);
}
stabilizeThrust();
@ -795,7 +794,7 @@ void Airplane::runApproach()
{
_approachState.setupState(_approachAoA, _approachSpeed,_approachGlideAngle);
_model.setState(&_approachState);
_model.setAtmosphere(_approachAtmo);
_model.setStandardAtmosphere(_approachAltitude);
// The control configuration
loadControls(_approachControls);
@ -813,7 +812,7 @@ void Airplane::runApproach()
for(int i=0; i<_thrusters.size(); i++) {
Thruster* t = ((ThrustRec*)_thrusters.get(i))->thruster;
t->setWind(wind);
t->setAir(_approachAtmo);
t->setStandardAtmosphere(_approachAltitude);
}
stabilizeThrust();
@ -1058,7 +1057,7 @@ void Airplane::solveHelicopter()
setupWeights(true);
_controls.reset();
_model.getBody()->reset();
_model.setAtmosphere(_cruiseAtmo);
_model.setStandardAtmosphere(_cruiseAltitude);
}
float Airplane::getCGMAC()

View file

@ -169,7 +169,7 @@ private:
Vector _cruiseControls;
State _cruiseState;
Atmosphere _cruiseAtmo;
float _cruiseAltitude;
float _cruiseSpeed{0};
float _cruiseWeight{0};
float _cruiseFuel{0};
@ -177,7 +177,7 @@ private:
Vector _approachControls;
State _approachState;
Atmosphere _approachAtmo;
float _approachAltitude;
float _approachSpeed {0};
float _approachAoA {0};
float _approachWeight {0};

View file

@ -127,7 +127,7 @@ void Model::initIteration()
localWind(pos, _s, v, alt);
t->setWind(v);
t->setAir(_atmo);
t->setAtmosphere(_atmo);
t->integrate(_integrator.getInterval());
t->getTorque(v);

View file

@ -46,7 +46,8 @@ public:
// Runtime instructions
void setWind(const float* wind) { Math::set3(wind, _wind); };
void setAir(Atmosphere a) { _atmo = a; };
void setAtmosphere(Atmosphere a) { _atmo = a; };
void setStandardAtmosphere(float altitude) { _atmo.setStandard(altitude); };
virtual void init() {}
virtual void integrate(float dt)=0;
virtual void stabilize()=0;

View file

@ -71,9 +71,7 @@ int main(int argc, char** argv)
eng->setBoost(1);
float alt = (argc > 2 ? atof(argv[2]) : 0) * FT2M;
Atmosphere atmo;
atmo.setStandard(alt);
pe->setAir(atmo);
pe->setStandardAtmosphere(alt);
float speed = (argc > 3 ? atof(argv[3]) : 0) * KTS2MPS;
float wind[3];