From 2606555bf6737fbfb56e2d917e47214dc0051ff1 Mon Sep 17 00:00:00 2001 From: mselig Date: Fri, 25 Jul 2003 17:53:35 +0000 Subject: [PATCH] UIUC code initilization mods to tidy things up a bit. --- src/FDM/LaRCsim/ls_init.c | 14 ++++++++++++-- src/FDM/LaRCsim/ls_model.c | 18 +++++++++++++++++- src/FDM/LaRCsim/ls_model.h | 1 + src/FDM/LaRCsim/ls_step.c | 21 ++++++++++++--------- src/FDM/LaRCsim/uiuc_aero.c | 23 +++++++++++++++++------ 5 files changed, 59 insertions(+), 18 deletions(-) diff --git a/src/FDM/LaRCsim/ls_init.c b/src/FDM/LaRCsim/ls_init.c index 0cef5fb36..b249608c9 100644 --- a/src/FDM/LaRCsim/ls_init.c +++ b/src/FDM/LaRCsim/ls_init.c @@ -34,8 +34,11 @@ $Header$ $Log$ -Revision 1.1 2002/09/10 01:14:02 curt -Initial revision +Revision 1.2 2003/07/25 17:53:35 mselig +UIUC code initilization mods to tidy things up a bit. + +Revision 1.1.1.1 2002/09/10 01:14:02 curt +Initial revision of FlightGear-0.9.0 Revision 1.3 2000/05/24 04:10:01 curt MSVC5 portability changes contributed by Bruce Finney. @@ -149,6 +152,7 @@ static char rcsid[] = "$Id$"; void cherokee_init( void ); void c172_init( void ); +void basic_init( void ); typedef struct { @@ -245,6 +249,9 @@ void ls_init( char * aircraft ) { } else if (!strcasecmp(aircraft, "cherokee")) { printf("Initializing LaRCsim for Cherokee\n"); current_model = CHEROKEE; + } else if (!strcasecmp(aircraft, "basic")) { + printf("Initializing LaRCsim for Basic\n"); + current_model = BASIC; } else if (!strcasecmp(aircraft, "uiuc")) { printf("Initializing LaRCsim for UIUC models\n"); current_model = UIUC; @@ -283,6 +290,9 @@ void ls_init( char * aircraft ) { case CHEROKEE: cherokee_init(); break; + case BASIC: + basic_init(); + break; case UIUC: c172_init(); break; diff --git a/src/FDM/LaRCsim/ls_model.c b/src/FDM/LaRCsim/ls_model.c index 735903907..3f442ecec 100644 --- a/src/FDM/LaRCsim/ls_model.c +++ b/src/FDM/LaRCsim/ls_model.c @@ -37,6 +37,9 @@ CURRENT RCS HEADER INFO: $Header$ $Log$ +Revision 1.4 2003/07/25 17:53:41 mselig +UIUC code initilization mods to tidy things up a bit. + Revision 1.3 2003/05/13 18:45:06 curt Robert Deters: @@ -168,6 +171,7 @@ void ls_model( SCALAR dt, int Initialize ) { navion_gear( dt, Initialize ); break; case C172: + printf("here we are in C172 \n"); if(Initialize < 0) c172_init(); inertias( dt, Initialize ); subsystems( dt, Initialize ); @@ -182,10 +186,22 @@ void ls_model( SCALAR dt, int Initialize ) { cherokee_engine( dt, Initialize ); cherokee_gear( dt, Initialize ); break; + case BASIC: + // printf("here we are in BASIC \n"); + if(Initialize < 0) basic_init(); + printf("Initialize %d \n", Initialize); + inertias( dt, Initialize ); + subsystems( dt, Initialize ); + basic_aero( dt, Initialize ); + basic_engine( dt, Initialize ); + basic_gear( dt, Initialize ); + break; case UIUC: inertias( dt, Initialize ); subsystems( dt, Initialize ); - uiuc_init_2_wrapper(); + // During initialization period, re-initialize velocities + // and euler angles + if (Initialize !=0) uiuc_init_2_wrapper(); uiuc_network_recv_2_wrapper(); uiuc_engine_2_wrapper( dt, Initialize ); uiuc_wind_2_wrapper( dt, Initialize ); diff --git a/src/FDM/LaRCsim/ls_model.h b/src/FDM/LaRCsim/ls_model.h index 9dfb63604..df980590f 100644 --- a/src/FDM/LaRCsim/ls_model.h +++ b/src/FDM/LaRCsim/ls_model.h @@ -8,6 +8,7 @@ typedef enum { NAVION, C172, CHEROKEE, + BASIC, UIUC } Model; diff --git a/src/FDM/LaRCsim/ls_step.c b/src/FDM/LaRCsim/ls_step.c index 6268d23e7..3927425cd 100644 --- a/src/FDM/LaRCsim/ls_step.c +++ b/src/FDM/LaRCsim/ls_step.c @@ -50,6 +50,9 @@ $Header$ $Log$ +Revision 1.5 2003/07/25 17:53:47 mselig +UIUC code initilization mods to tidy things up a bit. + Revision 1.4 2003/06/20 19:53:56 ehofman Get rid of a multiple defined symbol warning" src/FDM/LaRCsim/ls_step.c " @@ -294,7 +297,7 @@ Initial Flight Gear revision. --------------------------------------------------------------------------*/ -#include +//#include #include "ls_types.h" #include "ls_constants.h" @@ -361,11 +364,9 @@ void ls_step( SCALAR dt, int Initialize ) { V_east = V_east + local_gnd_veast; /* Initialize quaternions and transformation matrix from Euler angles */ - if (current_model == UIUC && Simtime == 0) { - if (inited == 0) { - uiuc_defaults_inits(); - } - uiuc_init_vars(); + // Initialize UIUC aircraft model + if (current_model == UIUC) { + uiuc_init_2_wrapper(); } e_0 = cos(Psi*0.5)*cos(Theta*0.5)*cos(Phi*0.5) @@ -386,9 +387,11 @@ 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; - if (current_model == UIUC && Simtime == 0) { - uiuc_vel_init(); - } + // Initialize local velocities (V_north, V_east, V_down) + // based on transformation matrix calculated above + if (current_model == UIUC) { + uiuc_local_vel_init(); + } /* Calculate local gravitation acceleration */ diff --git a/src/FDM/LaRCsim/uiuc_aero.c b/src/FDM/LaRCsim/uiuc_aero.c index c218517d8..bd7d3358f 100644 --- a/src/FDM/LaRCsim/uiuc_aero.c +++ b/src/FDM/LaRCsim/uiuc_aero.c @@ -66,11 +66,21 @@ void uiuc_init_2_wrapper() { static int init = 0; - if (init==0) - { - init = -1; - uiuc_initial_init(); + // On first time through initialize UIUC aircraft model + if (init==0) { + init=-1; + uiuc_defaults_inits(); + uiuc_init_aeromodel(); } + + // Re-initialize velocities and euler angles since LaRCsim tends + // to change them + uiuc_initial_init(); +} + +void uiuc_local_vel_init() +{ + uiuc_vel_init(); } void uiuc_aero_2_wrapper( SCALAR dt, int Initialize ) @@ -81,6 +91,7 @@ void uiuc_aero_2_wrapper( SCALAR dt, int Initialize ) void uiuc_wind_2_wrapper( SCALAR dt, int Initialize ) { + if (Initialize == 0) uiuc_wind_routine(dt); } @@ -103,10 +114,10 @@ void uiuc_record_2_wrapper(SCALAR dt) void uiuc_network_recv_2_wrapper() { - uiuc_network_recv_routine(); + uiuc_network_recv_routine(); } void uiuc_network_send_2_wrapper() { - uiuc_network_send_routine(); + uiuc_network_send_routine(); }