From: curt Date: Tue, 4 Sep 2001 14:38:15 +0000 (+0000) Subject: Changes to better support arbitrary external flight models. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a691a3a3f6b3765fe967b9a730c3ea1e7cf20de0;p=flightgear.git Changes to better support arbitrary external flight models. --- diff --git a/src/FDM/flight.cxx b/src/FDM/flight.cxx index 1caf20c99..1c16f7c4f 100644 --- a/src/FDM/flight.cxx +++ b/src/FDM/flight.cxx @@ -405,6 +405,8 @@ bool FGInterface::update( int multi_loop ) { void FGInterface::_updatePosition( double lat_geoc, double lon, double alt ) { double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc; + // cout << "starting sea level rad = " << get_Sea_level_radius() << endl; + sgGeocToGeod( lat_geoc, ( get_Sea_level_radius() + alt ) * SG_FEET_TO_METER, &lat_geod, &tmp_alt, &sl_radius1 ); sgGeodToGeoc( lat_geod, alt * SG_FEET_TO_METER, &sl_radius2, &tmp_lat_geoc ); diff --git a/src/FDM/flight.hxx b/src/FDM/flight.hxx index a09520f2d..d8ad9624f 100644 --- a/src/FDM/flight.hxx +++ b/src/FDM/flight.hxx @@ -285,7 +285,8 @@ private: // SGTimeStamp valid_stamp; // time this record is valid // SGTimeStamp next_stamp; // time this record is valid -protected: +// protected: +public: // deliberately not virtual so that // FGInterface constructor will call diff --git a/src/Main/fg_io.cxx b/src/Main/fg_io.cxx index 9760f83e6..498bdf3f0 100644 --- a/src/Main/fg_io.cxx +++ b/src/Main/fg_io.cxx @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -100,6 +101,9 @@ static FGProtocol *parse_port_config( const string& config ) } else if ( protocol == "native_ctrls" ) { FGNativeCtrls *native_ctrls = new FGNativeCtrls; io = native_ctrls; + } else if ( protocol == "native_fdm" ) { + FGNativeFDM *native_fdm = new FGNativeFDM; + io = native_fdm; } else if ( protocol == "nmea" ) { FGNMEA *nmea = new FGNMEA; io = nmea; diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 770fce0a1..4acf21ed1 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -796,6 +796,8 @@ parse_option (const string& arg) add_channel( "native", arg.substr(9) ); } else if ( arg.find( "--native-ctrls=" ) == 0 ) { add_channel( "native_ctrls", arg.substr(15) ); + } else if ( arg.find( "--native-fdm=" ) == 0 ) { + add_channel( "native_fdm", arg.substr(13) ); } else if ( arg.find( "--garmin=" ) == 0 ) { add_channel( "garmin", arg.substr(9) ); } else if ( arg.find( "--nmea=" ) == 0 ) { diff --git a/src/Network/Makefile.am b/src/Network/Makefile.am index c0f6ce2c1..361da9c30 100644 --- a/src/Network/Makefile.am +++ b/src/Network/Makefile.am @@ -8,10 +8,11 @@ libNetwork_a_SOURCES = \ joyclient.cxx joyclient.hxx \ native.cxx native.hxx \ native_ctrls.cxx native_ctrls.hxx \ + native_fdm.cxx native_fdm.hxx \ nmea.cxx nmea.hxx \ props.cxx props.hxx \ pve.cxx pve.hxx \ - raw_ctrls.hxx \ + raw_ctrls.hxx raw_fdm.hxx \ ray.cxx ray.hxx \ rul.cxx rul.hxx diff --git a/src/Network/native_ctrls.cxx b/src/Network/native_ctrls.cxx index 27f7b3694..2cc20ff5f 100644 --- a/src/Network/native_ctrls.cxx +++ b/src/Network/native_ctrls.cxx @@ -55,9 +55,10 @@ bool FGNativeCtrls::open() { } -static void global2raw( FGControls *global, FGRawCtrls *raw ) { +static void global2raw( const FGControls *global, FGRawCtrls *raw ) { int i; + raw->version = FG_RAW_CTRLS_VERSION; raw->aileron = globals->get_controls()->get_aileron(); raw->elevator = globals->get_controls()->get_elevator(); raw->elevator_trim = globals->get_controls()->get_elevator_trim(); @@ -74,21 +75,27 @@ static void global2raw( FGControls *global, FGRawCtrls *raw ) { } -static void raw2global( FGRawCtrls *raw, FGControls *global ) { +static void raw2global( const FGRawCtrls *raw, FGControls *global ) { int i; - globals->get_controls()->set_aileron( raw->aileron ); - globals->get_controls()->set_elevator( raw->elevator ); - globals->get_controls()->set_elevator_trim( raw->elevator_trim ); - globals->get_controls()->set_rudder( raw->rudder ); - globals->get_controls()->set_flaps( raw->flaps ); - for ( i = 0; i < FG_MAX_ENGINES; ++i ) { - globals->get_controls()->set_throttle( i, raw->throttle[i] ); - globals->get_controls()->set_mixture( i, raw->mixture[i] ); - globals->get_controls()->set_prop_advance( i, raw->prop_advance[i] ); - } - for ( i = 0; i < FG_MAX_WHEELS; ++i ) { - globals->get_controls()->set_brake( i, raw->brake[i] ); + if ( raw->version == FG_RAW_CTRLS_VERSION ) { + globals->get_controls()->set_aileron( raw->aileron ); + globals->get_controls()->set_elevator( raw->elevator ); + globals->get_controls()->set_elevator_trim( raw->elevator_trim ); + globals->get_controls()->set_rudder( raw->rudder ); + globals->get_controls()->set_flaps( raw->flaps ); + for ( i = 0; i < FG_MAX_ENGINES; ++i ) { + globals->get_controls()->set_throttle( i, raw->throttle[i] ); + globals->get_controls()->set_mixture( i, raw->mixture[i] ); + globals->get_controls()->set_prop_advance( i, raw->prop_advance[i]); + } + for ( i = 0; i < FG_MAX_WHEELS; ++i ) { + globals->get_controls()->set_brake( i, raw->brake[i] ); + } + } else { + SG_LOG( SG_IO, SG_ALERT, "Error: version mismatch in raw2global()" ); + SG_LOG( SG_IO, SG_ALERT, + "\tsomeone needs to upgrade raw_ctrls.hxx and recompile." ); } } diff --git a/src/Network/raw_ctrls.hxx b/src/Network/raw_ctrls.hxx index fd0b14529..dafedece8 100644 --- a/src/Network/raw_ctrls.hxx +++ b/src/Network/raw_ctrls.hxx @@ -30,6 +30,7 @@ # error This library requires C++ #endif +const int FG_RAW_CTRLS_VERSION = 1; const int FG_MAX_ENGINES = 10; const int FG_MAX_WHEELS = 3; @@ -40,6 +41,7 @@ class FGRawCtrls { public: + int version; // increment when data values change double aileron; // -1 ... 1 double elevator; // -1 ... 1 double elevator_trim; // -1 ... 1