From d7ec45ca3b1f5abdcf96f54907a756224f5f8caa Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 26 Oct 2001 05:42:08 +0000 Subject: [PATCH] Various tweaks for support of external flight models running as seperate processes. --- src/Network/native_ctrls.cxx | 5 +++++ src/Network/native_fdm.cxx | 8 ++++++++ src/Network/raw_ctrls.hxx | 6 +++++- src/Network/raw_fdm.hxx | 8 +++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Network/native_ctrls.cxx b/src/Network/native_ctrls.cxx index 2cc20ff5f..f34367dbc 100644 --- a/src/Network/native_ctrls.cxx +++ b/src/Network/native_ctrls.cxx @@ -24,6 +24,8 @@ #include #include +#include // ground elevation + #include "native_ctrls.hxx" @@ -72,6 +74,8 @@ static void global2raw( const FGControls *global, FGRawCtrls *raw ) { for ( i = 0; i < FG_MAX_WHEELS; ++i ) { raw->brake[i] = globals->get_controls()->get_brake(i); } + + raw->hground = scenery.cur_elev; } @@ -92,6 +96,7 @@ static void raw2global( const FGRawCtrls *raw, FGControls *global ) { for ( i = 0; i < FG_MAX_WHEELS; ++i ) { globals->get_controls()->set_brake( i, raw->brake[i] ); } + scenery.cur_elev = raw->hground; } else { SG_LOG( SG_IO, SG_ALERT, "Error: version mismatch in raw2global()" ); SG_LOG( SG_IO, SG_ALERT, diff --git a/src/Network/native_fdm.cxx b/src/Network/native_fdm.cxx index efa46c8b8..0c7049c0d 100644 --- a/src/Network/native_fdm.cxx +++ b/src/Network/native_fdm.cxx @@ -60,12 +60,18 @@ bool FGNativeFDM::open() { static void global2raw( const FGInterface *global, FGRawFDM *raw ) { raw->version = FG_RAW_FDM_VERSION; + + // positions raw->longitude = cur_fdm_state->get_Longitude(); raw->latitude = cur_fdm_state->get_Latitude(); raw->altitude = cur_fdm_state->get_Altitude(); raw->phi = cur_fdm_state->get_Phi(); raw->theta = cur_fdm_state->get_Theta(); raw->psi = cur_fdm_state->get_Psi(); + + // velocities + raw->vcas = cur_fdm_state->get_V_calibrated_kts(); + raw->climb_rate = cur_fdm_state->get_Climb_Rate(); } @@ -78,6 +84,8 @@ static void raw2global( const FGRawFDM *raw, FGInterface *global ) { cur_fdm_state->_set_Euler_Angles( raw->phi, raw->theta, raw->psi ); + cur_fdm_state->_set_V_calibrated_kts( raw->vcas ); + cur_fdm_state->_set_Climb_Rate( raw->climb_rate ); } else { SG_LOG( SG_IO, SG_ALERT, "Error: version mismatch in raw2global()" ); SG_LOG( SG_IO, SG_ALERT, diff --git a/src/Network/raw_ctrls.hxx b/src/Network/raw_ctrls.hxx index dafedece8..91a74cf41 100644 --- a/src/Network/raw_ctrls.hxx +++ b/src/Network/raw_ctrls.hxx @@ -30,7 +30,7 @@ # error This library requires C++ #endif -const int FG_RAW_CTRLS_VERSION = 1; +const int FG_RAW_CTRLS_VERSION = 2; const int FG_MAX_ENGINES = 10; const int FG_MAX_WHEELS = 3; @@ -42,6 +42,8 @@ class FGRawCtrls { public: int version; // increment when data values change + + // Controls double aileron; // -1 ... 1 double elevator; // -1 ... 1 double elevator_trim; // -1 ... 1 @@ -52,6 +54,8 @@ public: double prop_advance[FG_MAX_ENGINES]; // 0 ... 1 double brake[FG_MAX_WHEELS]; // 0 ... 1 + // Other interesting/useful values + double hground; // ground elevation (meters) }; diff --git a/src/Network/raw_fdm.hxx b/src/Network/raw_fdm.hxx index 1b2cf7b17..e5f8b7ed3 100644 --- a/src/Network/raw_fdm.hxx +++ b/src/Network/raw_fdm.hxx @@ -30,7 +30,7 @@ # error This library requires C++ #endif -const int FG_RAW_FDM_VERSION = 1; +const int FG_RAW_FDM_VERSION = 3; // Define a structure containing the top level flight dynamics model // parameters @@ -40,6 +40,8 @@ class FGRawFDM { public: int version; // increment when data values change + + // Positions double longitude; // radians double latitude; // radians double altitude; // meters (above sea level) @@ -47,6 +49,10 @@ public: double phi; // radians double theta; // radians double psi; // radians + + // Velocities + double vcas; // calibrated airspeed + double climb_rate; // feet per second }; -- 2.39.5