1
0
Fork 0

Changes from Tony Peden to fix reinit crashes (and eliminate the force

altitude function).
This commit is contained in:
david 2002-02-17 21:05:27 +00:00
parent d1208f15b8
commit 93c69c4bc3
8 changed files with 31 additions and 84 deletions

View file

@ -79,8 +79,6 @@ FGLaRCsim::~FGLaRCsim(void) {
void FGLaRCsim::init() {
//do init common to all FDM's
common_init();
//now do any specific to LaRCsim
}
@ -566,20 +564,6 @@ void FGLaRCsim::set_ls(void) {
V_down_airmass = lsic->GetVdownAirmassFpsIC();
ls_loop(0.0,-1);
copy_from_LaRCsim();
SG_LOG( SG_FLIGHT, SG_INFO, " FGLaRCsim::set_ls(): " );
SG_LOG( SG_FLIGHT, SG_INFO, " Phi: " << Phi );
SG_LOG( SG_FLIGHT, SG_INFO, " Theta: " << Theta );
SG_LOG( SG_FLIGHT, SG_INFO, " Psi: " << Psi );
SG_LOG( SG_FLIGHT, SG_INFO, " V_north: " << V_north );
SG_LOG( SG_FLIGHT, SG_INFO, " V_east: " << V_east );
SG_LOG( SG_FLIGHT, SG_INFO, " V_down: " << V_down );
SG_LOG( SG_FLIGHT, SG_INFO, " Altitude: " << Altitude );
SG_LOG( SG_FLIGHT, SG_INFO, " Latitude: " << Latitude );
SG_LOG( SG_FLIGHT, SG_INFO, " Longitude: " << Longitude );
SG_LOG( SG_FLIGHT, SG_INFO, " Runway_altitude: " << Runway_altitude );
SG_LOG( SG_FLIGHT, SG_INFO, " V_north_airmass: " << V_north_airmass );
SG_LOG( SG_FLIGHT, SG_INFO, " V_east_airmass: " << V_east_airmass );
SG_LOG( SG_FLIGHT, SG_INFO, " V_down_airmass: " << V_down_airmass );
}
void FGLaRCsim::snap_shot(void) {
@ -601,6 +585,7 @@ void FGLaRCsim::snap_shot(void) {
void FGLaRCsim::set_Latitude(double lat) {
SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Latitude: " << lat );
snap_shot();
_set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET );
lsic->SetLatitudeGDRadIC(lat);
set_ls();
copy_from_LaRCsim(); //update the bus
@ -609,6 +594,8 @@ void FGLaRCsim::set_Latitude(double lat) {
void FGLaRCsim::set_Longitude(double lon) {
SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Longitude: " << lon );
snap_shot();
_set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET );
lsic->SetLongitudeRadIC(lon);
set_ls();
copy_from_LaRCsim(); //update the bus
@ -617,6 +604,7 @@ void FGLaRCsim::set_Longitude(double lon) {
void FGLaRCsim::set_Altitude(double alt) {
SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Altitude: " << alt );
snap_shot();
_set_Runway_altitude( scenery.get_cur_elev() * SG_METER_TO_FEET );
lsic->SetAltitudeFtIC(alt);
set_ls();
copy_from_LaRCsim(); //update the bus
@ -687,14 +675,6 @@ void FGLaRCsim::set_Gamma_vert_rad( double gamma) {
copy_from_LaRCsim(); //update the bus
}
void FGLaRCsim::set_Runway_altitude(double ralt) {
SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_Runway_altitude: " << ralt );
snap_shot();
lsic->SetRunwayAltitudeFtIC(ralt);
set_ls();
copy_from_LaRCsim(); //update the bus
}
void FGLaRCsim::set_AltitudeAGL(double altagl) {
SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::set_AltitudeAGL: " << altagl );
snap_shot();

View file

@ -80,7 +80,6 @@ public:
void set_Gamma_vert_rad( double gamma);
// Earth
void set_Runway_altitude(double ralt);
void set_Static_pressure(double p);
void set_Static_temperature(double T);
void set_Density(double rho);

View file

@ -99,15 +99,11 @@ void LaRCsimIC::SetClimbRateFpmIC( SCALAR tt) {
void LaRCsimIC::SetClimbRateFpsIC( SCALAR tt) {
vtg=vt+vw;
cout << "vtg: " << vtg << endl;
if(vtg > 0.1) {
hdot = tt - vdownwind;
gamma=asin(hdot/vtg);
getTheta();
vdown=-1*hdot;
cout << "hdot: " << hdot << endl;
cout << "gamma: " << gamma*SGD_RADIANS_TO_DEGREES << endl;
cout << "vdown: " << vdown << endl;
}
}
@ -116,7 +112,6 @@ void LaRCsimIC::SetFlightPathAngleRadIC( SCALAR tt) {
getTheta();
vtg=vt+vw;
hdot=vtg*sin(tt);
cout << "hdot: " << hdot << endl;
vdown=-1*hdot;
}

View file

@ -227,7 +227,7 @@ void YASim::copyToYASim(bool copyState)
// The ground elevation doesn't come from FGInterface; query it
// from the scenery and set it for others to find.
double ground = scenery.get_cur_elev();
set_Runway_altitude(ground * FT2M);
_set_Runway_altitude(ground * FT2M);
// cout << "YASIM: ground = " << ground << endl;
// You'd this this would work, but it doesn't. These values are

View file

@ -188,10 +188,6 @@ FGInterface::common_init ()
SG_LOG( SG_FLIGHT, SG_INFO,
"...initializing ground elevation to " << ground_elev_ft
<< "ft..." );
SG_LOG( SG_FLIGHT, SG_INFO, "common_init(): set ground elevation "
<< ground_elev_ft );
base_fdm_state.set_Runway_altitude( ground_elev_ft );
set_Runway_altitude( ground_elev_ft );
// Set sea-level radius
SG_LOG( SG_FLIGHT, SG_INFO, "...initializing sea-level radius..." );
@ -204,7 +200,7 @@ FGInterface::common_init ()
* SGD_DEGREES_TO_RADIANS,
fgGetDouble("/position/altitude-ft") * SG_FEET_TO_METER,
&sea_level_radius_meters, &lat_geoc );
set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
_set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET );
// Set initial velocities
SG_LOG( SG_FLIGHT, SG_INFO, "...initializing velocities..." );
@ -358,6 +354,14 @@ FGInterface::bind ()
&FGInterface::get_Climb_Rate); // read-only
fgTie("/velocities/side-slip-rad", this,
&FGInterface::get_Beta); // read-only
fgTie("/velocities/side-slip-deg", this,
&FGInterface::get_Beta_deg); // read-only
fgTie("/velocities/alpha-deg", this,
&FGInterface::get_Alpha_deg); // read-only
fgTie("/accelerations/nlf", this,
&FGInterface::get_Nlf); // read-only
}
@ -392,6 +396,10 @@ FGInterface::unbind ()
fgUntie("/velocities/wBody-fps");
fgUntie("/velocities/vertical-speed-fps");
fgUntie("/velocities/side-slip-rad");
fgUntie("/velocities/side-slip-deg");
fgUntie("/velocities/alpha-deg");
fgUntie("/accelerations/nlf");
}
/**
@ -540,35 +548,6 @@ void FGInterface::extrapolate( int time_offset ) {
geocentric_position_v[2] = radius;
}
// Set the altitude (force)
void fgFDMForceAltitude(const string &model, double alt_meters) {
SG_LOG(SG_FLIGHT,SG_INFO, "fgFDMForceAltitude: " << alt_meters );
double sea_level_radius_meters;
double lat_geoc;
// Set the FG variables first
sgGeodToGeoc( base_fdm_state.get_Latitude(), alt_meters,
&sea_level_radius_meters, &lat_geoc);
base_fdm_state.set_Altitude( alt_meters * SG_METER_TO_FEET );
base_fdm_state.set_Sea_level_radius( sea_level_radius_meters *
SG_METER_TO_FEET );
cur_fdm_state->set_Altitude( alt_meters * SG_METER_TO_FEET );
cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters *
SG_METER_TO_FEET );
cur_fdm_state->set_Runway_altitude( scenery.get_cur_elev() *
SG_METER_TO_FEET );
// additional work needed for some flight models
if ( model == "larcsim" ) {
ls_ForceAltitude( base_fdm_state.get_Altitude() );
}
}
// Positions
void FGInterface::set_Latitude(double lat) {
geodetic_position_v[0] = lat;
@ -629,15 +608,6 @@ void FGInterface::set_Gamma_vert_rad( double gamma) {
gamma_vert_rad = gamma;
}
// Earth
void FGInterface::set_Sea_level_radius(double slr) {
sea_level_radius = slr;
}
void FGInterface::set_Runway_altitude(double ralt) {
runway_altitude = ralt;
}
void FGInterface::set_Static_pressure(double p) { static_pressure = p; }
void FGInterface::set_Static_temperature(double T) { static_temperature = T; }
void FGInterface::set_Density(double rho) { density = rho; }

View file

@ -513,8 +513,6 @@ public:
virtual void set_Gamma_vert_rad( double gamma);
// Earth
virtual void set_Sea_level_radius(double slr);
virtual void set_Runway_altitude(double ralt);
virtual void set_Static_pressure(double p);
virtual void set_Static_temperature(double T);
@ -693,7 +691,7 @@ public:
// n_pilot_body_v[2] = z;
// }
inline double get_Nlf(void) { return nlf; }
inline double get_Nlf(void) const { return nlf; }
// inline double * get_Omega_dot_body_v() { return omega_dot_body_v; }
// inline double get_P_dot_body() const { return omega_dot_body_v[0]; }
@ -912,7 +910,9 @@ public:
// }
inline double get_Alpha() const { return alpha; }
inline double get_Alpha_deg() const { return alpha * SGD_RADIANS_TO_DEGREES; }
inline double get_Beta() const { return beta; }
inline double get_Beta_deg() const { return beta * SGD_RADIANS_TO_DEGREES; }
inline double get_Alpha_dot() const { return alpha_dot; }
// inline void set_Alpha_dot( double ad ) { alpha_dot = ad; }
inline double get_Beta_dot() const { return beta_dot; }
@ -1081,8 +1081,6 @@ extern FGInterface * cur_fdm_state;
// General interface to the flight model routines
// Set the altitude (force)
void fgFDMForceAltitude(const string &model, double alt_meters);
// Toggle data logging on/off
void fgToggleFDMdataLogging(void);

View file

@ -1017,6 +1017,10 @@ void fgReInitSubsystems( void )
#endif
fgInitFDM();
// allocates structures so must happen before any of the flight
// model or control parameters are set
fgAircraftInit(); // In the future this might not be the case.
fgInitView();

View file

@ -883,7 +883,7 @@ void fgUpdateTimeDepCalcs() {
static const SGPropertyNode *master_freeze
= fgGetNode("/sim/freeze/master");
// cout << "Updating time dep calcs()" << endl;
//SG_LOG(SG_FLIGHT,SG_INFO, "Updating time dep calcs()");
fgLIGHT *l = &cur_light_params;
int i;
@ -897,7 +897,8 @@ void fgUpdateTimeDepCalcs() {
// << " cur_elev = " << scenery.get_cur_elev() << endl;
if ( !cur_fdm_state->get_inited() && scenery.get_cur_elev() > -9990 ) {
cout << "Finally initializing fdm" << endl;
SG_LOG(SG_FLIGHT,SG_INFO, "Finally initializing fdm");
cur_fdm_state->init();
if ( cur_fdm_state->get_bound() ) {
cur_fdm_state->unbind();
@ -1061,8 +1062,8 @@ static void fgMainLoop( void ) {
cur_fdm_state->get_Altitude() * SG_FEET_TO_METER,
scenery.get_cur_elev() + alt_adjust_m - 3.0,
scenery.get_cur_elev() + alt_adjust_m );
fgFDMForceAltitude( fgGetString("/sim/flight-model"),
scenery.get_cur_elev() + alt_adjust_m );
cur_fdm_state->set_Altitude( scenery.get_cur_elev()
+ alt_adjust_m );
SG_LOG( SG_ALL, SG_DEBUG,
"<*> resetting altitude to "
@ -1716,7 +1717,7 @@ int mainLoop( int argc, char **argv ) {
// build our custom render states
fgBuildRenderStates();
// pass control off to the master GLUT event handler
glutMainLoop();