X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim.cxx;h=06462438eb225f9a19951447e0ec9e6c949ea624;hb=9a3b25e4fa4b9acb7b444e6e33bcba1c8310b888;hp=d2e52dbf89f42d40ea3e337c4604ae1f8521e42e;hpb=b86e6ddc11afe0578fff207e74a20abe8a053c23;p=flightgear.git diff --git a/src/FDM/JSBSim.cxx b/src/FDM/JSBSim.cxx index d2e52dbf8..06462438e 100644 --- a/src/FDM/JSBSim.cxx +++ b/src/FDM/JSBSim.cxx @@ -21,7 +21,7 @@ // $Id$ -#include +#include #ifdef FG_MATH_EXCEPTION_CLASH # include @@ -29,13 +29,14 @@ #include STL_STRING +#include +#include +#include +#include + #include #include -#include -#include #include
-#include -#include #include #include @@ -44,6 +45,8 @@ #include #include #include +#include +#include #include "JSBsim.hxx" @@ -61,31 +64,35 @@ int FGJSBsim::init( double dt ) { FGPath engine_path( current_options.get_fg_root() ); engine_path.append( "Engine" ); - FDMExec.GetAircraft()->LoadAircraft(aircraft_path.str(), - engine_path.str(), "X15"); - FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft" ); - -// FDMExec.GetState()->Reset(aircraft_path.str(), "Reset00"); + FDMExec.GetAircraft()->LoadAircraft( aircraft_path.str(), + engine_path.str(), + current_options.get_aircraft() ); + FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft" << + current_options.get_aircraft() ); + + FG_LOG( FG_FLIGHT, FG_INFO, "Initializing JSBsim with:" ); + FG_LOG( FG_FLIGHT, FG_INFO, " U: " << current_options.get_uBody() ); + FG_LOG( FG_FLIGHT, FG_INFO, " V: " <Initialize( current_options.get_uBody(), current_options.get_vBody(), current_options.get_wBody(), - get_Phi(), - get_Theta(), - get_Psi(), + get_Phi() * DEGTORAD, + get_Theta() * DEGTORAD, + get_Psi() * DEGTORAD, get_Latitude(), get_Longitude(), get_Altitude() ); -// FDMExec.GetState()->Setlatitude(f.get_Latitude()); -// FDMExec.GetState()->Setlongitude(f.get_Longitude()); -// FDMExec.GetState()->Seth(f.get_Altitude()); -// FDMExec.GetRotation()->Setphi(f.get_Phi()); -// FDMExec.GetRotation()->Settht(f.get_Theta()); -// FDMExec.GetRotation()->Setpsi(f.get_Psi()); - FG_LOG( FG_FLIGHT, FG_INFO, " loaded initial conditions" ); FDMExec.GetState()->Setdt( dt ); @@ -112,13 +119,13 @@ int FGJSBsim::update( int multiloop ) { } // copy control positions into the JSBsim structure - FDMExec.GetFCS()->SetDa( controls.get_aileron()); - FDMExec.GetFCS()->SetDe( controls.get_elevator() + FDMExec.GetFCS()->SetDaCmd( controls.get_aileron()); + FDMExec.GetFCS()->SetDeCmd( 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, + FDMExec.GetFCS()->SetDrCmd( controls.get_rudder()); + FDMExec.GetFCS()->SetDfCmd( 0.0 ); + // FDMExec.GetFCS()->SetDsCmd( 0.0 ); + FDMExec.GetFCS()->SetThrottleCmd( FGControls::ALL_ENGINES, controls.get_throttle( 0 ) * 100.0 ); // FCS->SetBrake( controls.get_brake( 0 ) ); @@ -173,9 +180,9 @@ int FGJSBsim::copy_to_JSBsim() { int FGJSBsim::copy_from_JSBsim() { // Velocities - set_Velocities_Local( FDMExec.GetPosition()->GetVn(), - FDMExec.GetPosition()->GetVe(), - FDMExec.GetPosition()->GetVd() ); + // set_Velocities_Local( FDMExec.GetPosition()->GetVn(), + // FDMExec.GetPosition()->GetVe(), + // FDMExec.GetPosition()->GetVd() ); // set_Velocities_Ground( V_north_rel_ground, V_east_rel_ground, // V_down_rel_ground ); // set_Velocities_Local_Airmass( V_north_airmass, V_east_airmass, @@ -192,18 +199,23 @@ int FGJSBsim::copy_from_JSBsim() { // set_V_ground_speed( V_ground_speed ); // set_V_equiv( V_equiv ); - /* ***FIXME*** */ set_V_equiv_kts( FDMExec.GetState()->GetVt() ); - // set_V_calibrated( V_calibrated ); - // set_V_calibrated_kts( V_calibrated_kts ); + set_V_equiv_kts( FDMExec.GetAuxiliary()->GetVequivalentKTS() ); + //set_V_calibrated( FDMExec.GetAuxiliary()->GetVcalibratedFPS() ); + set_V_calibrated_kts( FDMExec.GetAuxiliary()->GetVcalibratedKTS() ); - set_Omega_Body( FDMExec.GetRotation()->GetP(), - FDMExec.GetRotation()->GetQ(), - FDMExec.GetRotation()->GetR() ); + set_Omega_Body( FDMExec.GetState()->GetParameter(FG_ROLLRATE), + FDMExec.GetState()->GetParameter(FG_PITCHRATE), + FDMExec.GetState()->GetParameter(FG_YAWRATE) ); // set_Omega_Local( P_local, Q_local, R_local ); // set_Omega_Total( P_total, Q_total, R_total ); - - // set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot ); + + set_Euler_Rates( FDMExec.GetRotation()->Getphi(), + FDMExec.GetRotation()->Gettht(), + FDMExec.GetRotation()->Getpsi() ); + // ***FIXME*** set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot ); + + set_Mach_number( FDMExec.GetState()->GetMach()); // Positions double lat_geoc = FDMExec.GetState()->Getlatitude(); @@ -224,9 +236,9 @@ int FGJSBsim::copy_from_JSBsim() { set_Geocentric_Position( lat_geoc, lon, sl_radius2 * METER_TO_FEET + alt ); set_Geodetic_Position( lat_geod, lon, alt ); - set_Euler_Angles( FDMExec.GetRotation()->Getphi(), - FDMExec.GetRotation()->Gettht(), - FDMExec.GetRotation()->Getpsi() ); + set_Euler_Angles( FDMExec.GetRotation()->Getphi(), + FDMExec.GetRotation()->Gettht(), + FDMExec.GetRotation()->Getpsi() ); // Miscellaneous quantities // set_T_Local_to_Body(T_local_to_body_m);