1
0
Fork 0

Updates to track current JSBSim cvs.

This commit is contained in:
curt 2000-10-12 01:06:31 +00:00
parent f5cc3b9b9c
commit 72a09d198c
3 changed files with 71 additions and 35 deletions

View file

@ -60,6 +60,10 @@
// 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++ ) {

View 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;
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;
FirstModel = 0L;
Error = 0;
State = 0;
Atmosphere = 0;
FCS = 0;
Aircraft = 0;
Translation = 0;
Rotation = 0;
Position = 0;
Auxiliary = 0;
Output = 0;
allocated = false;
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;
}

View file

@ -96,8 +96,8 @@ public:
private:
bool frozen;
bool terminate;
bool allocated;
int Error;
bool modelLoaded;
string AircraftPath;
string EnginePath;