From e2ddc6f2b8958eeaecba3e4dcc55204ea0e58305 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 21 Apr 1998 16:59:33 +0000 Subject: [PATCH] Integrated autopilot. Prepairing for C++ integration. --- FDM/flight.c | 12 +++++++----- FDM/flight.h | 20 +++++++++++++++++--- LaRCsim/Makefile.am | 2 +- LaRCsim/Makefile.in | 2 +- LaRCsim/ls_interface.c | 26 +++++++++++++++++++++++++- LaRCsim/ls_interface.h | 12 ++++++++---- 6 files changed, 59 insertions(+), 15 deletions(-) diff --git a/FDM/flight.c b/FDM/flight.c index 9468e9932..fcca61c23 100644 --- a/FDM/flight.c +++ b/FDM/flight.c @@ -59,9 +59,7 @@ int fgFlightModelUpdate(int model, fgFLIGHT *f, int multiloop) { int result; if ( model == FG_LARCSIM ) { - fgFlight_2_LaRCsim(f); /* translate FG to LaRCsim structure */ - fgLaRCsimUpdate(multiloop); - fgLaRCsim_2_Flight(f); /* translate LaRCsim back to FG structure */ + fgLaRCsimUpdate(f, multiloop); } else { fgPrintf(FG_FLIGHT,FG_WARN,"Unimplemented flight model == %d\n", model); } @@ -73,9 +71,13 @@ int fgFlightModelUpdate(int model, fgFLIGHT *f, int multiloop) { /* $Log$ -/* Revision 1.11 1998/04/18 04:14:04 curt -/* Moved fg_debug.c to it's own library. +/* Revision 1.12 1998/04/21 16:59:33 curt +/* Integrated autopilot. +/* Prepairing for C++ integration. /* + * Revision 1.11 1998/04/18 04:14:04 curt + * Moved fg_debug.c to it's own library. + * * Revision 1.10 1998/02/07 15:29:37 curt * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss * diff --git a/FDM/flight.h b/FDM/flight.h index f27d42f8b..3ae17f8d8 100644 --- a/FDM/flight.h +++ b/FDM/flight.h @@ -28,6 +28,11 @@ #define _FLIGHT_H +#ifdef __cplusplus +extern "C" { +#endif + + #include /* #include */ @@ -397,14 +402,23 @@ int fgFlightModelInit(int model, fgFLIGHT *f, double dt); int fgFlightModelUpdate(int model, fgFLIGHT *f, int multiloop); +#ifdef __cplusplus +} +#endif + + #endif /* _FLIGHT_H */ /* $Log$ -/* Revision 1.14 1998/02/07 15:29:37 curt -/* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss -/* +/* Revision 1.15 1998/04/21 16:59:33 curt +/* Integrated autopilot. +/* Prepairing for C++ integration. /* + * Revision 1.14 1998/02/07 15:29:37 curt + * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss + * + * * Revision 1.13 1998/01/24 00:04:59 curt * misc. tweaks. * diff --git a/LaRCsim/Makefile.am b/LaRCsim/Makefile.am index 4b9981a7a..0a8d74b06 100644 --- a/LaRCsim/Makefile.am +++ b/LaRCsim/Makefile.am @@ -20,4 +20,4 @@ libLaRCsim_la_SOURCES = \ navion_init.c navion_init.h \ ls_interface.c ls_interface.h -INCLUDES += -I$(top_builddir) -I$(top_builddir)/Simulator +INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator diff --git a/LaRCsim/Makefile.in b/LaRCsim/Makefile.in index a5912d976..f9bb848cf 100644 --- a/LaRCsim/Makefile.in +++ b/LaRCsim/Makefile.in @@ -335,7 +335,7 @@ installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean -INCLUDES += -I$(top_builddir) -I$(top_builddir)/Simulator +INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/LaRCsim/ls_interface.c b/LaRCsim/ls_interface.c index 59feea8e6..95eb04fdc 100644 --- a/LaRCsim/ls_interface.c +++ b/LaRCsim/ls_interface.c @@ -242,6 +242,9 @@ $Original log: LaRCsim.c,v $ #include "ls_init.h" #include #include +#include +#include + /* global variable declarations */ @@ -545,15 +548,32 @@ int fgLaRCsimInit(double dt) { /* Run an iteration of the EOM (equations of motion) */ -int fgLaRCsimUpdate(int multiloop) { +int fgLaRCsimUpdate(fgFLIGHT *f, int multiloop) { int i; if (speedup > 0) { ls_cockpit(); } + // translate FG to LaRCsim structure + fgFlight_2_LaRCsim(f); + for ( i = 0; i < multiloop; i++ ) { + //Insertion by Jeff Goeke-Smith for Autopilot. + + // run Autopilot system + fgPrintf( FG_ALL, FG_BULK,"Attempting autopilot run\n"); + + fgAPRun(); + + // end of insertion + ls_loop( model_dt, 0); + + // translate LaRCsim back to FG structure so that the + // autopilot (and the rest of the sim can use the updated + // values + fgLaRCsim_2_Flight(f); } return(1); @@ -914,6 +934,10 @@ int fgLaRCsim_2_Flight (fgFLIGHT *f) { /* Flight Gear Modification Log * * $Log$ + * Revision 1.18 1998/04/21 16:59:38 curt + * Integrated autopilot. + * Prepairing for C++ integration. + * * Revision 1.17 1998/02/23 19:07:58 curt * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position * calculation code between sun display, and other FG sections that use this diff --git a/LaRCsim/ls_interface.h b/LaRCsim/ls_interface.h index 958968657..487dbcc6b 100644 --- a/LaRCsim/ls_interface.h +++ b/LaRCsim/ls_interface.h @@ -36,7 +36,7 @@ int fgLaRCsimInit(double dt); /* update position based on inputs, positions, velocities, etc. */ -int fgLaRCsimUpdate(int multiloop); +int fgLaRCsimUpdate(fgFLIGHT *f, int multiloop); /* Convert from the fgFLIGHT struct to the LaRCsim generic_ struct */ int fgFlight_2_LaRCsim (fgFLIGHT *f); @@ -51,10 +51,14 @@ void ls_loop( SCALAR dt, int initialize ); /* $Log$ -/* Revision 1.7 1998/02/07 15:29:39 curt -/* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss -/* +/* Revision 1.8 1998/04/21 16:59:39 curt +/* Integrated autopilot. +/* Prepairing for C++ integration. /* + * Revision 1.7 1998/02/07 15:29:39 curt + * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss + * + * * Revision 1.6 1998/02/03 23:20:17 curt * Lots of little tweaks to fix various consistency problems discovered by * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper -- 2.39.2