]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/JSBSim.cxx
*** empty log message ***
[flightgear.git] / src / FDM / JSBSim / JSBSim.cxx
index cf9e683726907b0f3659f24558ce39f508d9a237..80ee3ee03e559cc45aca1df6cf22a9ae6b7aaa0e 100644 (file)
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/misc/sg_path.hxx>
+#include <simgear/structure/commands.hxx>
 
 #include <FDM/flight.hxx>
 
 #include <Aircraft/aircraft.hxx>
-#include <Controls/controls.hxx>
+#include <Aircraft/controls.hxx>
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 
+#include "JSBSim.hxx"
 #include <FDM/JSBSim/FGFDMExec.h>
-#include <FDM/JSBSim/FGAircraft.h>
-#include <FDM/JSBSim/FGFCS.h>
-#include <FDM/JSBSim/FGPropagate.h>
+#include <FDM/JSBSim/FGJSBBase.h>
 #include <FDM/JSBSim/FGState.h>
-#include <FDM/JSBSim/FGAuxiliary.h>
-#include <FDM/JSBSim/FGInitialCondition.h>
-#include <FDM/JSBSim/FGTrim.h>
-#include <FDM/JSBSim/FGAtmosphere.h>
-#include <FDM/JSBSim/FGMassBalance.h>
-#include <FDM/JSBSim/FGAerodynamics.h>
-#include <FDM/JSBSim/FGLGear.h>
-#include <FDM/JSBSim/FGPropertyManager.h>
-#include <FDM/JSBSim/FGEngine.h>
-#include <FDM/JSBSim/FGPiston.h>
-#include <FDM/JSBSim/FGTurbine.h>
-#include <FDM/JSBSim/FGRocket.h>
-#include <FDM/JSBSim/FGElectric.h>
-#include <FDM/JSBSim/FGNozzle.h>
-#include <FDM/JSBSim/FGPropeller.h>
-#include <FDM/JSBSim/FGRotor.h>
-#include <FDM/JSBSim/FGTank.h>
-#include "JSBSim.hxx"
+#include <FDM/JSBSim/initialization/FGInitialCondition.h>
+#include <FDM/JSBSim/initialization/FGTrim.h>
+#include <FDM/JSBSim/models/FGModel.h>
+#include <FDM/JSBSim/models/FGAircraft.h>
+#include <FDM/JSBSim/models/FGFCS.h>
+#include <FDM/JSBSim/models/FGPropagate.h>
+#include <FDM/JSBSim/models/FGAuxiliary.h>
+#include <FDM/JSBSim/models/FGAtmosphere.h>
+#include <FDM/JSBSim/models/FGMassBalance.h>
+#include <FDM/JSBSim/models/FGAerodynamics.h>
+#include <FDM/JSBSim/models/FGLGear.h>
+#include <FDM/JSBSim/models/propulsion/FGEngine.h>
+#include <FDM/JSBSim/models/propulsion/FGPiston.h>
+#include <FDM/JSBSim/models/propulsion/FGTurbine.h>
+#include <FDM/JSBSim/models/propulsion/FGTurboProp.h>
+#include <FDM/JSBSim/models/propulsion/FGRocket.h>
+#include <FDM/JSBSim/models/propulsion/FGElectric.h>
+#include <FDM/JSBSim/models/propulsion/FGNozzle.h>
+#include <FDM/JSBSim/models/propulsion/FGPropeller.h>
+#include <FDM/JSBSim/models/propulsion/FGRotor.h>
+#include <FDM/JSBSim/models/propulsion/FGTank.h>
+#include <FDM/JSBSim/input_output/FGPropertyManager.h>
+#include <FDM/JSBSim/input_output/FGGroundCallback.h>
+
+using namespace JSBSim;
 
 static inline double
 FMAX (double a, double b)
@@ -76,6 +83,38 @@ FMAX (double a, double b)
   return a > b ? a : b;
 }
 
+class FGFSGroundCallback : public FGGroundCallback {
+public:
+  FGFSGroundCallback(FGInterface* ifc) : mInterface(ifc) {}
+  virtual ~FGFSGroundCallback() {}
+
+  /** Get the altitude above sea level depenent on the location. */
+  virtual double GetAltitude(const FGLocation& l) const {
+    double pt[3] = { SG_FEET_TO_METER*l(eX),
+                     SG_FEET_TO_METER*l(eY),
+                     SG_FEET_TO_METER*l(eZ) };
+    double lat, lon, alt;
+    sgCartToGeod( pt, &lat, &lon, &alt);
+    return alt * SG_METER_TO_FEET;
+  }
+
+  /** Compute the altitude above ground. */
+  virtual double GetAGLevel(double t, const FGLocation& l,
+                            FGLocation& cont,
+                            FGColumnVector3& n, FGColumnVector3& v) const {
+    double loc_cart[3] = { l(eX), l(eY), l(eZ) };
+    double contact[3], normal[3], vel[3], lc, ff, agl;
+    int groundtype;
+    mInterface->get_agl_ft(t, loc_cart, contact, normal, vel,
+                           &groundtype, &lc, &ff, &agl);
+    n = l.GetTec2l()*FGColumnVector3( normal[0], normal[1], normal[2] );
+    v = l.GetTec2l()*FGColumnVector3( vel[0], vel[1], vel[2] );
+    cont = FGColumnVector3( contact[0], contact[1], contact[2] );
+    return agl;
+  }
+private:
+  FGInterface* mInterface;
+};
 
 /******************************************************************************/
 
@@ -83,7 +122,6 @@ FGJSBsim::FGJSBsim( double dt )
   : FGInterface(dt)
 {
     bool result;
-
                                 // Set up the debugging level
                                 // FIXME: this will not respond to
                                 // runtime changes
@@ -111,6 +149,9 @@ FGJSBsim::FGJSBsim( double dt )
 
     fdmex = new FGFDMExec( (FGPropertyManager*)globals->get_props() );
 
+    // Register ground callback.
+    fdmex->SetGroundCallback( new FGFSGroundCallback(this) );
+
     State           = fdmex->GetState();
     Atmosphere      = fdmex->GetAtmosphere();
     FCS             = fdmex->GetFCS();
@@ -171,6 +212,7 @@ FGJSBsim::FGJSBsim( double dt )
         node->setDoubleValue("level-gal_us", Propulsion->GetTank(i)->GetContents() / 6.6);
       }
     }
+    Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue());
 
     fgSetDouble("/fdm/trim/pitch-trim", FCS->GetPitchTrimCmd());
     fgSetDouble("/fdm/trim/throttle",   FCS->GetThrottleCmd(0));
@@ -220,6 +262,8 @@ FGJSBsim::FGJSBsim( double dt )
     wind_from_east = fgGetNode("/environment/wind-from-east-fps" ,true);
     wind_from_down = fgGetNode("/environment/wind-from-down-fps" ,true);
 
+    slaved = fgGetNode("/sim/slaved/enabled", true);
+
     for (unsigned int i = 0; i < Propulsion->GetNumEngines(); i++) {
       SGPropertyNode * node = fgGetNode("engines/engine", i, true);
       Propulsion->GetEngine(i)->GetThruster()->SetRPM(node->getDoubleValue("rpm") /
@@ -247,9 +291,6 @@ void FGJSBsim::init()
     // Explicitly call the superclass's
     // init method first.
 
-#ifdef FG_WEATHERCM
-    Atmosphere->UseInternal();
-#else
     if (fgGetBool("/environment/params/control-fdm-atmosphere")) {
       Atmosphere->UseExternal();
       Atmosphere->SetExTemperature(
@@ -266,7 +307,6 @@ void FGJSBsim::init()
     } else {
       Atmosphere->UseInternal();
     }
-#endif
 
     fgic->SetVnorthFpsIC( wind_from_north->getDoubleValue() );
     fgic->SetVeastFpsIC( wind_from_east->getDoubleValue() );
@@ -279,6 +319,14 @@ void FGJSBsim::init()
      << ", " << fdmex->GetAtmosphere()->GetPressure()
      << ", " << fdmex->GetAtmosphere()->GetDensity() );
 
+    if (fgGetBool("/sim/presets/running")) {
+          for (int i=0; i < Propulsion->GetNumEngines(); i++) {
+            SGPropertyNode * node = fgGetNode("engines/engine", i, true);
+            node->setBoolValue("running", true);
+            Propulsion->GetEngine(i)->SetRunning(true);
+          }
+    }
+
     common_init();
 
     copy_to_JSBsim();
@@ -290,9 +338,9 @@ void FGJSBsim::init()
     switch(fgic->GetSpeedSet()) {
     case setned:
         SG_LOG(SG_FLIGHT,SG_INFO, "  Vn,Ve,Vd= "
-               << Propagate->GetVel(eNorth) << ", "
-               << Propagate->GetVel(eEast) << ", "
-               << Propagate->GetVel(eDown) << " ft/s");
+               << Propagate->GetVel(FGJSBBase::eNorth) << ", "
+               << Propagate->GetVel(FGJSBBase::eEast) << ", "
+               << Propagate->GetVel(FGJSBBase::eDown) << " ft/s");
     break;
     case setuvw:
         SG_LOG(SG_FLIGHT,SG_INFO, "  U,V,W= "
@@ -314,11 +362,11 @@ void FGJSBsim::init()
     stall_warning->setDoubleValue(0);
 
     SG_LOG( SG_FLIGHT, SG_INFO, "  Bank Angle: "
-            << Propagate->GetEuler(ePhi)*RADTODEG << " deg" );
+            << Propagate->GetEuler(FGJSBBase::ePhi)*RADTODEG << " deg" );
     SG_LOG( SG_FLIGHT, SG_INFO, "  Pitch Angle: "
-            << Propagate->GetEuler(eTht)*RADTODEG << " deg" );
+            << Propagate->GetEuler(FGJSBBase::eTht)*RADTODEG << " deg" );
     SG_LOG( SG_FLIGHT, SG_INFO, "  True Heading: "
-            << Propagate->GetEuler(ePsi)*RADTODEG << " deg" );
+            << Propagate->GetEuler(FGJSBBase::ePsi)*RADTODEG << " deg" );
     SG_LOG( SG_FLIGHT, SG_INFO, "  Latitude: "
             << Propagate->GetLocation().GetLatitudeDeg() << " deg" );
     SG_LOG( SG_FLIGHT, SG_INFO, "  Longitude: "
@@ -348,7 +396,41 @@ void FGJSBsim::update( double dt )
 
     int i;
 
-    // double save_alt = 0.0;
+    // Compute the radius of the aircraft. That is the radius of a ball
+    // where all gear units are in. At the moment it is at least 10ft ...
+    double acrad = 10.0;
+    int n_gears = GroundReactions->GetNumGearUnits();
+    for (i=0; i<n_gears; ++i) {
+      FGColumnVector3 bl = GroundReactions->GetGearUnit(i)->GetBodyLocation();
+      double r = bl.Magnitude();
+      if (acrad < r)
+        acrad = r;
+    }
+
+    // Compute the potential movement of this aircraft and query for the
+    // ground in this area.
+    double groundCacheRadius = acrad + 2*dt*Propagate->GetUVW().Magnitude();
+    double alt, slr, lat, lon;
+    FGColumnVector3 cart = Auxiliary->GetLocationVRP();
+    if ( needTrim && startup_trim->getBoolValue() ) {
+      alt = fgic->GetAltitudeFtIC();
+      slr = fgic->GetSeaLevelRadiusFtIC();
+      lat = fgic->GetLatitudeDegIC() * SGD_DEGREES_TO_RADIANS;
+      lon = fgic->GetLongitudeDegIC() * SGD_DEGREES_TO_RADIANS;
+      cart = FGLocation(lon, lat, alt+slr);
+    }
+    double cart_pos[3] = { cart(1), cart(2), cart(3) };
+    bool cache_ok = prepare_ground_cache_ft( State->Getsim_time(), cart_pos,
+                                             groundCacheRadius );
+    if (!cache_ok) {
+      SG_LOG(SG_FLIGHT, SG_WARN,
+             "FGInterface is being called without scenery below the aircraft!");
+      cout << "altitude         = " << alt << endl;
+      cout << "sea level radius = " << slr << endl;
+      cout << "latitude         = " << lat << endl;
+      cout << "longitude        = " << lon << endl;
+      //return;
+    }
 
     copy_to_JSBsim();
 
@@ -356,10 +438,18 @@ void FGJSBsim::update( double dt )
 
     if ( needTrim ) {
       if ( startup_trim->getBoolValue() ) {
+        double contact[3], dummy[3], lc, ff, agl;
+        int groundtype;
+        get_agl_ft(State->Getsim_time(), cart_pos, contact,
+                   dummy, dummy, &groundtype, &lc, &ff, &agl);
+        double terrain_alt = sqrt(contact[0]*contact[0] + contact[1]*contact[1]
+             + contact[2]*contact[2]) - fgic->GetSeaLevelRadiusFtIC();
+
         SG_LOG(SG_FLIGHT, SG_INFO,
           "Ready to trim, terrain altitude is: "
-            << cur_fdm_state->get_Runway_altitude() * SG_METER_TO_FEET );
-        fgic->SetTerrainAltitudeFtIC( cur_fdm_state->get_ground_elev_ft() );
+            << terrain_alt * SG_METER_TO_FEET );
+
+        fgic->SetTerrainAltitudeFtIC( terrain_alt );
         do_trim();
       } else {
         fdmex->RunIC();  //apply any changes made through the set_ functions
@@ -437,6 +527,7 @@ bool FGJSBsim::copy_to_JSBsim()
       FCS->SetThrottleCmd(i, globals->get_controls()->get_throttle(i));
       FCS->SetMixtureCmd(i, globals->get_controls()->get_mixture(i));
       FCS->SetPropAdvanceCmd(i, globals->get_controls()->get_prop_advance(i));
+      FCS->SetFeatherCmd(i, globals->get_controls()->get_feather(i));
 
       switch (Propulsion->GetEngine(i)->GetType()) {
       case FGEngine::etPiston:
@@ -460,6 +551,17 @@ bool FGJSBsim::copy_to_JSBsim()
         FGRocket* eng = (FGRocket*)Propulsion->GetEngine(i);
         break;
         } // end FGRocket code block
+      case FGEngine::etTurboprop:
+        { // FGTurboProp code block
+        FGTurboProp* eng = (FGTurboProp*)Propulsion->GetEngine(i);
+        eng->SetReverse( globals->get_controls()->get_reverser(i) );
+        eng->SetCutoff( globals->get_controls()->get_cutoff(i) );
+        eng->SetIgnition( globals->get_controls()->get_ignition(i) );
+
+               eng->SetGeneratorPower( globals->get_controls()->get_generator_breaker(i) );
+               eng->SetCondition( globals->get_controls()->get_condition(i) );
+        break;
+        } // end FGTurboProp code block
       }
 
       { // FGEngine code block
@@ -470,11 +572,8 @@ bool FGJSBsim::copy_to_JSBsim()
       } // end FGEngine code block
     }
 
-    _set_Runway_altitude( cur_fdm_state->get_Runway_altitude() );
+
     Propagate->SetSeaLevelRadius( get_Sea_level_radius() );
-    Propagate->SetRunwayRadius( get_Runway_altitude()
-                               + get_Sea_level_radius() );
 
     Atmosphere->SetExTemperature(
                   9.0/5.0*(temperature->getDoubleValue()+273.15) );
@@ -503,6 +602,8 @@ bool FGJSBsim::copy_to_JSBsim()
     }
     SGPropertyNode* node = fgGetNode("/systems/refuel", true);
     Propulsion->SetRefuel(node->getDoubleValue("contact"));
+    Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue());
+    fdmex->SetSlave(slaved->getBoolValue());
 
     return true;
 }
@@ -541,18 +642,18 @@ bool FGJSBsim::copy_from_JSBsim()
 
     // Velocities
 
-    _set_Velocities_Local( Propagate->GetVel(eNorth),
-                           Propagate->GetVel(eEast),
-                           Propagate->GetVel(eDown) );
+    _set_Velocities_Local( Propagate->GetVel(FGJSBBase::eNorth),
+                           Propagate->GetVel(FGJSBBase::eEast),
+                           Propagate->GetVel(FGJSBBase::eDown) );
 
     _set_Velocities_Wind_Body( Propagate->GetUVW(1),
                                Propagate->GetUVW(2),
                                Propagate->GetUVW(3) );
 
     // Make the HUD work ...
-    _set_Velocities_Ground( Propagate->GetVel(eNorth),
-                            Propagate->GetVel(eEast),
-                            -Propagate->GetVel(eDown) );
+    _set_Velocities_Ground( Propagate->GetVel(FGJSBBase::eNorth),
+                            Propagate->GetVel(FGJSBBase::eEast),
+                            -Propagate->GetVel(FGJSBBase::eDown) );
 
     _set_V_rel_wind( Auxiliary->GetVt() );
 
@@ -562,26 +663,36 @@ bool FGJSBsim::copy_from_JSBsim()
 
     _set_V_ground_speed( Auxiliary->GetVground() );
 
-    _set_Omega_Body( Propagate->GetPQR(eP),
-                     Propagate->GetPQR(eQ),
-                     Propagate->GetPQR(eR) );
+    _set_Omega_Body( Propagate->GetPQR(FGJSBBase::eP),
+                     Propagate->GetPQR(FGJSBBase::eQ),
+                     Propagate->GetPQR(FGJSBBase::eR) );
 
-    _set_Euler_Rates( Auxiliary->GetEulerRates(ePhi),
-                      Auxiliary->GetEulerRates(eTht),
-                      Auxiliary->GetEulerRates(ePsi) );
+    _set_Euler_Rates( Auxiliary->GetEulerRates(FGJSBBase::ePhi),
+                      Auxiliary->GetEulerRates(FGJSBBase::eTht),
+                      Auxiliary->GetEulerRates(FGJSBBase::ePsi) );
 
     _set_Mach_number( Auxiliary->GetMach() );
 
     // Positions of Visual Reference Point
-    _updateGeocentricPosition( Auxiliary->GetLocationVRP().GetLatitude(),
-                               Auxiliary->GetLocationVRP().GetLongitude(),
-                               Auxiliary->GethVRP() );
+    FGLocation l = Auxiliary->GetLocationVRP();
+    _updateGeocentricPosition( l.GetLatitude(), l.GetLongitude(),
+                               l.GetRadius() - get_Sea_level_radius() );
 
     _set_Altitude_AGL( Propagate->GetDistanceAGL() );
+    {
+      double loc_cart[3] = { l(FGJSBBase::eX), l(FGJSBBase::eY), l(FGJSBBase::eZ) };
+      double contact[3], d[3], sd, t;
+      int id;
+      is_valid_m(&t, d, &sd);
+      get_agl_ft(t, loc_cart, contact, d, d, &id, &sd, &sd, &sd);
+      double rwrad
+        = FGColumnVector3( contact[0], contact[1], contact[2] ).Magnitude();
+      _set_Runway_altitude( rwrad - get_Sea_level_radius() );
+    }
 
-    _set_Euler_Angles( Propagate->GetEuler(ePhi),
-                       Propagate->GetEuler(eTht),
-                       Propagate->GetEuler(ePsi) );
+    _set_Euler_Angles( Propagate->GetEuler(FGJSBBase::ePhi),
+                       Propagate->GetEuler(FGJSBBase::eTht),
+                       Propagate->GetEuler(FGJSBBase::ePsi) );
 
     _set_Alpha( Auxiliary->Getalpha() );
     _set_Beta( Auxiliary->Getbeta() );
@@ -646,6 +757,28 @@ bool FGJSBsim::copy_from_JSBsim()
         globals->get_controls()->set_augmentation(i, eng->GetAugmentation() );
         } // end FGTurbine code block
         break;
+      case FGEngine::etTurboprop:
+        { // FGTurboProp code block
+        FGTurboProp* eng = (FGTurboProp*)Propulsion->GetEngine(i);
+        node->setDoubleValue("n1", eng->GetN1());
+        //node->setDoubleValue("n2", eng->GetN2());
+        node->setDoubleValue("itt_degf", 32 + eng->GetITT()*9/5);
+        node->setBoolValue("ignition", eng->GetIgnition());
+        node->setDoubleValue("nozzle-pos-norm", eng->GetNozzle());
+        node->setDoubleValue("inlet-pos-norm", eng->GetInlet());
+        node->setDoubleValue("oil-pressure-psi", eng->getOilPressure_psi());
+        node->setBoolValue("reversed", eng->GetReversed());
+        node->setBoolValue("cutoff", eng->GetCutoff());
+        node->setBoolValue("starting", eng->GetEngStarting());
+        node->setBoolValue("generator-power", eng->GetGeneratorPower());
+        node->setBoolValue("damaged", eng->GetCondition());
+        node->setBoolValue("ielu-intervent", eng->GetIeluIntervent());
+        node->setDoubleValue("oil-temperature-degf", eng->getOilTemp_degF());
+//        node->setBoolValue("onfire", eng->GetFire());
+        globals->get_controls()->set_reverser(i, eng->GetReversed() );
+        globals->get_controls()->set_cutoff(i, eng->GetCutoff() );
+        } // end FGTurboProp code block
+        break;
       case FGEngine::etElectric:
         { // FGElectric code block
         FGElectric* eng = (FGElectric*)Propulsion->GetEngine(i);
@@ -677,6 +810,7 @@ bool FGJSBsim::copy_from_JSBsim()
         tnode->setDoubleValue("rpm", thruster->GetRPM());
         tnode->setDoubleValue("pitch", prop->GetPitch());
         tnode->setDoubleValue("torque", prop->GetTorque());
+        tnode->setBoolValue("feathered", prop->GetFeather());
         } // end FGPropeller code block
         break;
       case FGThruster::ttRotor:
@@ -692,11 +826,9 @@ bool FGJSBsim::copy_from_JSBsim()
 
     }
 
-    static const SGPropertyNode *fuel_freeze = fgGetNode("/sim/freeze/fuel");
-
     // Copy the fuel levels from JSBSim if fuel
     // freeze not enabled.
-    if ( ! fuel_freeze->getBoolValue() ) {
+    if ( ! Propulsion->GetFuelFreeze() ) {
       for (i = 0; i < Propulsion->GetNumTanks(); i++) {
         SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
         FGTank* tank = Propulsion->GetTank(i);
@@ -720,23 +852,32 @@ bool FGJSBsim::copy_from_JSBsim()
     speedbrake_pos_pct->setDoubleValue( FCS->GetDsbPos(ofNorm) );
     spoilers_pos_pct->setDoubleValue( FCS->GetDspPos(ofNorm) );
 
+    // force a sim reset if crashed (altitude AGL < 0)
+    if (get_Altitude_AGL() < -100.0) {
+         fgSetBool("/sim/crashed", true);
+         SGPropertyNode* node = fgGetNode("/sim/presets", true);
+         globals->get_commands()->execute("old-reinit-dialog", node);
+    }
+
     return true;
 }
 
 
 bool FGJSBsim::ToggleDataLogging(void)
 {
-    return fdmex->GetOutput()->Toggle();
+  // ToDo: handle this properly
+  fdmex->DisableOutput();
+  return false;
 }
 
 
 bool FGJSBsim::ToggleDataLogging(bool state)
 {
     if (state) {
-      fdmex->GetOutput()->Enable();
+      fdmex->EnableOutput();
       return true;
     } else {
-      fdmex->GetOutput()->Disable();
+      fdmex->DisableOutput();
       return false;
     }
 }
@@ -766,8 +907,6 @@ void FGJSBsim::set_Latitude(double lat)
                       &sea_level_radius_meters, &lat_geoc );
     _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET  );
     fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET  );
-    _set_Runway_altitude( cur_fdm_state->get_Runway_altitude() );
-    fgic->SetTerrainAltitudeFtIC( cur_fdm_state->get_ground_elev_ft() );
     fgic->SetLatitudeRadIC( lat_geoc );
     needTrim=true;
 }
@@ -782,8 +921,6 @@ void FGJSBsim::set_Longitude(double lon)
 
     update_ic();
     fgic->SetLongitudeRadIC( lon );
-    _set_Runway_altitude( cur_fdm_state->get_Runway_altitude() );
-    fgic->SetTerrainAltitudeFtIC( cur_fdm_state->get_ground_elev_ft() );
     needTrim=true;
 }
 
@@ -804,8 +941,6 @@ void FGJSBsim::set_Altitude(double alt)
                   &sea_level_radius_meters, &lat_geoc);
     _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET  );
     fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
-    _set_Runway_altitude( cur_fdm_state->get_Runway_altitude() );
-    fgic->SetTerrainAltitudeFtIC( cur_fdm_state->get_ground_elev_ft() );
     SG_LOG(SG_FLIGHT, SG_INFO,
           "Terrain altitude: " << cur_fdm_state->get_Runway_altitude() * SG_METER_TO_FEET );
     fgic->SetLatitudeRadIC( lat_geoc );
@@ -877,9 +1012,9 @@ void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi )
     FGInterface::set_Euler_Angles(phi, theta, psi);
 
     update_ic();
-    fgic->SetPitchAngleRadIC(theta);
-    fgic->SetRollAngleRadIC(phi);
-    fgic->SetTrueHeadingRadIC(psi);
+    fgic->SetThetaRadIC(theta);
+    fgic->SetPhiRadIC(phi);
+    fgic->SetPsiRadIC(psi);
     needTrim=true;
 }
 
@@ -926,6 +1061,7 @@ void FGJSBsim::init_gear(void )
       node->setBoolValue("has-brake", gear->GetBrakeGroup() > 0);
       node->setDoubleValue("position-norm", FCS->GetGearPos());
       node->setDoubleValue("tire-pressure-norm", gear->GetTirePressure());
+      node->setDoubleValue("compression-norm", gear->GetCompLen());
       if ( gear->GetSteerable() )
         node->setDoubleValue("steering-norm", gear->GetSteerNorm());
     }
@@ -941,6 +1077,7 @@ void FGJSBsim::update_gear(void)
       node->getChild("wow", 0, true)->setBoolValue( gear->GetWOW());
       node->getChild("position-norm", 0, true)->setDoubleValue(FCS->GetGearPos());
       gear->SetTirePressure(node->getDoubleValue("tire-pressure-norm"));
+      node->setDoubleValue("compression-norm", gear->GetCompLen());
       if ( gear->GetSteerable() )
         node->setDoubleValue("steering-norm", gear->GetSteerNorm());
     }
@@ -992,9 +1129,9 @@ void FGJSBsim::update_ic(void)
      fgic->SetLongitudeRadIC( get_Longitude() );
      fgic->SetAltitudeFtIC( get_Altitude() );
      fgic->SetVcalibratedKtsIC( get_V_calibrated_kts() );
-     fgic->SetPitchAngleRadIC( get_Theta() );
-     fgic->SetRollAngleRadIC( get_Phi() );
-     fgic->SetTrueHeadingRadIC( get_Psi() );
+     fgic->SetThetaRadIC( get_Theta() );
+     fgic->SetPhiRadIC( get_Phi() );
+     fgic->SetPsiRadIC( get_Psi() );
      fgic->SetClimbRateFpsIC( get_Climb_Rate() );
    }
 }