--------------------------------------------------------------------------*/
#include <sys/types.h>
-#include <sys/stat.h>
+/* #include <sys/stat.h> */
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "ls_sim_control.h"
#include "ls_cockpit.h"
#include "ls_interface.h"
-#include "../flight.h"
-#include "../../Aircraft/aircraft.h"
+#include "ls_step.h"
+#include "ls_accel.h"
+#include "ls_aux.h"
+#include "ls_model.h"
+#include "ls_init.h"
+#include <Flight/flight.h>
+#include <Aircraft/aircraft.h>
+#include <Autopilot/autopilot.h>
+#include <Debug/fg_debug.h>
+
/* global variable declarations */
SCALAR Simtime;
-/* #define DEFAULT_TERM_UPDATE_HZ 20 */ /* original value */
#define DEFAULT_TERM_UPDATE_HZ 20
#define DEFAULT_MODEL_HZ 120
#define DEFAULT_END_TIME 3600.
-void ls_stamp()
-{
+void ls_stamp( void ) {
char rcsid[] = "$Id$";
char revid[] = "$Revision$";
char dateid[] = "$Date$";
sprintf(sim_control_.date_string, "%06d\0", date);
sprintf(sim_control_.time_stamp, "%02d:%02d:%02d\0",
nowtime->tm_hour, nowtime->tm_min, nowtime->tm_sec);
+#ifdef COMPILE_THIS_CODE_THIS_USELESS_CODE
cuserid( sim_control_.userid ); /* set up user id */
-
+#endif /* COMPILE_THIS_CODE_THIS_USELESS_CODE */
return;
}
-void ls_setdefopts()
-{
+void ls_setdefopts( void ) {
/* set default values for most options */
sim_control_.debug = 0; /* change to non-zero if in dbx! */
sim_control_.write_mat = 0; /* write matrix-x/matlab script */
sim_control_.write_tab = 0; /* write tab delim. history file */
sim_control_.write_asc1 = 0; /* write GetData file */
- sim_control_.sim_type = GLmouse; /* hook up to mouse */
sim_control_.save_spacing = DEFAULT_SAVE_SPACING;
/* interpolation on recording */
sim_control_.write_spacing = DEFAULT_WRITE_SPACING;
sim_control_.end_time = DEFAULT_END_TIME;
sim_control_.model_hz = DEFAULT_MODEL_HZ;
sim_control_.term_update_hz = DEFAULT_TERM_UPDATE_HZ;
- sim_control_.time_slices = DEFAULT_END_TIME * DEFAULT_MODEL_HZ /
- DEFAULT_SAVE_SPACING;
+ sim_control_.time_slices = (long int)(DEFAULT_END_TIME * DEFAULT_MODEL_HZ /
+ DEFAULT_SAVE_SPACING);
sim_control_.paused = 0;
speedup = 1.0;
#endif /* COMPILE_THIS_CODE_THIS_USELESS_CODE */
-void ls_loop( dt, initialize )
-
-SCALAR dt;
-int initialize;
-
-{
+void ls_loop( SCALAR dt, int initialize ) {
/* printf (" In ls_loop()\n"); */
ls_step( dt, initialize );
/* if (sim_control_.sim_type == cockpit ) ls_ACES(); */
-int ls_cockpit() {
- struct fgCONTROLS *c;
+int ls_cockpit( void ) {
+ fgCONTROLS *c;
sim_control_.paused = 0;
- c = ¤t_aircraft.controls;
+ c = current_aircraft.controls;
Lat_control = FG_Aileron;
Long_control = FG_Elevator;
printf("%.4f,%.4f,%.2f ", Latitude, Longitude, Altitude);
printf("%.2f,%.2f,%.2f\n", Phi, Theta, Psi); */
+ return( 0 );
}
return 1;
}
- printf("LS pre Init pos = %.2f\n", Latitude);
+ /* printf("LS pre Init pos = %.2f\n", Latitude); */
ls_init();
- printf("LS post Init pos = %.2f\n", Latitude);
+ /* printf("LS post Init pos = %.2f\n", Latitude); */
if (speedup > 0) {
/* Initialize (get) cockpit (controls) settings */
/* Run an iteration of the EOM (equations of motion) */
-int fgLaRCsimUpdate(int multiloop) {
+int fgLaRCsimUpdate(fgFLIGHT *f, int multiloop) {
+ double save_alt = 0.0;
int i;
if (speedup > 0) {
}
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();
+
+ /* lets try to avoid really screwing up the LaRCsim model */
+ if ( FG_Altitude < -9000 ) {
+ save_alt = FG_Altitude;
+ FG_Altitude = 0;
+ }
+
+ // translate FG to LaRCsim structure
+ fgFlight_2_LaRCsim(f);
+ // printf("FG_Altitude = %.2f\n", FG_Altitude * 0.3048);
+ // printf("Altitude = %.2f\n", Altitude * 0.3048);
+ // printf("Radius to Vehicle = %.2f\n", Radius_to_vehicle * 0.3048);
+
+ // end of insertion
+
ls_loop( model_dt, 0);
+
+ // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
+ // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
+
+ // 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);
+
+ /* but lets restore our original bogus altitude when we are done */
+ if ( save_alt < -9000 ) {
+ FG_Altitude = save_alt;
+ }
}
return(1);
/* Convert from the fgFLIGHT struct to the LaRCsim generic_ struct */
-int fgFlight_2_LaRCsim (struct fgFLIGHT *f) {
+int fgFlight_2_LaRCsim (fgFLIGHT *f) {
Mass = FG_Mass;
I_xx = FG_I_xx;
I_yy = FG_I_yy;
X_pilot_rwy = FG_X_pilot_rwy;
Y_pilot_rwy = FG_Y_pilot_rwy;
H_pilot_rwy = FG_H_pilot_rwy;
+
+ return( 0 );
}
/* Convert from the LaRCsim generic_ struct to the fgFLIGHT struct */
-int fgLaRCsim_2_Flight (struct fgFLIGHT *f) {
+int fgLaRCsim_2_Flight (fgFLIGHT *f) {
FG_Mass = Mass;
FG_I_xx = I_xx;
FG_I_yy = I_yy;
FG_X_pilot_rwy = X_pilot_rwy;
FG_Y_pilot_rwy = Y_pilot_rwy;
FG_H_pilot_rwy = H_pilot_rwy;
+
+ return ( 0 );
+}
+
+
+/* Set the altitude (force) */
+int ls_ForceAltitude(double alt_feet) {
+ Altitude = alt_feet;
+ ls_geod_to_geoc( Latitude, Altitude, &Sea_level_radius, &Lat_geocentric);
+ Radius_to_vehicle = Altitude + Sea_level_radius;
}
+
/* Flight Gear Modification Log
*
* $Log$
+ * Revision 1.21 1998/08/22 14:49:56 curt
+ * Attempting to iron out seg faults and crashes.
+ * Did some shuffling to fix a initialization order problem between view
+ * position, scenery elevation.
+ *
+ * Revision 1.20 1998/07/12 03:11:03 curt
+ * Removed some printf()'s.
+ * Fixed the autopilot integration so it should be able to update it's control
+ * positions every time the internal flight model loop is run, and not just
+ * once per rendered frame.
+ * Added a routine to do the necessary stuff to force an arbitrary altitude
+ * change.
+ * Gave the Navion engine just a tad more power.
+ *
+ * Revision 1.19 1998/05/11 18:17:28 curt
+ * Output message tweaking.
+ *
+ * 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
+ * for things like lighting.
+ *
+ * Revision 1.16 1998/02/07 15:29:38 curt
+ * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
+ * <chotchkiss@namg.us.anritsu.com>
+ *
+ * Revision 1.15 1998/01/22 22:03:47 curt
+ * Removed #include <sys/stat.h>
+ *
+ * Revision 1.14 1998/01/19 19:27:04 curt
+ * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
+ * This should simplify things tremendously.
+ *
+ * Revision 1.13 1998/01/19 18:40:26 curt
+ * Tons of little changes to clean up the code and to remove fatal errors
+ * when building with the c++ compiler.
+ *
+ * Revision 1.12 1998/01/06 01:20:16 curt
+ * Tweaks to help building with MSVC++
+ *
* Revision 1.11 1998/01/05 22:19:26 curt
* #ifdef'd out some unused code that was problematic for MSVC++ to compile.
*