From 442fb251e408219fac113a12f341847f359325c7 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 8 Jan 1999 19:27:34 +0000 Subject: [PATCH] Fixed AOA reading on HUD. Continued work on time jitter compensation. --- Cockpit/cockpit.cxx | 6 +++++- FDM/LaRCsim.cxx | 8 ++++++-- FDM/flight.cxx | 43 ++++++++++++++++++++++++++++++++++++++++++- FDM/flight.hxx | 26 ++++++++++++++++++-------- 4 files changed, 71 insertions(+), 12 deletions(-) diff --git a/Cockpit/cockpit.cxx b/Cockpit/cockpit.cxx index 1b4c4c92e..a489474b9 100644 --- a/Cockpit/cockpit.cxx +++ b/Cockpit/cockpit.cxx @@ -150,7 +150,7 @@ double get_aoa( void ) FGState *f; f = current_aircraft.fdm_state; - return( f->get_Gamma_vert_rad() * RAD_TO_DEG ); + return( f->get_Alpha() * RAD_TO_DEG ); } double get_roll( void ) @@ -303,6 +303,10 @@ void fgCockpitUpdate( void ) { // $Log$ +// Revision 1.29 1999/01/08 19:27:34 curt +// Fixed AOA reading on HUD. +// Continued work on time jitter compensation. +// // Revision 1.28 1999/01/07 20:24:17 curt // Update fgGENERAL to FGGeneral. // diff --git a/FDM/LaRCsim.cxx b/FDM/LaRCsim.cxx index fe6034f42..5a714f9fc 100644 --- a/FDM/LaRCsim.cxx +++ b/FDM/LaRCsim.cxx @@ -322,7 +322,7 @@ int fgLaRCsim_2_FGState (FGState& f) { // f.set_Omega_Total( P_total, Q_total, R_total ); // f.set_Euler_Rates( Phi_dot, Theta_dot, Psi_dot ); - // f.set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot ); + f.set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot ); // Positions f.set_Geocentric_Position( Lat_geocentric, Lon_geocentric, @@ -335,7 +335,7 @@ int fgLaRCsim_2_FGState (FGState& f) { // f.set_Gravity( Gravity ); // f.set_Centrifugal_relief( Centrifugal_relief ); - // f.set_Alpha( Alpha ); + f.set_Alpha( Alpha ); f.set_Beta( Beta ); // f.set_Alpha_dot( Alpha_dot ); // f.set_Beta_dot( Beta_dot ); @@ -389,6 +389,10 @@ int fgLaRCsim_2_FGState (FGState& f) { // $Log$ +// Revision 1.9 1999/01/08 19:27:36 curt +// Fixed AOA reading on HUD. +// Continued work on time jitter compensation. +// // Revision 1.8 1998/12/18 23:37:06 curt // Collapsed out the FGState variables not currently needed. They are just // commented out and can be readded easily at any time. The point of this diff --git a/FDM/flight.cxx b/FDM/flight.cxx index 3225b3227..07f756fd2 100644 --- a/FDM/flight.cxx +++ b/FDM/flight.cxx @@ -90,6 +90,43 @@ int fgFlightModelInit(int model, FGState& f, double dt) { } +// Extrapolate fdm based on jitter time (in milliseconds) +static FGState extrapolate_fdm( FGState &base, int jitter ) { + FGState result; + + double dt = jitter / 1000.0; + // cout << "dt = " << dt << endl; + + // start by making a straight up copy + result = base; + + double lon = base.get_Longitude() + base.get_Longitude_dot() * dt; + double lon_geoc = base.get_Lon_geocentric() + base.get_Longitude_dot() * dt; + + double lat = base.get_Latitude() + base.get_Latitude_dot() * dt; + double lat_geoc = base.get_Lat_geocentric() + base.get_Latitude_dot() * dt; + + /* + cout << "( " << base.get_Longitude() << ", " << + base.get_Latitude() << " )" << endl; + cout << "( " << lon << ", " << lat << " )" << endl; + cout << "( " << base.get_Longitude_dot() * dt << ", " << + base.get_Latitude_dot() * dt << ", " << + base.get_Radius_dot() * dt << " )" << endl; + */ + + double alt = base.get_Altitude() + base.get_Radius_dot() * dt; + double radius = base.get_Radius_to_vehicle() + base.get_Radius_dot() * dt; + + result.set_Longitude( lon ); + result.set_Latitude( lat ); + result.set_Altitude( alt ); + // result.set_Geocentric_Position( lon_geoc, lat_geoc, radius ); + + return result; +} + + // Run multiloop iterations of the flight model int fgFlightModelUpdate(int model, FGState& f, int multiloop, int jitter) { double time_step, start_elev, end_elev; @@ -119,7 +156,7 @@ int fgFlightModelUpdate(int model, FGState& f, int multiloop, int jitter) { base_fdm_state.set_Climb_Rate( (end_elev - start_elev) / time_step ); } - f = base_fdm_state; + f = extrapolate_fdm( base_fdm_state, jitter ); return 1; } @@ -147,6 +184,10 @@ void fgFlightModelSetAltitude(int model, double alt_meters) { // $Log$ +// Revision 1.9 1999/01/08 19:27:37 curt +// Fixed AOA reading on HUD. +// Continued work on time jitter compensation. +// // Revision 1.8 1999/01/08 03:23:51 curt // Beginning work on compensating for sim time vs. real world time "jitter". // diff --git a/FDM/flight.hxx b/FDM/flight.hxx index 17d3c4733..9cd463723 100644 --- a/FDM/flight.hxx +++ b/FDM/flight.hxx @@ -52,6 +52,7 @@ `FGState::get_Gamma_vert_rad ()' `FGState::get_Climb_Rate ()' + `FGState::get_Alpha ()' `FGState::get_Beta ()' `FGState::get_Runway_altitude ()' @@ -61,6 +62,10 @@ `FGState::get_Sea_level_radius ()' `FGState::get_Earth_position_angle ()' + `FGState::get_Latitude_dot()' + `FGState::get_Longitude_dot()' + `FGState::get_Radius_dot()' + `FGState::get_Dx_cg ()' `FGState::get_Dy_cg ()' `FGState::get_Dz_cg ()' @@ -511,14 +516,14 @@ public: FG_VECTOR_3 geocentric_rates_v; // Geocentric linear velocities // inline double * get_Geocentric_rates_v() { return geocentric_rates_v; } - // inline double get_Latitude_dot() const { return geocentric_rates_v[0]; } - // inline double get_Longitude_dot() const { return geocentric_rates_v[1]; } - // inline double get_Radius_dot() const { return geocentric_rates_v[2]; } - /* inline void set_Geocentric_Rates( double lat, double lon, double rad ) { + inline double get_Latitude_dot() const { return geocentric_rates_v[0]; } + inline double get_Longitude_dot() const { return geocentric_rates_v[1]; } + inline double get_Radius_dot() const { return geocentric_rates_v[2]; } + inline void set_Geocentric_Rates( double lat, double lon, double rad ) { geocentric_rates_v[0] = lat; geocentric_rates_v[1] = lon; geocentric_rates_v[2] = rad; - } */ + } /*=============================== Positions ===============================*/ @@ -538,7 +543,8 @@ public: inline void set_Radius_to_vehicle(double radius) { geocentric_position_v[2] = radius; } - inline void set_Geocentric_Position( double lat, double lon, double rad ) { + +// inline void set_Geocentric_Position( double lat, double lon, double rad ) { geocentric_position_v[0] = lat; geocentric_position_v[1] = lon; geocentric_position_v[2] = rad; @@ -621,8 +627,8 @@ public: // inline void set_Centrifugal_relief(double cr) { centrifugal_relief = cr; } double alpha, beta, alpha_dot, beta_dot; // in radians - // inline double get_Alpha() const { return alpha; } - // inline void set_Alpha( double a ) { alpha = a; } + inline double get_Alpha() const { return alpha; } + inline void set_Alpha( double a ) { alpha = a; } inline double get_Beta() const { return beta; } inline void set_Beta( double b ) { beta = b; } // inline double get_Alpha_dot() const { return alpha_dot; } @@ -791,6 +797,10 @@ void fgFlightModelSetAltitude(int model, double alt_meters); // $Log$ +// Revision 1.9 1999/01/08 19:27:38 curt +// Fixed AOA reading on HUD. +// Continued work on time jitter compensation. +// // Revision 1.8 1999/01/08 03:23:52 curt // Beginning work on compensating for sim time vs. real world time "jitter". //