X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FYASim%2FYASim.cxx;h=9635e7294ce6cba9d80c3dfa068d65834fec482f;hb=13db36f67912be03c2e970e84cdcdbd41dddb61c;hp=febabc481bbc2dc51907f2e46103d3de7dc0f113;hpb=76f4bc1cef4121e2f8f9ac17c60747de67ed9d83;p=flightgear.git diff --git a/src/FDM/YASim/YASim.cxx b/src/FDM/YASim/YASim.cxx index febabc481..9635e7294 100644 --- a/src/FDM/YASim/YASim.cxx +++ b/src/FDM/YASim/YASim.cxx @@ -1,4 +1,8 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include @@ -39,7 +43,8 @@ static const float W2HP = 1.3416e-3; static const float INHG2PA = 3386.389; static const float SLUG2KG = 14.59390; -YASim::YASim(double dt) +YASim::YASim(double dt) : + _simTime(0) { // set_delta_t(dt); _fdm = new FGFDM(); @@ -50,6 +55,11 @@ YASim::YASim(double dt) _fdm->getAirplane()->getModel()->getIntegrator()->setInterval(_dt); } +YASim::~YASim() +{ + delete _fdm; +} + void YASim::report() { Airplane* a = _fdm->getAirplane(); @@ -85,9 +95,10 @@ void YASim::bind() // Run the superclass bind to set up a bunch of property ties FGInterface::bind(); +//Torsten Dreyer: we shouldn't do this anymore because we don't set these values nomore // Now UNtie the ones that we are going to set ourselves. - fgUntie("/consumables/fuel/tank[0]/level-gal_us"); - fgUntie("/consumables/fuel/tank[1]/level-gal_us"); +// fgUntie("/consumables/fuel/tank[0]/level-gal_us"); +// fgUntie("/consumables/fuel/tank[1]/level-gal_us"); char buf[256]; for(int i=0; i<_fdm->getAirplane()->getModel()->numThrusters(); i++) { @@ -200,7 +211,7 @@ void YASim::update(double dt) // build the environment cache. float vr = _fdm->getVehicleRadius(); vr += 2.0*FT2M*dt*Math::mag3(v); - prepare_ground_cache_m( 0.0, xyz, vr ); + prepare_ground_cache_m( _simTime, _simTime + dt, xyz, vr ); // Track time increments. FGGround* gr @@ -208,21 +219,22 @@ void YASim::update(double dt) int i; for(i=0; isetTimeOffset(i*_dt); + gr->setTimeOffset(_simTime + i*_dt); copyToYASim(false); _fdm->iterate(_dt); copyFromYASim(); } - // Reset the time increment. - gr->setTimeOffset(0.0); + // Increment the local sim time + _simTime += dt; + gr->setTimeOffset(_simTime); } void YASim::copyToYASim(bool copyState) { // Physical state - float lat = get_Latitude(); - float lon = get_Longitude(); + double lat = get_Latitude(); + double lon = get_Longitude(); float alt = get_Altitude() * FT2M; float roll = get_Phi(); float pitch = get_Theta(); @@ -367,13 +379,17 @@ void YASim::copyFromYASim() double lat, lon, alt; sgCartToGeod(s->pos, &lat, &lon, &alt); _set_Geodetic_Position(lat, lon, alt*M2FT); - _update_ground_elev_at_pos(); + double groundlevel_m = get_groundlevel_m(lat, lon, alt); + _set_Runway_altitude(groundlevel_m*SG_METER_TO_FEET); + _set_Altitude_AGL((alt-groundlevel_m)*SG_METER_TO_FEET); + + // the smallest agl of all gears + fgSetFloat("/position/gear-agl-m", model->getAGL()); + fgSetFloat("/position/gear-agl-ft", model->getAGL()*M2FT); // UNUSED //_set_Geocentric_Position(Glue::geod2geocLat(lat), lon, alt*M2FT); - _set_Altitude_AGL(model->getAGL() * M2FT); - // useful conversion matrix float xyz2ned[9]; Glue::xyz2nedMat(lat, lon, xyz2ned); @@ -403,7 +419,7 @@ void YASim::copyFromYASim() _set_V_rel_wind(Math::mag3(v)*M2FT); // units? float P = fgGetDouble("/environment/pressure-inhg") * INHG2PA; - float T = fgGetDouble("/environment/temperature-degC") + 273.15; + float T = fgGetDouble("/environment/temperature-degc") + 273.15; float D = fgGetFloat("/environment/density-slugft3") *SLUG2KG * M2FT*M2FT*M2FT; _set_V_equiv_kts(Atmosphere::calcVEAS(v[0], P, T, D)*MPS2KTS); @@ -433,7 +449,7 @@ void YASim::copyFromYASim() // orientation float alpha, beta; - Glue::calcAlphaBeta(s, &alpha, &beta); + Glue::calcAlphaBeta(s, wind, &alpha, &beta); _set_Alpha(alpha); _set_Beta(beta); @@ -461,8 +477,11 @@ void YASim::copyFromYASim() node->setBoolValue("has-brake", g->getBrake() != 0); node->setBoolValue("wow", g->getCompressFraction() != 0); node->setFloatValue("compression-norm", g->getCompressFraction()); + node->setFloatValue("compression-m", g->getCompressDist()); node->setFloatValue("caster-angle-deg", g->getCasterAngle() * RAD2DEG); node->setFloatValue("rollspeed-ms", g->getRollSpeed()); + node->setBoolValue("ground-is-solid", g->getGroundIsSolid()!=0); + node->setFloatValue("ground-friction-factor", g->getGroundFrictionFactor()); } Hook* h = airplane->getHook(); @@ -475,5 +494,9 @@ void YASim::copyFromYASim() if(l) { SGPropertyNode * node = fgGetNode("gear/launchbar", 0, true); node->setFloatValue("position-norm", l->getCompressFraction()); + node->setFloatValue("holdback-position-norm", l->getHoldbackCompressFraction()); + node->setStringValue("state", l->getState()); + node->setBoolValue("strop", l->getStrop()); } + }