Changes to better support arbitrary external flight models.
This commit is contained in:
parent
a6ab6f0117
commit
a691a3a3f6
7 changed files with 35 additions and 16 deletions
|
@ -405,6 +405,8 @@ bool FGInterface::update( int multi_loop ) {
|
||||||
void FGInterface::_updatePosition( double lat_geoc, double lon, double alt ) {
|
void FGInterface::_updatePosition( double lat_geoc, double lon, double alt ) {
|
||||||
double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc;
|
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,
|
sgGeocToGeod( lat_geoc, ( get_Sea_level_radius() + alt ) * SG_FEET_TO_METER,
|
||||||
&lat_geod, &tmp_alt, &sl_radius1 );
|
&lat_geod, &tmp_alt, &sl_radius1 );
|
||||||
sgGeodToGeoc( lat_geod, alt * SG_FEET_TO_METER, &sl_radius2, &tmp_lat_geoc );
|
sgGeodToGeoc( lat_geod, alt * SG_FEET_TO_METER, &sl_radius2, &tmp_lat_geoc );
|
||||||
|
|
|
@ -285,7 +285,8 @@ private:
|
||||||
// SGTimeStamp valid_stamp; // time this record is valid
|
// SGTimeStamp valid_stamp; // time this record is valid
|
||||||
// SGTimeStamp next_stamp; // time this record is valid
|
// SGTimeStamp next_stamp; // time this record is valid
|
||||||
|
|
||||||
protected:
|
// protected:
|
||||||
|
public:
|
||||||
|
|
||||||
// deliberately not virtual so that
|
// deliberately not virtual so that
|
||||||
// FGInterface constructor will call
|
// FGInterface constructor will call
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <Network/joyclient.hxx>
|
#include <Network/joyclient.hxx>
|
||||||
#include <Network/native.hxx>
|
#include <Network/native.hxx>
|
||||||
#include <Network/native_ctrls.hxx>
|
#include <Network/native_ctrls.hxx>
|
||||||
|
#include <Network/native_fdm.hxx>
|
||||||
#include <Network/nmea.hxx>
|
#include <Network/nmea.hxx>
|
||||||
#include <Network/props.hxx>
|
#include <Network/props.hxx>
|
||||||
#include <Network/pve.hxx>
|
#include <Network/pve.hxx>
|
||||||
|
@ -100,6 +101,9 @@ static FGProtocol *parse_port_config( const string& config )
|
||||||
} else if ( protocol == "native_ctrls" ) {
|
} else if ( protocol == "native_ctrls" ) {
|
||||||
FGNativeCtrls *native_ctrls = new FGNativeCtrls;
|
FGNativeCtrls *native_ctrls = new FGNativeCtrls;
|
||||||
io = native_ctrls;
|
io = native_ctrls;
|
||||||
|
} else if ( protocol == "native_fdm" ) {
|
||||||
|
FGNativeFDM *native_fdm = new FGNativeFDM;
|
||||||
|
io = native_fdm;
|
||||||
} else if ( protocol == "nmea" ) {
|
} else if ( protocol == "nmea" ) {
|
||||||
FGNMEA *nmea = new FGNMEA;
|
FGNMEA *nmea = new FGNMEA;
|
||||||
io = nmea;
|
io = nmea;
|
||||||
|
|
|
@ -796,6 +796,8 @@ parse_option (const string& arg)
|
||||||
add_channel( "native", arg.substr(9) );
|
add_channel( "native", arg.substr(9) );
|
||||||
} else if ( arg.find( "--native-ctrls=" ) == 0 ) {
|
} else if ( arg.find( "--native-ctrls=" ) == 0 ) {
|
||||||
add_channel( "native_ctrls", arg.substr(15) );
|
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 ) {
|
} else if ( arg.find( "--garmin=" ) == 0 ) {
|
||||||
add_channel( "garmin", arg.substr(9) );
|
add_channel( "garmin", arg.substr(9) );
|
||||||
} else if ( arg.find( "--nmea=" ) == 0 ) {
|
} else if ( arg.find( "--nmea=" ) == 0 ) {
|
||||||
|
|
|
@ -8,10 +8,11 @@ libNetwork_a_SOURCES = \
|
||||||
joyclient.cxx joyclient.hxx \
|
joyclient.cxx joyclient.hxx \
|
||||||
native.cxx native.hxx \
|
native.cxx native.hxx \
|
||||||
native_ctrls.cxx native_ctrls.hxx \
|
native_ctrls.cxx native_ctrls.hxx \
|
||||||
|
native_fdm.cxx native_fdm.hxx \
|
||||||
nmea.cxx nmea.hxx \
|
nmea.cxx nmea.hxx \
|
||||||
props.cxx props.hxx \
|
props.cxx props.hxx \
|
||||||
pve.cxx pve.hxx \
|
pve.cxx pve.hxx \
|
||||||
raw_ctrls.hxx \
|
raw_ctrls.hxx raw_fdm.hxx \
|
||||||
ray.cxx ray.hxx \
|
ray.cxx ray.hxx \
|
||||||
rul.cxx rul.hxx
|
rul.cxx rul.hxx
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,10 @@ bool FGNativeCtrls::open() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void global2raw( FGControls *global, FGRawCtrls *raw ) {
|
static void global2raw( const FGControls *global, FGRawCtrls *raw ) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
raw->version = FG_RAW_CTRLS_VERSION;
|
||||||
raw->aileron = globals->get_controls()->get_aileron();
|
raw->aileron = globals->get_controls()->get_aileron();
|
||||||
raw->elevator = globals->get_controls()->get_elevator();
|
raw->elevator = globals->get_controls()->get_elevator();
|
||||||
raw->elevator_trim = globals->get_controls()->get_elevator_trim();
|
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;
|
int i;
|
||||||
|
|
||||||
globals->get_controls()->set_aileron( raw->aileron );
|
if ( raw->version == FG_RAW_CTRLS_VERSION ) {
|
||||||
globals->get_controls()->set_elevator( raw->elevator );
|
globals->get_controls()->set_aileron( raw->aileron );
|
||||||
globals->get_controls()->set_elevator_trim( raw->elevator_trim );
|
globals->get_controls()->set_elevator( raw->elevator );
|
||||||
globals->get_controls()->set_rudder( raw->rudder );
|
globals->get_controls()->set_elevator_trim( raw->elevator_trim );
|
||||||
globals->get_controls()->set_flaps( raw->flaps );
|
globals->get_controls()->set_rudder( raw->rudder );
|
||||||
for ( i = 0; i < FG_MAX_ENGINES; ++i ) {
|
globals->get_controls()->set_flaps( raw->flaps );
|
||||||
globals->get_controls()->set_throttle( i, raw->throttle[i] );
|
for ( i = 0; i < FG_MAX_ENGINES; ++i ) {
|
||||||
globals->get_controls()->set_mixture( i, raw->mixture[i] );
|
globals->get_controls()->set_throttle( i, raw->throttle[i] );
|
||||||
globals->get_controls()->set_prop_advance( i, raw->prop_advance[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] );
|
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." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
# error This library requires C++
|
# error This library requires C++
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const int FG_RAW_CTRLS_VERSION = 1;
|
||||||
|
|
||||||
const int FG_MAX_ENGINES = 10;
|
const int FG_MAX_ENGINES = 10;
|
||||||
const int FG_MAX_WHEELS = 3;
|
const int FG_MAX_WHEELS = 3;
|
||||||
|
@ -40,6 +41,7 @@ class FGRawCtrls {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
int version; // increment when data values change
|
||||||
double aileron; // -1 ... 1
|
double aileron; // -1 ... 1
|
||||||
double elevator; // -1 ... 1
|
double elevator; // -1 ... 1
|
||||||
double elevator_trim; // -1 ... 1
|
double elevator_trim; // -1 ... 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue