From: david Date: Sun, 17 Feb 2002 21:04:44 +0000 (+0000) Subject: Latest JSBSim changes. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d1208f15b896d09e2300a9adc330281fc8621be2;p=flightgear.git Latest JSBSim changes. --- diff --git a/src/FDM/JSBSim.cxx b/src/FDM/JSBSim.cxx index aba3ad761..926d9d34f 100644 --- a/src/FDM/JSBSim.cxx +++ b/src/FDM/JSBSim.cxx @@ -174,9 +174,7 @@ void FGJSBsim::init() { common_init(); copy_to_JSBsim(); - fdmex->GetState()->Initialize(fgic); fdmex->RunIC(fgic); //loop JSBSim once w/o integrating - // fdmex->Run(); //loop JSBSim once copy_from_JSBsim(); //update the bus SG_LOG( SG_FLIGHT, SG_INFO, " Initialized JSBSim with:" ); @@ -320,8 +318,9 @@ bool FGJSBsim::copy_to_JSBsim() { eng->SetStarter( globals->get_controls()->get_starter(i) ); } + _set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET ); Position->SetSeaLevelRadius( get_Sea_level_radius() ); - Position->SetRunwayRadius( scenery.get_cur_elev()*SG_METER_TO_FEET + Position->SetRunwayRadius( get_Runway_altitude() + get_Sea_level_radius() ); Atmosphere->SetExTemperature(get_Static_temperature()); @@ -506,21 +505,24 @@ bool FGJSBsim::ToggleDataLogging(bool state) { void FGJSBsim::set_Latitude(double lat) { static const SGPropertyNode *altitude = fgGetNode("/position/altitude-ft"); double alt; + double sea_level_radius_meters, lat_geoc; + if ( altitude->getDoubleValue() > -9990 ) { alt = altitude->getDoubleValue(); } else { alt = 0.0; } - - double sea_level_radius_meters, lat_geoc; - + + update_ic(); SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Latitude: " << lat ); SG_LOG(SG_FLIGHT,SG_INFO," cur alt (ft) = " << alt ); - sgGeodToGeoc( lat, alt * SG_FEET_TO_METER, &sea_level_radius_meters, &lat_geoc ); - + sgGeodToGeoc( lat, alt * SG_FEET_TO_METER, + &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 ); + fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET ); + _set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET ); + fgic->SetTerrainAltitudeFtIC( scenery.get_cur_elev() * SG_METER_TO_FEET ); fgic->SetLatitudeRadIC( lat_geoc ); needTrim=true; } @@ -528,8 +530,10 @@ void FGJSBsim::set_Latitude(double lat) { void FGJSBsim::set_Longitude(double lon) { SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Longitude: " << lon ); - + update_ic(); fgic->SetLongitudeRadIC( lon ); + _set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET ); + fgic->SetTerrainAltitudeFtIC( scenery.get_cur_elev() * SG_METER_TO_FEET ); needTrim=true; } @@ -540,11 +544,14 @@ void FGJSBsim::set_Altitude(double alt) { SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Altitude: " << alt ); SG_LOG(SG_FLIGHT,SG_INFO, " lat (deg) = " << latitude->getDoubleValue() ); - + + update_ic(); sgGeodToGeoc( latitude->getDoubleValue() * SGD_DEGREES_TO_RADIANS, alt, - &sea_level_radius_meters, &lat_geoc); + &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( scenery.get_cur_elev() * SG_METER_TO_FEET ); + fgic->SetTerrainAltitudeFtIC( scenery.get_cur_elev() * SG_METER_TO_FEET ); fgic->SetLatitudeRadIC( lat_geoc ); fgic->SetAltitudeFtIC(alt); needTrim=true; @@ -552,14 +559,16 @@ void FGJSBsim::set_Altitude(double alt) { void FGJSBsim::set_V_calibrated_kts(double vc) { SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_V_calibrated_kts: " << vc ); - + + update_ic(); fgic->SetVcalibratedKtsIC(vc); needTrim=true; } void FGJSBsim::set_Mach_number(double mach) { SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Mach_number: " << mach ); - + + update_ic(); fgic->SetMachIC(mach); needTrim=true; } @@ -567,7 +576,8 @@ void FGJSBsim::set_Mach_number(double mach) { void FGJSBsim::set_Velocities_Local( double north, double east, double down ){ SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Local: " << north << ", " << east << ", " << down ); - + + update_ic(); fgic->SetVnorthFpsIC(north); fgic->SetVeastFpsIC(east); fgic->SetVdownFpsIC(down); @@ -577,7 +587,8 @@ void FGJSBsim::set_Velocities_Local( double north, double east, double down ){ void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w){ SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Wind_Body: " << u << ", " << v << ", " << w ); - + + update_ic(); fgic->SetUBodyFpsIC(u); fgic->SetVBodyFpsIC(v); fgic->SetWBodyFpsIC(w); @@ -588,7 +599,8 @@ void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w){ void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi ) { SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Euler_Angles: " << phi << ", " << theta << ", " << psi ); - + + update_ic(); fgic->SetPitchAngleRadIC(theta); fgic->SetRollAngleRadIC(phi); fgic->SetTrueHeadingRadIC(psi); @@ -598,40 +610,27 @@ void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi ) { //Flight Path void FGJSBsim::set_Climb_Rate( double roc) { SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Climb_Rate: " << roc ); - + + update_ic(); fgic->SetClimbRateFpsIC(roc); needTrim=true; } void FGJSBsim::set_Gamma_vert_rad( double gamma) { SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Gamma_vert_rad: " << gamma ); - + + update_ic(); fgic->SetFlightPathAngleRadIC(gamma); needTrim=true; } -//Earth -void FGJSBsim::set_Sea_level_radius(double slr) { - SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Sea_level_radius: " << slr ); - - fgic->SetSeaLevelRadiusFtIC(slr); - needTrim=true; -} - -void FGJSBsim::set_Runway_altitude(double ralt) { - SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Runway_altitude: " << ralt ); - - _set_Runway_altitude( ralt ); - fgic->SetTerrainAltitudeFtIC( ralt ); - needTrim=true; -} - void FGJSBsim::set_Static_pressure(double p) { SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Static_pressure: " << p ); - + + update_ic(); Atmosphere->SetExPressure(p); if(Atmosphere->External() == true) - needTrim=true; + needTrim=true; } void FGJSBsim::set_Static_temperature(double T) { @@ -639,7 +638,7 @@ void FGJSBsim::set_Static_temperature(double T) { Atmosphere->SetExTemperature(T); if(Atmosphere->External() == true) - needTrim=true; + needTrim=true; } @@ -648,7 +647,7 @@ void FGJSBsim::set_Density(double rho) { Atmosphere->SetExDensity(rho); if(Atmosphere->External() == true) - needTrim=true; + needTrim=true; } void FGJSBsim::set_Velocities_Local_Airmass (double wnorth, @@ -658,7 +657,7 @@ void FGJSBsim::set_Velocities_Local_Airmass (double wnorth, << wnorth << ", " << weast << ", " << wdown ); _set_Velocities_Local_Airmass( wnorth, weast, wdown ); - Atmosphere->SetWindNED(wnorth, weast, wdown ); + fgic->SetWindNEDFpsIC( wnorth, weast, wdown ); if(Atmosphere->External() == true) needTrim=true; } @@ -726,3 +725,16 @@ void FGJSBsim::do_trim(void) { SG_LOG( SG_FLIGHT, SG_INFO, " Trim complete" ); } + +void FGJSBsim::update_ic(void) { + if( !needTrim ) { + fgic->SetLatitudeRadIC(get_Lat_geocentric() ); + 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->SetClimbRateFpsIC( get_Climb_Rate() ); + } +} diff --git a/src/FDM/JSBSim.hxx b/src/FDM/JSBSim.hxx index b2da20edf..55dcbc453 100644 --- a/src/FDM/JSBSim.hxx +++ b/src/FDM/JSBSim.hxx @@ -176,16 +176,6 @@ public: void set_Gamma_vert_rad( double gamma); //@} - /// @name Earth Parameter Set - //@{ - /** Sets the sea level radius in feet. - @param slr Sea Level Radius in feet */ - void set_Sea_level_radius(double slr); - - /** Sets the runway altitude in feet above sea level. - @param ralt Runway altitude in feet above sea level. */ - void set_Runway_altitude(double ralt); - //@} /// @name Atmospheric Parameter Set //@{ @@ -219,6 +209,7 @@ public: bool ToggleDataLogging(bool state); bool ToggleDataLogging(void); void do_trim(void); + void update_ic(void); private: FGFDMExec *fdmex; diff --git a/src/FDM/JSBSim/FGCoefficient.cpp b/src/FDM/JSBSim/FGCoefficient.cpp index fa6973a65..55639c31f 100644 --- a/src/FDM/JSBSim/FGCoefficient.cpp +++ b/src/FDM/JSBSim/FGCoefficient.cpp @@ -246,7 +246,7 @@ void FGCoefficient::DisplayCoeffFactors(void) cout << "none" << endl; } else { for (i=0; iGetState()->paramdef[multipliers[i]]; + cout << State->GetParameterName(multipliers[i]); } cout << endl; } diff --git a/src/FDM/JSBSim/FGFCS.cpp b/src/FDM/JSBSim/FGFCS.cpp index d95e3d8c0..1e304e2aa 100644 --- a/src/FDM/JSBSim/FGFCS.cpp +++ b/src/FDM/JSBSim/FGFCS.cpp @@ -256,7 +256,7 @@ bool FGFCS::Load(FGConfigFile* AC_cfg) while ((token = AC_cfg->GetValue()) != string("/FLIGHT_CONTROL")) { if (token == "COMPONENT") { token = AC_cfg->GetValue("TYPE"); - if (debug_lvl > 0) cout << " Loading Component \"" + if (debug_lvl > 0) cout << endl << " Loading Component \"" << AC_cfg->GetValue("NAME") << "\" of type: " << token << endl; if ((token == "LAG_FILTER") || diff --git a/src/FDM/JSBSim/FGScript.cpp b/src/FDM/JSBSim/FGScript.cpp index 19a105039..25e1dc685 100644 --- a/src/FDM/JSBSim/FGScript.cpp +++ b/src/FDM/JSBSim/FGScript.cpp @@ -338,14 +338,14 @@ void FGScript::Debug(int from) for (i=0; iTestValue.size(); i++) { if (i>0) cout << " and" << endl << " "; - cout << "(" << State->paramdef[iterConditions->TestParam[i]] + cout << "(" << State->GetParameterName(iterConditions->TestParam[i]) << iterConditions->Comparison[i] << " " << iterConditions->TestValue[i] << ")"; } cout << ") then {"; for (i=0; iSetValue.size(); i++) { - cout << endl << " set" << State->paramdef[iterConditions->SetParam[i]] + cout << endl << " set" << State->GetParameterName(iterConditions->SetParam[i]) << "to " << iterConditions->SetValue[i]; switch (iterConditions->Type[i]) { diff --git a/src/FDM/JSBSim/FGState.h b/src/FDM/JSBSim/FGState.h index b3e7267e5..05c9a6025 100644 --- a/src/FDM/JSBSim/FGState.h +++ b/src/FDM/JSBSim/FGState.h @@ -211,6 +211,12 @@ public: */ inline void Seta(double speed) { a = speed; } + /** Gets the name of the parameter given the index. + @param val_idx one of the enumerated JSBSim parameters. + @return the name of the parameter pointed to by the index. + */ + string GetParameterName(eParam val_idx) {return paramdef[val_idx];} + /** Sets the current sim time. @param cur_time the current time @return the current time. @@ -303,10 +309,6 @@ public: */ void ReportState(void); - - typedef map ParamMap; - ParamMap paramdef; - private: double a; // speed of sound double sim_time, dt; @@ -340,6 +342,10 @@ private: typedef map CoeffMap; CoeffMap coeffdef; + + typedef map ParamMap; + ParamMap paramdef; + int ActiveEngine; void Debug(int from); }; diff --git a/src/FDM/JSBSim/filtersjb/FGFilter.cpp b/src/FDM/JSBSim/filtersjb/FGFilter.cpp index f1b916196..1af9dc1dd 100644 --- a/src/FDM/JSBSim/filtersjb/FGFilter.cpp +++ b/src/FDM/JSBSim/filtersjb/FGFilter.cpp @@ -213,7 +213,15 @@ void FGFilter::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor cout << " ID: " << ID << endl; - cout << " INPUT: " << InputIdx << endl; + switch(InputType) { + case itPilotAC: + cout << " INPUT: " << fcs->GetState()->GetParameterName(InputIdx) << endl; + break; + case itFCS: + cout << " INPUT: FCS Component " << InputIdx << " (" << + fcs->GetComponentName(InputIdx) << ")" << endl; + break; + } cout << " C1: " << C1 << endl; cout << " C2: " << C2 << endl; cout << " C3: " << C3 << endl; diff --git a/src/FDM/JSBSim/filtersjb/FGGain.cpp b/src/FDM/JSBSim/filtersjb/FGGain.cpp index 89324b590..b2548f8d7 100644 --- a/src/FDM/JSBSim/filtersjb/FGGain.cpp +++ b/src/FDM/JSBSim/filtersjb/FGGain.cpp @@ -166,7 +166,15 @@ void FGGain::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor cout << " ID: " << ID << endl; - cout << " INPUT: " << InputIdx << endl; + switch(InputType) { + case itPilotAC: + cout << " INPUT: " << State->GetParameterName(InputIdx) << endl; + break; + case itFCS: + cout << " INPUT: FCS Component " << InputIdx << " (" << + fcs->GetComponentName(InputIdx) << ")" << endl; + break; + } cout << " GAIN: " << Gain << endl; if (IsOutput) cout << " OUTPUT: " << sOutputIdx << endl; cout << " MIN: " << Min << endl; diff --git a/src/FDM/JSBSim/filtersjb/FGKinemat.cpp b/src/FDM/JSBSim/filtersjb/FGKinemat.cpp index 963b13574..15375be44 100644 --- a/src/FDM/JSBSim/filtersjb/FGKinemat.cpp +++ b/src/FDM/JSBSim/filtersjb/FGKinemat.cpp @@ -146,7 +146,7 @@ bool FGKinemat::Run(void ) { else output_transit_rate=(Detents[fi] - Detents[fi+1])/5; } - if(fabs(OutputPos - InputCmd) > dt*output_transit_rate) + if(fabs(OutputPos - InputCmd) > fabs(dt*output_transit_rate) ) OutputPos+=output_transit_rate*dt; else { InTransit=0; diff --git a/src/FDM/JSBSim/filtersjb/FGSummer.cpp b/src/FDM/JSBSim/filtersjb/FGSummer.cpp index dba37c458..b033e450b 100644 --- a/src/FDM/JSBSim/filtersjb/FGSummer.cpp +++ b/src/FDM/JSBSim/filtersjb/FGSummer.cpp @@ -168,7 +168,18 @@ void FGSummer::Debug(int from) cout << " ID: " << ID << endl; cout << " INPUTS: " << endl; for (unsigned i=0;iGetState()->GetParameterName(InputIndices[i]) << endl; + break; + case itFCS: + cout << " FCS Component " << InputIndices[i] << " (" << + fcs->GetComponentName(InputIndices[i]) << ")" << endl; + break; + case itBias: + cout << " " << "Bias of " << Bias << endl; + break; + } } if (clipmax > clipmin) cout << " CLIPTO: " << clipmin << ", " << clipmax << endl;