// (Log is kept at end of this file)
-#define FDM_MAIN
-#include <FDM/JSBsim/FGFDMExec.h>
-#undef FDM_MAIN
+#include <Include/compiler.h>
-#include "JSBsim.hxx"
+#include STL_STRING
#include <Aircraft/aircraft.hxx>
#include <Controls/controls.hxx>
#include <Debug/logstream.hxx>
#include <Include/fg_constants.h>
+#include <Main/options.hxx>
#include <Math/fg_geodesy.hxx>
+#include <FDM/JSBsim/FGFDMExec.h>
+#include <FDM/JSBsim/FGAircraft.h>
+#include <FDM/JSBsim/FGFCS.h>
+#include <FDM/JSBsim/FGPosition.h>
+#include <FDM/JSBsim/FGRotation.h>
+#include <FDM/JSBsim/FGState.h>
+#include <FDM/JSBsim/FGTranslation.h>
+
+#include "JSBsim.hxx"
+
+
+// The default aircraft
+FGFDMExec FDMExec;
+
// Initialize the JSBsim flight model, dt is the time increment for
// each subsequent iteration through the EOM
int fgJSBsimInit(double dt) {
FG_LOG( FG_FLIGHT, FG_INFO, "Starting initializing JSBsim" );
- FDMExec = new FGFDMExec();
FG_LOG( FG_FLIGHT, FG_INFO, " created FDMExec" );
- Aircraft->LoadAircraft("X15");
+ string aircraft_path = current_options.get_fg_root() + "/Aircraft";
+ string engine_path = current_options.get_fg_root() + "/Engine";
+
+ FDMExec.GetAircraft()->LoadAircraft(aircraft_path, engine_path, "X15");
FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft" );
- State->Reset("reset00");
+ FDMExec.GetState()->Reset(aircraft_path, "Reset00");
FG_LOG( FG_FLIGHT, FG_INFO, " loaded initial conditions" );
- State->Setdt(dt);
+ FDMExec.GetState()->Setdt(dt);
FG_LOG( FG_FLIGHT, FG_INFO, " set dt" );
FG_LOG( FG_FLIGHT, FG_INFO, "Finished initializing JSBsim" );
}
// copy control positions into the JSBsim structure
- FCS->SetDa( controls.get_aileron() );
- FCS->SetDe( controls.get_elevator() + controls.get_elevator_trim() );
- FCS->SetDr( controls.get_rudder() );
- FCS->SetDf( 0.0 );
- FCS->SetDs( 0.0 );
- FCS->SetThrottle( controls.get_throttle( 0 ) );
+ FDMExec.GetFCS()->SetDa( controls.get_aileron() );
+ FDMExec.GetFCS()->SetDe( controls.get_elevator()
+ + controls.get_elevator_trim() );
+ FDMExec.GetFCS()->SetDr( controls.get_rudder() );
+ FDMExec.GetFCS()->SetDf( 0.0 );
+ FDMExec.GetFCS()->SetDs( 0.0 );
+ FDMExec.GetFCS()->SetThrottle( FGControls::ALL_ENGINES,
+ controls.get_throttle( 0 ) );
// FCS->SetBrake( controls.get_brake( 0 ) );
// Inform JSBsim of the local terrain altitude
// printf("Altitude = %.2f\n", Altitude * 0.3048);
// printf("Radius to Vehicle = %.2f\n", Radius_to_vehicle * 0.3048);
- State->Setsim_time(State->Getsim_time() + State->Getdt() * multiloop);
- FDMExec->Run();
+ /* FDMExec.GetState()->Setsim_time(State->Getsim_time()
+ + State->Getdt() * multiloop); */
+
+ for ( int i = 0; i < multiloop; i++ ) {
+ FDMExec.Run();
+ }
// printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
// printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
int fgJSBsim_2_FGInterface (FGInterface& f) {
// Velocities
- f.set_Velocities_Local( State->GetVn(), State->GetVe(), State->GetVd() );
+ f.set_Velocities_Local( FDMExec.GetPosition()->GetVn(),
+ FDMExec.GetPosition()->GetVe(),
+ FDMExec.GetPosition()->GetVd() );
// f.set_Velocities_Ground( V_north_rel_ground, V_east_rel_ground,
// V_down_rel_ground );
// f.set_Velocities_Local_Airmass( V_north_airmass, V_east_airmass,
// f.set_V_ground_speed( V_ground_speed );
// f.set_V_equiv( V_equiv );
- /* ***FIXME*** */ f.set_V_equiv_kts( State->GetVt() );
+ /* ***FIXME*** */ f.set_V_equiv_kts( FDMExec.GetState()->GetVt() );
// f.set_V_calibrated( V_calibrated );
// f.set_V_calibrated_kts( V_calibrated_kts );
- f.set_Omega_Body( State->GetP(), State->GetQ(), State->GetR() );
+ f.set_Omega_Body( FDMExec.GetRotation()->GetP(),
+ FDMExec.GetRotation()->GetQ(),
+ FDMExec.GetRotation()->GetR() );
// f.set_Omega_Local( P_local, Q_local, R_local );
// f.set_Omega_Total( P_total, Q_total, R_total );
// ***FIXME*** f.set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
// Positions
- double lat = State->Getlatitude();
- double lon = State->Getlongitude();
- double alt = State->Geth();
- double lat_geoc, sl_radius;
- fgGeodToGeoc( lat, alt * FEET_TO_METER, &sl_radius, &lat_geoc );
-
- FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << lon << " lat = " << lat
+ double lat_geoc = FDMExec.GetState()->Getlatitude();
+ double lon = FDMExec.GetState()->Getlongitude();
+ double alt = FDMExec.GetState()->Geth();
+ double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc;
+ fgGeocToGeod( lat_geoc, EQUATORIAL_RADIUS_M + alt * FEET_TO_METER,
+ &lat_geod, &tmp_alt, &sl_radius1 );
+ fgGeodToGeoc( lat_geod, alt * FEET_TO_METER, &sl_radius2, &tmp_lat_geoc );
+
+ FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << lon << " lat_geod = " << lat_geod
<< " lat_geoc = " << lat_geoc
- << " alt = " << alt
- << " sl_radius = " << sl_radius * METER_TO_FEET);
+ << " alt = " << alt << " tmp_alt = " << tmp_alt * METER_TO_FEET
+ << " sl_radius1 = " << sl_radius1 * METER_TO_FEET
+ << " sl_radius2 = " << sl_radius2 * METER_TO_FEET
+ << " Equator = " << EQUATORIAL_RADIUS_FT );
- f.set_Geocentric_Position( lat_geoc, lon, sl_radius * METER_TO_FEET + alt );
- f.set_Geodetic_Position( lat, lon, alt );
- f.set_Euler_Angles( State->Getphi(), State->Gettht(), State->Getpsi() );
+ f.set_Geocentric_Position( lat_geoc, lon,
+ sl_radius2 * METER_TO_FEET + alt );
+ f.set_Geodetic_Position( lat_geod, lon, alt );
+ f.set_Euler_Angles( FDMExec.GetRotation()->Getphi(),
+ FDMExec.GetRotation()->Gettht(),
+ FDMExec.GetRotation()->Getpsi() );
// Miscellaneous quantities
// f.set_T_Local_to_Body(T_local_to_body_m);
// f.set_Gravity( Gravity );
// f.set_Centrifugal_relief( Centrifugal_relief );
- f.set_Alpha( State->Getalpha() );
- f.set_Beta( State->Getbeta() );
+ f.set_Alpha( FDMExec.GetTranslation()->Getalpha() );
+ f.set_Beta( FDMExec.GetTranslation()->Getbeta() );
// f.set_Alpha_dot( Alpha_dot );
// f.set_Beta_dot( Beta_dot );
// f.set_Static_temperature( Static_temperature );
// f.set_Total_temperature( Total_temperature );
- /* **FIXME*** */ f.set_Sea_level_radius( sl_radius * METER_TO_FEET );
+ /* **FIXME*** */ f.set_Sea_level_radius( sl_radius2 * METER_TO_FEET );
/* **FIXME*** */ f.set_Earth_position_angle( 0.0 );
/* ***FIXME*** */ f.set_Runway_altitude( 0.0 );
// $Log$
+// Revision 1.3 1999/02/26 22:09:10 curt
+// Added initial support for native SGI compilers.
+// Integrated Jon's next version of JSBsim.
+//
+// Revision 1.2 1999/02/11 21:09:40 curt
+// Interface with Jon's submitted JSBsim changes.
+//
// Revision 1.1 1999/02/05 21:29:38 curt
// Incorporating Jon S. Berndt's flight model code.
//