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:
parent
8064135665
commit
add6c6b8a8
5 changed files with 13 additions and 15 deletions
|
@ -125,7 +125,7 @@ void Airplane::updateGearState()
|
||||||
void Airplane::setApproach(float speed, float altitude, float aoa, float fuel, float gla)
|
void Airplane::setApproach(float speed, float altitude, float aoa, float fuel, float gla)
|
||||||
{
|
{
|
||||||
_approachSpeed = speed;
|
_approachSpeed = speed;
|
||||||
_approachAtmo.setStandard(altitude);
|
_approachAltitude = altitude;
|
||||||
_approachAoA = aoa;
|
_approachAoA = aoa;
|
||||||
_approachFuel = fuel;
|
_approachFuel = fuel;
|
||||||
_approachGlideAngle = gla;
|
_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)
|
void Airplane::setCruise(float speed, float altitude, float fuel, float gla)
|
||||||
{
|
{
|
||||||
_cruiseSpeed = speed;
|
_cruiseSpeed = speed;
|
||||||
_cruiseAtmo.setStandard(altitude);
|
_cruiseAltitude = altitude;
|
||||||
_cruiseAoA = 0;
|
_cruiseAoA = 0;
|
||||||
_tailIncidence = 0;
|
_tailIncidence = 0;
|
||||||
_cruiseFuel = fuel;
|
_cruiseFuel = fuel;
|
||||||
|
@ -758,7 +758,7 @@ void Airplane::runCruise()
|
||||||
{
|
{
|
||||||
_cruiseState.setupState(_cruiseAoA, _cruiseSpeed,_cruiseGlideAngle);
|
_cruiseState.setupState(_cruiseAoA, _cruiseSpeed,_cruiseGlideAngle);
|
||||||
_model.setState(&_cruiseState);
|
_model.setState(&_cruiseState);
|
||||||
_model.setAtmosphere(_cruiseAtmo);
|
_model.setStandardAtmosphere(_cruiseAltitude);
|
||||||
|
|
||||||
// The control configuration
|
// The control configuration
|
||||||
loadControls(_cruiseControls);
|
loadControls(_cruiseControls);
|
||||||
|
@ -776,8 +776,7 @@ void Airplane::runCruise()
|
||||||
for(int i=0; i<_thrusters.size(); i++) {
|
for(int i=0; i<_thrusters.size(); i++) {
|
||||||
Thruster* t = ((ThrustRec*)_thrusters.get(i))->thruster;
|
Thruster* t = ((ThrustRec*)_thrusters.get(i))->thruster;
|
||||||
t->setWind(wind);
|
t->setWind(wind);
|
||||||
t->setAir(_cruiseAtmo);
|
t->setStandardAtmosphere(_cruiseAltitude);
|
||||||
//Atmosphere::calcStdDensity(_cruiseP, _cruiseT));
|
|
||||||
}
|
}
|
||||||
stabilizeThrust();
|
stabilizeThrust();
|
||||||
|
|
||||||
|
@ -795,7 +794,7 @@ void Airplane::runApproach()
|
||||||
{
|
{
|
||||||
_approachState.setupState(_approachAoA, _approachSpeed,_approachGlideAngle);
|
_approachState.setupState(_approachAoA, _approachSpeed,_approachGlideAngle);
|
||||||
_model.setState(&_approachState);
|
_model.setState(&_approachState);
|
||||||
_model.setAtmosphere(_approachAtmo);
|
_model.setStandardAtmosphere(_approachAltitude);
|
||||||
|
|
||||||
// The control configuration
|
// The control configuration
|
||||||
loadControls(_approachControls);
|
loadControls(_approachControls);
|
||||||
|
@ -813,7 +812,7 @@ void Airplane::runApproach()
|
||||||
for(int i=0; i<_thrusters.size(); i++) {
|
for(int i=0; i<_thrusters.size(); i++) {
|
||||||
Thruster* t = ((ThrustRec*)_thrusters.get(i))->thruster;
|
Thruster* t = ((ThrustRec*)_thrusters.get(i))->thruster;
|
||||||
t->setWind(wind);
|
t->setWind(wind);
|
||||||
t->setAir(_approachAtmo);
|
t->setStandardAtmosphere(_approachAltitude);
|
||||||
}
|
}
|
||||||
stabilizeThrust();
|
stabilizeThrust();
|
||||||
|
|
||||||
|
@ -1058,7 +1057,7 @@ void Airplane::solveHelicopter()
|
||||||
setupWeights(true);
|
setupWeights(true);
|
||||||
_controls.reset();
|
_controls.reset();
|
||||||
_model.getBody()->reset();
|
_model.getBody()->reset();
|
||||||
_model.setAtmosphere(_cruiseAtmo);
|
_model.setStandardAtmosphere(_cruiseAltitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Airplane::getCGMAC()
|
float Airplane::getCGMAC()
|
||||||
|
|
|
@ -169,7 +169,7 @@ private:
|
||||||
|
|
||||||
Vector _cruiseControls;
|
Vector _cruiseControls;
|
||||||
State _cruiseState;
|
State _cruiseState;
|
||||||
Atmosphere _cruiseAtmo;
|
float _cruiseAltitude;
|
||||||
float _cruiseSpeed{0};
|
float _cruiseSpeed{0};
|
||||||
float _cruiseWeight{0};
|
float _cruiseWeight{0};
|
||||||
float _cruiseFuel{0};
|
float _cruiseFuel{0};
|
||||||
|
@ -177,7 +177,7 @@ private:
|
||||||
|
|
||||||
Vector _approachControls;
|
Vector _approachControls;
|
||||||
State _approachState;
|
State _approachState;
|
||||||
Atmosphere _approachAtmo;
|
float _approachAltitude;
|
||||||
float _approachSpeed {0};
|
float _approachSpeed {0};
|
||||||
float _approachAoA {0};
|
float _approachAoA {0};
|
||||||
float _approachWeight {0};
|
float _approachWeight {0};
|
||||||
|
|
|
@ -127,7 +127,7 @@ void Model::initIteration()
|
||||||
localWind(pos, _s, v, alt);
|
localWind(pos, _s, v, alt);
|
||||||
|
|
||||||
t->setWind(v);
|
t->setWind(v);
|
||||||
t->setAir(_atmo);
|
t->setAtmosphere(_atmo);
|
||||||
t->integrate(_integrator.getInterval());
|
t->integrate(_integrator.getInterval());
|
||||||
|
|
||||||
t->getTorque(v);
|
t->getTorque(v);
|
||||||
|
|
|
@ -46,7 +46,8 @@ public:
|
||||||
|
|
||||||
// Runtime instructions
|
// Runtime instructions
|
||||||
void setWind(const float* wind) { Math::set3(wind, _wind); };
|
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 init() {}
|
||||||
virtual void integrate(float dt)=0;
|
virtual void integrate(float dt)=0;
|
||||||
virtual void stabilize()=0;
|
virtual void stabilize()=0;
|
||||||
|
|
|
@ -71,9 +71,7 @@ int main(int argc, char** argv)
|
||||||
eng->setBoost(1);
|
eng->setBoost(1);
|
||||||
|
|
||||||
float alt = (argc > 2 ? atof(argv[2]) : 0) * FT2M;
|
float alt = (argc > 2 ? atof(argv[2]) : 0) * FT2M;
|
||||||
Atmosphere atmo;
|
pe->setStandardAtmosphere(alt);
|
||||||
atmo.setStandard(alt);
|
|
||||||
pe->setAir(atmo);
|
|
||||||
|
|
||||||
float speed = (argc > 3 ? atof(argv[3]) : 0) * KTS2MPS;
|
float speed = (argc > 3 ? atof(argv[3]) : 0) * KTS2MPS;
|
||||||
float wind[3];
|
float wind[3];
|
||||||
|
|
Loading…
Reference in a new issue