Latest JSBSim changes.
This commit is contained in:
parent
b26c690e01
commit
d1208f15b8
10 changed files with 98 additions and 62 deletions
|
@ -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() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -246,7 +246,7 @@ void FGCoefficient::DisplayCoeffFactors(void)
|
|||
cout << "none" << endl;
|
||||
} else {
|
||||
for (i=0; i<multipliers.size(); i++)
|
||||
cout << FDMExec->GetState()->paramdef[multipliers[i]];
|
||||
cout << State->GetParameterName(multipliers[i]);
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
|
|
@ -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") ||
|
||||
|
|
|
@ -338,14 +338,14 @@ void FGScript::Debug(int from)
|
|||
|
||||
for (i=0; i<iterConditions->TestValue.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; i<iterConditions->SetValue.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]) {
|
||||
|
|
|
@ -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<eParam, string> ParamMap;
|
||||
ParamMap paramdef;
|
||||
|
||||
private:
|
||||
double a; // speed of sound
|
||||
double sim_time, dt;
|
||||
|
@ -340,6 +342,10 @@ private:
|
|||
|
||||
typedef map<string, eParam> CoeffMap;
|
||||
CoeffMap coeffdef;
|
||||
|
||||
typedef map<eParam, string> ParamMap;
|
||||
ParamMap paramdef;
|
||||
|
||||
int ActiveEngine;
|
||||
void Debug(int from);
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -168,7 +168,18 @@ void FGSummer::Debug(int from)
|
|||
cout << " ID: " << ID << endl;
|
||||
cout << " INPUTS: " << endl;
|
||||
for (unsigned i=0;i<InputIndices.size();i++) {
|
||||
cout << " " << InputIndices[i] << endl;
|
||||
switch (InputTypes[i]) {
|
||||
case itPilotAC:
|
||||
cout << " " << fcs->GetState()->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;
|
||||
|
|
Loading…
Add table
Reference in a new issue