]> git.mxchange.org Git - flightgear.git/commitdiff
Updates to track current JSBSim cvs.
authorcurt <curt>
Thu, 12 Oct 2000 01:06:31 +0000 (01:06 +0000)
committercurt <curt>
Thu, 12 Oct 2000 01:06:31 +0000 (01:06 +0000)
src/FDM/JSBSim.cxx
src/FDM/JSBSim/FGFDMExec.cpp
src/FDM/JSBSim/FGFDMExec.h

index a23e88bee7026c101a038cb88193db06674252af..48efe4341bba3fcd116d9ffa1d348f9bbbb1a45b 100644 (file)
 // Initialize the JSBsim flight model, dt is the time increment for
 // each subsequent iteration through the EOM
 
+static bool trimmed = false;
+static bool trim_elev = false;
+static bool trim_throttle = false;
+
 int FGJSBsim::init( double dt ) {
 
   bool result;
@@ -73,12 +77,13 @@ int FGJSBsim::init( double dt ) {
   FGPath engine_path( current_options.get_fg_root() );
   engine_path.append( "Engine" );
 
-  FDMExec.GetState()->Setdt( dt );
+  //FDMExec.GetState()->Setdt( dt );
 
   result = FDMExec.LoadModel( aircraft_path.str(),
                                        engine_path.str(),
                                        current_options.get_aircraft() );
-
+  FDMExec.GetState()->Setdt( dt );
+  
   if (result) {
     FG_LOG( FG_FLIGHT, FG_INFO, "  loaded aircraft " << current_options.get_aircraft() );
   } else {
@@ -160,9 +165,12 @@ int FGJSBsim::init( double dt ) {
 
     controls.set_elevator_trim(FDMExec.GetFCS()->GetPitchTrimCmd());
     controls.set_throttle(FGControls::ALL_ENGINES,FDMExec.GetFCS()->GetThrottleCmd(0)/100);
+    trimmed=true;
+    trim_elev=FDMExec.GetFCS()->GetPitchTrimCmd();
+    trim_throttle=FDMExec.GetFCS()->GetThrottleCmd(0)/100;
     //the trimming routine only knows how to get 1 value for throttle
     
-//    delete fgtrim;
+    delete fgtrim;
     FG_LOG( FG_FLIGHT, FG_INFO, "  Trim complete." );
   } else {
     FG_LOG( FG_FLIGHT, FG_INFO, "  Initializing without trim" );
@@ -198,7 +206,19 @@ int FGJSBsim::update( int multiloop ) {
     save_alt = get_Altitude();
     set_Altitude( 0.0 );
   }
-
+  
+  if(trimmed) {
+    
+    controls.set_elevator_trim(trim_elev);
+    controls.set_throttle(FGControls::ALL_ENGINES,trim_throttle);
+    
+    controls.set_elevator(0.0);
+    controls.set_aileron(0.0);
+    controls.set_rudder(0.0);
+    trimmed=false;
+    
+  } 
+  
   copy_to_JSBsim();
 
   for ( int i = 0; i < multiloop; i++ ) {
index 0eab1d6d00201ca0622a1de6d86d0912105847e5..6c936cf448b948511b927eb5b6f7f84c93417a7f 100644 (file)
@@ -84,9 +84,12 @@ FGFDMExec::FGFDMExec(void)
   Auxiliary   = 0;
   Output      = 0;
 
-  allocated = false;
   terminate = false;
   frozen = false;
+  modelLoaded = false;
+  
+  Allocate();
+  
 }
 
 FGFDMExec::~FGFDMExec(void){
@@ -97,6 +100,7 @@ FGFDMExec::~FGFDMExec(void){
 
 bool FGFDMExec::Allocate(void) {
   
+  cout << "FGFDMExec::Allocate ... ";
   bool result=true;
   
   Atmosphere  = new FGAtmosphere(this);
@@ -136,40 +140,41 @@ bool FGFDMExec::Allocate(void) {
   Schedule(Auxiliary,   1);
   Schedule(Output,     1);
   
-  allocated = true;
-  
+  modelLoaded = false;
+  cout << "done." << endl;
   return result;
 
 }
 
 bool FGFDMExec::DeAllocate(void) {
-  if(allocated) {
-    if ( Atmosphere != 0 )  delete Atmosphere;
-    if ( FCS != 0 )         delete FCS;
-    if ( Aircraft != 0 )    delete Aircraft;
-    if ( Translation != 0 ) delete Translation;
-    if ( Rotation != 0 )    delete Rotation;
-    if ( Position != 0 )    delete Position;
-    if ( Auxiliary != 0 )   delete Auxiliary;
-    if ( Output != 0 )      delete Output;
-    if ( State != 0 )       delete State;
-
-    FirstModel  = 0L;
-    Error       = 0;
-
-    State       = 0;
-    Atmosphere  = 0;
-    FCS         = 0;
-    Aircraft    = 0;
-    Translation = 0;
-    Rotation    = 0;
-    Position    = 0;
-    Auxiliary   = 0;
-    Output      = 0;
-    
-    allocated = false;
+  cout << "FGFDMExec::DeAllocate ... ";
+  if ( Atmosphere != 0 )  delete Atmosphere;
+  if ( FCS != 0 )         delete FCS;
+  if ( Aircraft != 0 )    delete Aircraft;
+  if ( Translation != 0 ) delete Translation;
+  if ( Rotation != 0 )    delete Rotation;
+  if ( Position != 0 )    delete Position;
+  if ( Auxiliary != 0 )   delete Auxiliary;
+  if ( Output != 0 )      delete Output;
+  if ( State != 0 )       delete State;
+
+  FirstModel  = 0L;
+  Error       = 0;
+
+  State       = 0;
+  Atmosphere  = 0;
+  FCS         = 0;
+  Aircraft    = 0;
+  Translation = 0;
+  Rotation    = 0;
+  Position    = 0;
+  Auxiliary   = 0;
+  Output      = 0;
+
+  modelLoaded = false;
   
-  }
+  cout << "done" << endl;
 }
 
 
@@ -231,11 +236,22 @@ bool FGFDMExec::RunIC(FGInitialCondition *fgic)
 
 bool FGFDMExec::LoadModel(string APath, string EPath, string model)
 {
-       DeAllocate();
-  Allocate();
+       bool result=false;
+  cout << "FGFDMExec::LoadModel ..." << endl;
+  if(modelLoaded) {
+     DeAllocate();
+     Allocate();
+  }   
   AircraftPath = APath;
        EnginePath = EPath;
-  return Aircraft->LoadAircraft(AircraftPath, EnginePath, model);
+  result = Aircraft->LoadAircraft(AircraftPath, EnginePath, model);
+  if(result) {
+    modelLoaded=true;
+  } else {
+    cerr << "FGFDMExec: Failed to load aircraft and/or engine model" << endl;
+  }  
+  cout << "FGFDMExec::LoadModel complete." << endl;;
+  return result;
 }
 
 
index 3eebd503ef13716a9f620a8766719aac88862466..b2289e2bdd3f62f3c3444810a25b1cc0dad9d6c6 100644 (file)
@@ -96,8 +96,8 @@ public:
 private:
   bool frozen;
   bool terminate;
-  bool allocated;
   int Error;
+  bool modelLoaded;
 
   string AircraftPath;
   string EnginePath;