From 88c2b7a833cc478035247fd72814d1d74ea0dc24 Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Wed, 30 Sep 2020 15:39:30 +0200 Subject: [PATCH] Make LaRCsim work again when UIUC is dissabled. Unfortunately only the c172 seems to be stable. The Navion and Cherokee fail to trim at the runway. --- src/FDM/LaRCsim/LaRCsim.cxx | 9 +++++++-- src/FDM/LaRCsim/ls_model.c | 2 ++ src/FDM/LaRCsim/ls_step.c | 12 ++++++++---- src/FDM/LaRCsim/uiuc_aero.c | 3 +++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/FDM/LaRCsim/LaRCsim.cxx b/src/FDM/LaRCsim/LaRCsim.cxx index deba568ab..512fa397e 100644 --- a/src/FDM/LaRCsim/LaRCsim.cxx +++ b/src/FDM/LaRCsim/LaRCsim.cxx @@ -34,9 +34,11 @@ #include #include -#include #include
#include +#if ENABLE_UIUC_MODEL +# include +#endif #include "ls_cockpit.h" #include "ls_generic.h" @@ -317,6 +319,7 @@ void FGLaRCsim::update( double dt ) { fgSetDouble("/engines/engine/running", 1); // if flying uiuc, set some properties and over-ride some previous ones +#if ENABLE_UIUC_MODEL if ( !strcmp(aero->getStringValue(), "uiuc")) { // surface positions and other general properties @@ -408,7 +411,6 @@ void FGLaRCsim::update( double dt ) { } } - // add Gamma_horiz_deg to properties, mss 021213 if (use_gamma_horiz_on_speed) { if (V_rel_wind > gamma_horiz_on_speed) { @@ -421,6 +423,7 @@ void FGLaRCsim::update( double dt ) { else { fgSetDouble("/orientation/gamma-horiz-deg", fgGetDouble("/orientation/heading-deg")); } +#endif // ENABLE_UIUC_MODEL ls_update(multiloop); // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048); @@ -757,6 +760,7 @@ bool FGLaRCsim::copy_from_LaRCsim() { _set_Climb_Rate( -1 * V_down ); // cout << "climb rate = " << -V_down * 60 << endl; +#if ENABLE_UIUC_MODEL if ( !strcmp(aero->getStringValue(), "uiuc") ) { if (pilot_elev_no) { globals->get_controls()->set_elevator(Long_control); @@ -777,6 +781,7 @@ bool FGLaRCsim::copy_from_LaRCsim() { // controls.set_throttle(0,Throttle_pct); } } +#endif return true; } diff --git a/src/FDM/LaRCsim/ls_model.c b/src/FDM/LaRCsim/ls_model.c index 912f54e57..7446a5770 100644 --- a/src/FDM/LaRCsim/ls_model.c +++ b/src/FDM/LaRCsim/ls_model.c @@ -204,6 +204,7 @@ void ls_model( SCALAR dt, int Initialize ) { basic_gear( dt, Initialize ); break; case UIUC: +#if ENABLE_UIUC_MODEL inertias( dt, Initialize ); subsystems( dt, Initialize ); // During initialization period, re-initialize velocities @@ -216,6 +217,7 @@ void ls_model( SCALAR dt, int Initialize ) { uiuc_gear_2_wrapper( dt, Initialize ); uiuc_network_send_2_wrapper(); uiuc_record_2_wrapper(dt); +#endif break; } } diff --git a/src/FDM/LaRCsim/ls_step.c b/src/FDM/LaRCsim/ls_step.c index cbfd36cf5..b836ac54b 100644 --- a/src/FDM/LaRCsim/ls_step.c +++ b/src/FDM/LaRCsim/ls_step.c @@ -297,8 +297,6 @@ Initial Flight Gear revision. --------------------------------------------------------------------------*/ -#include "FDM/UIUCModel/uiuc_wrapper.h" - #include "ls_types.h" #include "ls_constants.h" #include "ls_generic.h" @@ -315,6 +313,9 @@ Initial Flight Gear revision. extern Model current_model; /* defined in ls_model.c */ extern SCALAR Simtime; /* defined in ls_main.c */ +#if ENABLE_UIUC_MODEL +# include "FDM/UIUCModel/uiuc_wrapper.h" + void uiuc_init_vars() { static int init = 0; @@ -325,7 +326,7 @@ void uiuc_init_vars() { uiuc_initial_init(); } - +#endif void ls_step( SCALAR dt, int Initialize ) { static int inited = 0; @@ -366,10 +367,11 @@ void ls_step( SCALAR dt, int Initialize ) { /* Initialize quaternions and transformation matrix from Euler angles */ // Initialize UIUC aircraft model +#if ENABLE_UIUC_MODEL if (current_model == UIUC) { uiuc_init_2_wrapper(); } - +#endif e_0 = cos(Psi*0.5)*cos(Theta*0.5)*cos(Phi*0.5) + sin(Psi*0.5)*sin(Theta*0.5)*sin(Phi*0.5); e_1 = cos(Psi*0.5)*cos(Theta*0.5)*sin(Phi*0.5) @@ -388,11 +390,13 @@ void ls_step( SCALAR dt, int Initialize ) { T_local_to_body_32 = 2*(e_2*e_3 - e_0*e_1); T_local_to_body_33 = e_0*e_0 - e_1*e_1 - e_2*e_2 + e_3*e_3; +#ifdef ENABLE_UIUC_MODEL // Initialize local velocities (V_north, V_east, V_down) // based on transformation matrix calculated above if (current_model == UIUC) { uiuc_local_vel_init(); } +#endif /* Calculate local gravitation acceleration */ diff --git a/src/FDM/LaRCsim/uiuc_aero.c b/src/FDM/LaRCsim/uiuc_aero.c index 57a9bc7c8..925f4ae79 100644 --- a/src/FDM/LaRCsim/uiuc_aero.c +++ b/src/FDM/LaRCsim/uiuc_aero.c @@ -53,6 +53,7 @@ --------------------------------------------------------------------------*/ +#if ENABLE_UIUC_MODEL #include #include "ls_types.h" @@ -121,3 +122,5 @@ void uiuc_network_send_2_wrapper() { uiuc_network_send_routine(); } + +#endif // ENABLE_UIUC_MODEL