]> git.mxchange.org Git - flightgear.git/blob - LaRCsim/ls_interface.c
Tweaks to help building with MSVC++
[flightgear.git] / LaRCsim / ls_interface.c
1 /**************************************************************************
2  * ls_interface.c -- the FG interface to the LaRCsim routines
3  *                   This is a heavily modified version of LaRCsim.c
4  *                   As a result there is much old baggage left in this file.
5  *
6  * Originally Written 921230 by Bruce Jackson
7  * Modified by Curtis Olson, started May 1997.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  * $Id$
24  * (Log is kept at end of this file)
25  **************************************************************************/
26
27 /* Original headers follow: */
28
29 /***************************************************************************
30
31         TITLE:          LaRCsim.c
32         
33 ----------------------------------------------------------------------------
34
35         FUNCTION:       Top level routine for LaRCSIM.  Includes
36                         global variable declarations.
37
38 ----------------------------------------------------------------------------
39
40         MODULE STATUS:  Developmental
41
42 ----------------------------------------------------------------------------
43
44         GENEALOGY:      Written 921230 by Bruce Jackson
45
46 ----------------------------------------------------------------------------
47
48         DESIGNED BY:    EBJ
49         
50         CODED BY:       EBJ
51         
52         MAINTAINED BY:  EBJ
53
54 ----------------------------------------------------------------------------
55
56         MODIFICATION HISTORY:
57         
58         DATE    PURPOSE                                         BY
59
60         930111  Added "progname" variable to keep name of invoking command.
61                                                                         EBJ
62         931012  Removed altitude < 0. test to support gear development. EBJ
63         931214  Added various pressures (Impact, Dynamic, Static, etc.) EBJ
64         931215  Adopted new generic variable structure.                 EBJ
65         931218  Added command line options decoding.                    EBJ
66         940110  Changed file type of matrix file to ".m"                EBJ
67         940513  Renamed this routine "LaRCsim.c" from "ls_main.c"       EBJ
68         940513  Added time_stamp routine,  t_stamp.                     EBJ
69         950225  Added options flag, 'i', to set I/O output rate.        EBJ
70         950306  Added calls to ls_get_settings() and ls_put_settings()  EBJ
71         950314  Options flag 'i' now reads IC file; 'o' is output rate  EBJ
72         950406  Many changes: added definition of default value macros;
73                 removed local variables term_update_hz, model_dt, endtime,
74                 substituted sim_control_ globals for these; removed
75                 initialization of sim_control_.tape_channels; moved optarg
76                 to generic extern; added mod_end_time & mod_buf_size flags
77                 and temporary buffer_time and data_rate locals to
78                 ls_checkopts(); added additional command line switches '-s'
79                 and '-b'; made psuedo-mandatory file names for data output
80                 switches; considerable rewrite of logic for setting data
81                 buffer length and interleave parameters; updated '-h' help
82                 output message; added protection logic to calculations of
83                 these parameters; added check of return value on first call
84                 to ls_cockpit() so <esc> abort works from initial pause
85                 state; added call to ls_unsync() immediately following
86                 first ls_sync() call, if paused (to avoid alarm clock
87                 timeout); moved call to ls_record() into non-paused
88                 multiloop path (was filling buffer with identical data
89                 during pause); put check of paused flag before calling sync
90                 routine ls_pause(); and added call to exit() on termination.
91
92
93 $Header$
94 $Original log: LaRCsim.c,v $
95  * Revision 1.4.1.7  1995/04/07  01:04:37  bjax
96  * Many changes made to support storage of sim options from run to run,
97  * as well as restructuring storage buffer sizing and some loop logic
98  * changes. See the modification log for details.
99  *
100  * Revision 1.4.1.6  1995/03/29  16:12:09  bjax
101  * Added argument to -o switch; changed run loop to pass dt=0
102  * if in paused mode. EBj
103  *
104  * Revision 1.4.1.5  1995/03/15  12:30:20  bjax
105  * Set paused flag to non-zero by default; moved 'i' I/O rate flag
106  * switch to 'o'; made 'i' an initial conditions file switch; added
107  * null string to ls_get_settings() call so that default settings
108  * file will be read. EBJ
109  *
110  * Revision 1.4.1.4  1995/03/08  12:31:34  bjax
111  * Added userid retrieval and proper termination of time & date strings.
112  *
113  * Revision 1.4.1.3  1995/03/08  12:00:21  bjax
114  * Moved setting of default options to ls_setdefopts from
115  * ls_checkopts; rearranged order of ls_get_settings() call
116  * to between ls_setdefopts and ls_checkopts, so command
117  * line options will override settings file options.
118  * EBJ
119  *
120  * Revision 1.4.1.2  1995/03/06  18:48:49  bjax
121  * Added calles to ls_get_settings() and ls_put_settings(); added
122  * passing of dt and init flags in ls_model(). EBJ
123  *
124  * Revision 1.4.1.1  1995/03/03  02:23:08  bjax
125  * Beta version for LaRCsim, version 1.4
126  *
127  * Revision 1.3.2.7  1995/02/27  20:00:21  bjax
128  * Rebuilt LaRCsim
129  *
130  * Revision 1.3.2.6  1995/02/25  16:52:31  bjax
131  * Added 'i' option to set I/O iteration rate. EBJ
132  *
133  * Revision 1.3.2.5  1995/02/06  19:33:15  bjax
134  * Rebuilt LaRCsim
135  *
136  * Revision 1.3.2.4  1995/02/06  19:30:30  bjax
137  * Oops, should really compile these before checking in. Fixed capitailzation of
138  * Initialize in ls_loop parameter.
139  *
140  * Revision 1.3.2.3  1995/02/06  19:25:44  bjax
141  * Moved main simulation loop into subroutine ls_loop. EBJ
142  *
143  * Revision 1.3.2.2  1994/05/20  21:46:45  bjax
144  * A little better logic on checking for option arguments.
145  *
146  * Revision 1.3.2.1  1994/05/20  19:29:51  bjax
147  * Added options arguments to command line.
148  *
149  * Revision 1.3.1.16  1994/05/17  15:08:45  bjax
150  * Corrected so that full name to directyr and file is saved
151  * in new global variable "fullname"; this allows symbol table
152  * to be extracted when in another default directory.
153  *
154  * Revision 1.3.1.15  1994/05/17  14:50:24  bjax
155  * Rebuilt LaRCsim
156  *
157  * Revision 1.3.1.14  1994/05/17  14:50:23  bjax
158  * Rebuilt LaRCsim
159  *
160  * Revision 1.3.1.13  1994/05/17  14:50:21  bjax
161  * Rebuilt LaRCsim
162  *
163  * Revision 1.3.1.12  1994/05/17  14:50:20  bjax
164  * Rebuilt LaRCsim
165  *
166  * Revision 1.3.1.11  1994/05/17  13:56:24  bjax
167  * Rebuilt LaRCsim
168  *
169  * Revision 1.3.1.10  1994/05/17  13:23:03  bjax
170  * Rebuilt LaRCsim
171  *
172  * Revision 1.3.1.9  1994/05/17  13:20:03  bjax
173  * Rebuilt LaRCsim
174  *
175  * Revision 1.3.1.8  1994/05/17  13:19:23  bjax
176  * Rebuilt LaRCsim
177  *
178  * Revision 1.3.1.7  1994/05/17  13:18:29  bjax
179  * Rebuilt LaRCsim
180  *
181  * Revision 1.3.1.6  1994/05/17  13:16:30  bjax
182  * Rebuilt LaRCsim
183  *
184  * Revision 1.3.1.5  1994/05/17  13:03:44  bjax
185  * Rebuilt LaRCsim
186  *
187  * Revision 1.3.1.4  1994/05/17  13:03:38  bjax
188  * Rebuilt LaRCsim
189  *
190  * Revision 1.3.1.3  1994/05/17  12:49:08  bjax
191  * Rebuilt LaRCsim
192  *
193  * Revision 1.3.1.2  1994/05/17  12:48:45  bjax
194  * *** empty log message ***
195  *
196  * Revision 1.3.1.1  1994/05/13  20:39:17  bjax
197  * Top of 1.3 branch.
198  *
199  * Revision 1.2  1994/05/13  19:51:50  bjax
200  * Skip rev
201  *
202
203 ----------------------------------------------------------------------------
204
205         REFERENCES:
206
207 ----------------------------------------------------------------------------
208
209         CALLED BY:
210
211 ----------------------------------------------------------------------------
212
213         CALLS TO:
214
215 ----------------------------------------------------------------------------
216
217         INPUTS:
218
219 ----------------------------------------------------------------------------
220
221         OUTPUTS:
222
223 --------------------------------------------------------------------------*/
224
225 #include <sys/types.h>
226 #include <sys/stat.h>
227 #include <stdlib.h>
228 #include <stdio.h>
229 #include <math.h>
230 #include <time.h>
231
232 #include "ls_types.h"
233 #include "ls_constants.h"
234 #include "ls_generic.h"
235 #include "ls_sim_control.h"
236 #include "ls_cockpit.h"
237 #include "ls_interface.h"
238 #include "../flight.h"
239 #include "../../Aircraft/aircraft.h"
240
241 /* global variable declarations */
242
243 /* TAPE         *Tape; */
244 GENERIC         generic_;
245 SIM_CONTROL     sim_control_;
246 COCKPIT         cockpit_;
247
248 SCALAR          Simtime;
249
250 /* #define DEFAULT_TERM_UPDATE_HZ 20 */ /* original value */
251 #define DEFAULT_TERM_UPDATE_HZ 20
252 #define DEFAULT_MODEL_HZ 120
253 #define DEFAULT_END_TIME 3600.
254 #define DEFAULT_SAVE_SPACING 8
255 #define DEFAULT_WRITE_SPACING 1
256 #define MAX_FILE_NAME_LENGTH 80
257
258 /* global variables */
259
260 char    *progname;
261 char    *fullname;
262
263 /* file variables - default simulation settings */
264
265 static double model_dt;
266 static double speedup;
267 static char  asc1name[MAX_FILE_NAME_LENGTH] = "run.asc1";
268 static char  tabname[MAX_FILE_NAME_LENGTH]  = "run.dat";
269 static char  fltname[MAX_FILE_NAME_LENGTH]  = "run.flt";
270 static char  matname[MAX_FILE_NAME_LENGTH]  = "run.m";
271
272
273
274 void ls_stamp()
275 {
276     char rcsid[] = "$Id$";
277     char revid[] = "$Revision$";
278     char dateid[] = "$Date$";
279     struct tm *nowtime;
280     time_t nowtime_t;
281     long date;
282     
283     /* report version of LaRCsim*/
284     printf("\nLaRCsim %s, %s\n\n", revid, dateid); 
285     
286     nowtime_t = time( 0 );
287     nowtime = localtime( &nowtime_t ); /* set fields to correct time values */
288     date = (nowtime->tm_year)*10000 
289          + (nowtime->tm_mon + 1)*100
290          + (nowtime->tm_mday);
291     sprintf(sim_control_.date_string, "%06d\0", date);
292     sprintf(sim_control_.time_stamp, "%02d:%02d:%02d\0", 
293         nowtime->tm_hour, nowtime->tm_min, nowtime->tm_sec);
294 #ifdef COMPILE_THIS_CODE_THIS_USELESS_CODE
295     cuserid( sim_control_.userid );     /* set up user id */
296 #endif /* COMPILE_THIS_CODE_THIS_USELESS_CODE */
297     return;
298 }
299
300 void ls_setdefopts()
301 {
302     /* set default values for most options */
303
304     sim_control_.debug = 0;             /* change to non-zero if in dbx! */
305     sim_control_.vision = 0;
306     sim_control_.write_av = 0;          /* write Agile-Vu '.flt' file */
307     sim_control_.write_mat = 0;         /* write matrix-x/matlab script */
308     sim_control_.write_tab = 0;         /* write tab delim. history file */
309     sim_control_.write_asc1 = 0;        /* write GetData file */
310     sim_control_.sim_type = GLmouse;    /* hook up to mouse */
311     sim_control_.save_spacing = DEFAULT_SAVE_SPACING;   
312                                         /* interpolation on recording */
313     sim_control_.write_spacing = DEFAULT_WRITE_SPACING; 
314                                         /* interpolation on output */
315     sim_control_.end_time = DEFAULT_END_TIME;
316     sim_control_.model_hz = DEFAULT_MODEL_HZ;
317     sim_control_.term_update_hz = DEFAULT_TERM_UPDATE_HZ;
318     sim_control_.time_slices = DEFAULT_END_TIME * DEFAULT_MODEL_HZ / 
319         DEFAULT_SAVE_SPACING;
320     sim_control_.paused = 0;
321
322     speedup = 1.0;
323 }
324
325
326 /* return result codes from ls_checkopts */
327
328 #define OPT_OK 0
329 #define OPT_ERR 1
330
331 #ifdef COMPILE_THIS_CODE_THIS_USELESS_CODE
332
333 extern char *optarg;
334 extern int optind;
335
336 int ls_checkopts(argc, argv)    /* check and set options flags */
337   int argc;
338   char *argv[];
339   {
340     int c;
341     int opt_err = 0;
342     int mod_end_time = 0;
343     int mod_buf_size = 0;
344     float buffer_time, data_rate;
345
346     /* set default values */
347
348     buffer_time = sim_control_.time_slices * sim_control_.save_spacing / 
349         sim_control_.model_hz;
350     data_rate   = sim_control_.model_hz / sim_control_.save_spacing;
351
352     while ((c = getopt(argc, argv, "Aa:b:de:f:hi:kmo:r:s:t:x:")) != EOF)
353         switch (c) {
354             case 'A':
355                 if (sim_control_.sim_type == GLmouse)
356                   {
357                     fprintf(stderr, "Cannot specify both keyboard (k) and ACES (A) cockpits option\n");
358                     fprintf(stderr, "Keyboard operation assumed.\n");
359                     break;
360                   }
361                 sim_control_.sim_type = cockpit;
362                 break;
363             case 'a':
364                 sim_control_.write_av = 1;
365                 if (optarg != NULL)
366                 if (*optarg != '-') 
367                     strncpy(fltname, optarg, MAX_FILE_NAME_LENGTH);
368                 else
369                     optind--;
370                 break;
371             case 'b':   
372                 buffer_time = atof(optarg);
373                 if (buffer_time <= 0.) opt_err = -1;
374                 mod_buf_size++;
375                 break;
376             case 'd':
377                 sim_control_.debug = 1;
378                 break;
379             case 'e':
380                 sim_control_.end_time = atof(optarg);
381                 mod_end_time++;
382                 break;
383             case 'f':
384                 sim_control_.model_hz = atof(optarg);
385                 break;
386             case 'h': 
387                 opt_err = 1;
388                 break;
389             case 'i':
390                 /* ls_get_settings( optarg ); */
391                 break;
392             case 'k':
393                 sim_control_.sim_type = GLmouse;
394                 break;
395             case 'm':
396                 sim_control_.vision = 1;
397                 break;
398             case 'o': 
399                 sim_control_.term_update_hz = atof(optarg);
400                 if (sim_control_.term_update_hz <= 0.) opt_err = 1;
401                 break;
402             case 'r':
403                 sim_control_.write_mat = 1;
404                 if (optarg != NULL)
405                 if (*optarg != '-') 
406                     strncpy(matname, optarg, MAX_FILE_NAME_LENGTH);
407                 else
408                     optind--;
409                 break;
410             case 's':
411                 data_rate = atof(optarg);
412                 if (data_rate <= 0.) opt_err = -1;
413                 break;
414             case 't':
415                 sim_control_.write_tab = 1;
416                 if (optarg != NULL)
417                 if (*optarg != '-') 
418                     strncpy(tabname, optarg, MAX_FILE_NAME_LENGTH);
419                 else
420                     optind--;
421                 break;
422             case 'x':
423                 sim_control_.write_asc1 = 1;
424                 if (optarg != NULL)
425                 if (*optarg != '-') 
426                     strncpy(asc1name, optarg, MAX_FILE_NAME_LENGTH);
427                 else
428                     optind--;
429                 break;
430             default:
431                 opt_err = 1;
432             
433         }
434
435     if (opt_err)
436       {
437         fprintf(stderr, "Usage: %s [-options]\n", progname);
438         fprintf(stderr, "\n");
439         fprintf(stderr, "  where [-options] is zero or more of the following:\n");
440         fprintf(stderr, "\n");
441         fprintf(stderr, "  [A|k]           Run mode: [A]CES cockpit   [default]\n");
442         fprintf(stderr, "                         or [k]eyboard\n");
443         fprintf(stderr, "\n");
444         fprintf(stderr, "  [i <filename>]  [i]nitial conditions filename\n");
445         fprintf(stderr, "\n");
446         fprintf(stderr, "  [f <value>]     Iteration rate [f]requency, Hz (default is %5.2f Hz)\n", 
447                                                 sim_control_.model_hz);
448         fprintf(stderr, "\n");
449         fprintf(stderr, "  [o <value>]     Display [o]utput frequency, Hz (default is %5.2f Hz)\n", 
450                                                 sim_control_.term_update_hz);
451         fprintf(stderr, "\n");
452         fprintf(stderr, "  [s <value>]     Data storage frequency, Hz (default is %5.2f Hz)\n",
453                                                 data_rate);
454         fprintf(stderr, "\n");
455         fprintf(stderr, "  [e <value>]     [e]nd time in seconds (default %5.1f seconds)\n", 
456                                                 sim_control_.end_time);
457         fprintf(stderr, "\n");
458         fprintf(stderr, "  [b <value>]     circular time history storage [b]uffer size, in seconds \n");
459         fprintf(stderr, "                  (default %5.1f seconds) (normally same as end time)\n", 
460                                                 sim_control_.time_slices*sim_control_.save_spacing/
461                                                         sim_control_.model_hz);
462         fprintf(stderr, "\n");
463         fprintf(stderr, "  [atxr [<filename>]] Output: [a]gile-vu  (default name: %s )\n", fltname);
464         fprintf(stderr, "                       and/or [t]ab delimited ( '' name: %s )\n", tabname);
465         fprintf(stderr, "                       and/or [x]plot     (default name: %s)\n", asc1name);
466         fprintf(stderr, "                       and/or mat[r]ix script ( '' name: %s   )\n", matname);
467         fprintf(stderr, "\n");
468         return OPT_ERR;
469       }
470
471 /* calculate additional controls */
472
473     sim_control_.save_spacing = (int) (0.5 + sim_control_.model_hz / data_rate);
474     if (sim_control_.save_spacing < 1) sim_control_.save_spacing = 1;
475
476     sim_control_.time_slices = buffer_time * sim_control_.model_hz / 
477         sim_control_.save_spacing;
478     if (sim_control_.time_slices < 2) sim_control_.time_slices = 2;
479          
480     return OPT_OK;
481   }
482 #endif /* COMPILE_THIS_CODE_THIS_USELESS_CODE */
483
484
485 void ls_loop( dt, initialize )
486
487 SCALAR dt;
488 int initialize;
489
490 {
491     /* printf ("  In ls_loop()\n"); */
492     ls_step( dt, initialize );
493     /* if (sim_control_.sim_type == cockpit ) ls_ACES();  */
494     ls_aux();
495     ls_model( dt, initialize );
496     ls_accel();
497 }
498
499
500
501 int ls_cockpit() {
502     struct fgCONTROLS *c;
503
504     sim_control_.paused = 0;
505
506     c = &current_aircraft.controls;
507
508     Lat_control = FG_Aileron;
509     Long_control = FG_Elevator;
510     Long_trim = FG_Elev_Trim;
511     Rudder_pedal = FG_Rudder;
512     Throttle_pct = FG_Throttle[0];
513
514     /* printf("Mach = %.2f  ", Mach_number);
515     printf("%.4f,%.4f,%.2f  ", Latitude, Longitude, Altitude);
516     printf("%.2f,%.2f,%.2f\n", Phi, Theta, Psi); */
517
518 }
519
520
521 /* Initialize the LaRCsim flight model, dt is the time increment for
522    each subsequent iteration through the EOM */
523 int fgLaRCsimInit(double dt) {
524     model_dt = dt;
525
526     ls_setdefopts();            /* set default options */
527         
528     ls_stamp();   /* ID stamp; record time and date of run */
529
530     if (speedup == 0.0) {
531         fprintf(stderr, "%s: Cannot run with speedup of 0.\n", progname);
532         return 1;
533     }
534
535     printf("LS pre Init pos = %.2f\n", Latitude);
536
537     ls_init();
538
539     printf("LS post Init pos = %.2f\n", Latitude);
540
541     if (speedup > 0) {
542         /* Initialize (get) cockpit (controls) settings */
543         ls_cockpit();
544     }
545
546     return(1);
547 }
548
549
550 /* Run an iteration of the EOM (equations of motion) */
551 int fgLaRCsimUpdate(int multiloop) {
552     int i;
553
554     if (speedup > 0) {
555         ls_cockpit();
556     }
557
558     for ( i = 0; i < multiloop; i++ ) {
559         ls_loop( model_dt, 0);
560     }
561
562     return(1);
563 }
564
565
566 /* Convert from the fgFLIGHT struct to the LaRCsim generic_ struct */
567 int fgFlight_2_LaRCsim (struct fgFLIGHT *f) {
568     Mass =      FG_Mass;
569     I_xx =      FG_I_xx;
570     I_yy =      FG_I_yy;
571     I_zz =      FG_I_zz;
572     I_xz =      FG_I_xz;
573     Dx_pilot =  FG_Dx_pilot;
574     Dy_pilot =  FG_Dy_pilot;
575     Dz_pilot =  FG_Dz_pilot;
576     Dx_cg =     FG_Dx_cg;
577     Dy_cg =     FG_Dy_cg;
578     Dz_cg =     FG_Dz_cg;
579     F_X =       FG_F_X;
580     F_Y =       FG_F_Y;
581     F_Z =       FG_F_Z;
582     F_north =   FG_F_north;
583     F_east =    FG_F_east;
584     F_down =    FG_F_down;
585     F_X_aero =  FG_F_X_aero;
586     F_Y_aero =  FG_F_Y_aero;
587     F_Z_aero =  FG_F_Z_aero;
588     F_X_engine =        FG_F_X_engine;
589     F_Y_engine =        FG_F_Y_engine;
590     F_Z_engine =        FG_F_Z_engine;
591     F_X_gear =  FG_F_X_gear;
592     F_Y_gear =  FG_F_Y_gear;
593     F_Z_gear =  FG_F_Z_gear;
594     M_l_rp =    FG_M_l_rp;
595     M_m_rp =    FG_M_m_rp;
596     M_n_rp =    FG_M_n_rp;
597     M_l_cg =    FG_M_l_cg;
598     M_m_cg =    FG_M_m_cg;
599     M_n_cg =    FG_M_n_cg;
600     M_l_aero =  FG_M_l_aero;
601     M_m_aero =  FG_M_m_aero;
602     M_n_aero =  FG_M_n_aero;
603     M_l_engine =        FG_M_l_engine;
604     M_m_engine =        FG_M_m_engine;
605     M_n_engine =        FG_M_n_engine;
606     M_l_gear =  FG_M_l_gear;
607     M_m_gear =  FG_M_m_gear;
608     M_n_gear =  FG_M_n_gear;
609     V_dot_north =       FG_V_dot_north;
610     V_dot_east =        FG_V_dot_east;
611     V_dot_down =        FG_V_dot_down;
612     U_dot_body =        FG_U_dot_body;
613     V_dot_body =        FG_V_dot_body;
614     W_dot_body =        FG_W_dot_body;
615     A_X_cg =    FG_A_X_cg;
616     A_Y_cg =    FG_A_Y_cg;
617     A_Z_cg =    FG_A_Z_cg;
618     A_X_pilot = FG_A_X_pilot;
619     A_Y_pilot = FG_A_Y_pilot;
620     A_Z_pilot = FG_A_Z_pilot;
621     N_X_cg =    FG_N_X_cg;
622     N_Y_cg =    FG_N_Y_cg;
623     N_Z_cg =    FG_N_Z_cg;
624     N_X_pilot = FG_N_X_pilot;
625     N_Y_pilot = FG_N_Y_pilot;
626     N_Z_pilot = FG_N_Z_pilot;
627     P_dot_body =        FG_P_dot_body;
628     Q_dot_body =        FG_Q_dot_body;
629     R_dot_body =        FG_R_dot_body;
630     V_north =   FG_V_north;
631     V_east =    FG_V_east;
632     V_down =    FG_V_down;
633     V_north_rel_ground =        FG_V_north_rel_ground;
634     V_east_rel_ground = FG_V_east_rel_ground;
635     V_down_rel_ground = FG_V_down_rel_ground;
636     V_north_airmass =   FG_V_north_airmass;
637     V_east_airmass =    FG_V_east_airmass;
638     V_down_airmass =    FG_V_down_airmass;
639     V_north_rel_airmass =       FG_V_north_rel_airmass;
640     V_east_rel_airmass =        FG_V_east_rel_airmass;
641     V_down_rel_airmass =        FG_V_down_rel_airmass;
642     U_gust =    FG_U_gust;
643     V_gust =    FG_V_gust;
644     W_gust =    FG_W_gust;
645     U_body =    FG_U_body;
646     V_body =    FG_V_body;
647     W_body =    FG_W_body;
648     V_rel_wind =        FG_V_rel_wind;
649     V_true_kts =        FG_V_true_kts;
650     V_rel_ground =      FG_V_rel_ground;
651     V_inertial =        FG_V_inertial;
652     V_ground_speed =    FG_V_ground_speed;
653     V_equiv =   FG_V_equiv;
654     V_equiv_kts =       FG_V_equiv_kts;
655     V_calibrated =      FG_V_calibrated;
656     V_calibrated_kts =  FG_V_calibrated_kts;
657     P_body =    FG_P_body;
658     Q_body =    FG_Q_body;
659     R_body =    FG_R_body;
660     P_local =   FG_P_local;
661     Q_local =   FG_Q_local;
662     R_local =   FG_R_local;
663     P_total =   FG_P_total;
664     Q_total =   FG_Q_total;
665     R_total =   FG_R_total;
666     Phi_dot =   FG_Phi_dot;
667     Theta_dot = FG_Theta_dot;
668     Psi_dot =   FG_Psi_dot;
669     Latitude_dot =      FG_Latitude_dot;
670     Longitude_dot =     FG_Longitude_dot;
671     Radius_dot =        FG_Radius_dot;
672     Lat_geocentric =    FG_Lat_geocentric;
673     Lon_geocentric =    FG_Lon_geocentric;
674     Radius_to_vehicle = FG_Radius_to_vehicle;
675     Latitude =  FG_Latitude;
676     Longitude = FG_Longitude;
677     Altitude =  FG_Altitude;
678     Phi =       FG_Phi;
679     Theta =     FG_Theta;
680     Psi =       FG_Psi;
681     T_local_to_body_11 =        FG_T_local_to_body_11;
682     T_local_to_body_12 =        FG_T_local_to_body_12;
683     T_local_to_body_13 =        FG_T_local_to_body_13;
684     T_local_to_body_21 =        FG_T_local_to_body_21;
685     T_local_to_body_22 =        FG_T_local_to_body_22;
686     T_local_to_body_23 =        FG_T_local_to_body_23;
687     T_local_to_body_31 =        FG_T_local_to_body_31;
688     T_local_to_body_32 =        FG_T_local_to_body_32;
689     T_local_to_body_33 =        FG_T_local_to_body_33;
690     Gravity =   FG_Gravity;
691     Centrifugal_relief =        FG_Centrifugal_relief;
692     Alpha =     FG_Alpha;
693     Beta =      FG_Beta;
694     Alpha_dot = FG_Alpha_dot;
695     Beta_dot =  FG_Beta_dot;
696     Cos_alpha = FG_Cos_alpha;
697     Sin_alpha = FG_Sin_alpha;
698     Cos_beta =  FG_Cos_beta;
699     Sin_beta =  FG_Sin_beta;
700     Cos_phi =   FG_Cos_phi;
701     Sin_phi =   FG_Sin_phi;
702     Cos_theta = FG_Cos_theta;
703     Sin_theta = FG_Sin_theta;
704     Cos_psi =   FG_Cos_psi;
705     Sin_psi =   FG_Sin_psi;
706     Gamma_vert_rad =    FG_Gamma_vert_rad;
707     Gamma_horiz_rad =   FG_Gamma_horiz_rad;
708     Sigma =     FG_Sigma;
709     Density =   FG_Density;
710     V_sound =   FG_V_sound;
711     Mach_number =       FG_Mach_number;
712     Static_pressure =   FG_Static_pressure;
713     Total_pressure =    FG_Total_pressure;
714     Impact_pressure =   FG_Impact_pressure;
715     Dynamic_pressure =  FG_Dynamic_pressure;
716     Static_temperature =        FG_Static_temperature;
717     Total_temperature = FG_Total_temperature;
718     Sea_level_radius =  FG_Sea_level_radius;
719     Earth_position_angle =      FG_Earth_position_angle;
720     Runway_altitude =   FG_Runway_altitude;
721     Runway_latitude =   FG_Runway_latitude;
722     Runway_longitude =  FG_Runway_longitude;
723     Runway_heading =    FG_Runway_heading;
724     Radius_to_rwy =     FG_Radius_to_rwy;
725     D_cg_north_of_rwy = FG_D_cg_north_of_rwy;
726     D_cg_east_of_rwy =  FG_D_cg_east_of_rwy;
727     D_cg_above_rwy =    FG_D_cg_above_rwy;
728     X_cg_rwy =  FG_X_cg_rwy;
729     Y_cg_rwy =  FG_Y_cg_rwy;
730     H_cg_rwy =  FG_H_cg_rwy;
731     D_pilot_north_of_rwy =      FG_D_pilot_north_of_rwy;
732     D_pilot_east_of_rwy =       FG_D_pilot_east_of_rwy;
733     D_pilot_above_rwy = FG_D_pilot_above_rwy;
734     X_pilot_rwy =       FG_X_pilot_rwy;
735     Y_pilot_rwy =       FG_Y_pilot_rwy;
736     H_pilot_rwy =       FG_H_pilot_rwy;
737 }
738
739
740 /* Convert from the LaRCsim generic_ struct to the fgFLIGHT struct */
741 int fgLaRCsim_2_Flight (struct fgFLIGHT *f) {
742     FG_Mass =   Mass;
743     FG_I_xx =   I_xx;
744     FG_I_yy =   I_yy;
745     FG_I_zz =   I_zz;
746     FG_I_xz =   I_xz;
747     FG_Dx_pilot =       Dx_pilot;
748     FG_Dy_pilot =       Dy_pilot;
749     FG_Dz_pilot =       Dz_pilot;
750     FG_Dx_cg =  Dx_cg;
751     FG_Dy_cg =  Dy_cg;
752     FG_Dz_cg =  Dz_cg;
753     FG_F_X =    F_X;
754     FG_F_Y =    F_Y;
755     FG_F_Z =    F_Z;
756     FG_F_north =        F_north;
757     FG_F_east = F_east;
758     FG_F_down = F_down;
759     FG_F_X_aero =       F_X_aero;
760     FG_F_Y_aero =       F_Y_aero;
761     FG_F_Z_aero =       F_Z_aero;
762     FG_F_X_engine =     F_X_engine;
763     FG_F_Y_engine =     F_Y_engine;
764     FG_F_Z_engine =     F_Z_engine;
765     FG_F_X_gear =       F_X_gear;
766     FG_F_Y_gear =       F_Y_gear;
767     FG_F_Z_gear =       F_Z_gear;
768     FG_M_l_rp = M_l_rp;
769     FG_M_m_rp = M_m_rp;
770     FG_M_n_rp = M_n_rp;
771     FG_M_l_cg = M_l_cg;
772     FG_M_m_cg = M_m_cg;
773     FG_M_n_cg = M_n_cg;
774     FG_M_l_aero =       M_l_aero;
775     FG_M_m_aero =       M_m_aero;
776     FG_M_n_aero =       M_n_aero;
777     FG_M_l_engine =     M_l_engine;
778     FG_M_m_engine =     M_m_engine;
779     FG_M_n_engine =     M_n_engine;
780     FG_M_l_gear =       M_l_gear;
781     FG_M_m_gear =       M_m_gear;
782     FG_M_n_gear =       M_n_gear;
783     FG_V_dot_north =    V_dot_north;
784     FG_V_dot_east =     V_dot_east;
785     FG_V_dot_down =     V_dot_down;
786     FG_U_dot_body =     U_dot_body;
787     FG_V_dot_body =     V_dot_body;
788     FG_W_dot_body =     W_dot_body;
789     FG_A_X_cg = A_X_cg;
790     FG_A_Y_cg = A_Y_cg;
791     FG_A_Z_cg = A_Z_cg;
792     FG_A_X_pilot =      A_X_pilot;
793     FG_A_Y_pilot =      A_Y_pilot;
794     FG_A_Z_pilot =      A_Z_pilot;
795     FG_N_X_cg = N_X_cg;
796     FG_N_Y_cg = N_Y_cg;
797     FG_N_Z_cg = N_Z_cg;
798     FG_N_X_pilot =      N_X_pilot;
799     FG_N_Y_pilot =      N_Y_pilot;
800     FG_N_Z_pilot =      N_Z_pilot;
801     FG_P_dot_body =     P_dot_body;
802     FG_Q_dot_body =     Q_dot_body;
803     FG_R_dot_body =     R_dot_body;
804     FG_V_north =        V_north;
805     FG_V_east = V_east;
806     FG_V_down = V_down;
807     FG_V_north_rel_ground =     V_north_rel_ground;
808     FG_V_east_rel_ground =      V_east_rel_ground;
809     FG_V_down_rel_ground =      V_down_rel_ground;
810     FG_V_north_airmass =        V_north_airmass;
811     FG_V_east_airmass = V_east_airmass;
812     FG_V_down_airmass = V_down_airmass;
813     FG_V_north_rel_airmass =    V_north_rel_airmass;
814     FG_V_east_rel_airmass =     V_east_rel_airmass;
815     FG_V_down_rel_airmass =     V_down_rel_airmass;
816     FG_U_gust = U_gust;
817     FG_V_gust = V_gust;
818     FG_W_gust = W_gust;
819     FG_U_body = U_body;
820     FG_V_body = V_body;
821     FG_W_body = W_body;
822     FG_V_rel_wind =     V_rel_wind;
823     FG_V_true_kts =     V_true_kts;
824     FG_V_rel_ground =   V_rel_ground;
825     FG_V_inertial =     V_inertial;
826     FG_V_ground_speed = V_ground_speed;
827     FG_V_equiv =        V_equiv;
828     FG_V_equiv_kts =    V_equiv_kts;
829     FG_V_calibrated =   V_calibrated;
830     FG_V_calibrated_kts =       V_calibrated_kts;
831     FG_P_body = P_body;
832     FG_Q_body = Q_body;
833     FG_R_body = R_body;
834     FG_P_local =        P_local;
835     FG_Q_local =        Q_local;
836     FG_R_local =        R_local;
837     FG_P_total =        P_total;
838     FG_Q_total =        Q_total;
839     FG_R_total =        R_total;
840     FG_Phi_dot =        Phi_dot;
841     FG_Theta_dot =      Theta_dot;
842     FG_Psi_dot =        Psi_dot;
843     FG_Latitude_dot =   Latitude_dot;
844     FG_Longitude_dot =  Longitude_dot;
845     FG_Radius_dot =     Radius_dot;
846     FG_Lat_geocentric = Lat_geocentric;
847     FG_Lon_geocentric = Lon_geocentric;
848     FG_Radius_to_vehicle =      Radius_to_vehicle;
849     FG_Latitude =       Latitude;
850     FG_Longitude =      Longitude;
851     FG_Altitude =       Altitude;
852     FG_Phi =    Phi;
853     FG_Theta =  Theta;
854     FG_Psi =    Psi;
855     FG_T_local_to_body_11 =     T_local_to_body_11;
856     FG_T_local_to_body_12 =     T_local_to_body_12;
857     FG_T_local_to_body_13 =     T_local_to_body_13;
858     FG_T_local_to_body_21 =     T_local_to_body_21;
859     FG_T_local_to_body_22 =     T_local_to_body_22;
860     FG_T_local_to_body_23 =     T_local_to_body_23;
861     FG_T_local_to_body_31 =     T_local_to_body_31;
862     FG_T_local_to_body_32 =     T_local_to_body_32;
863     FG_T_local_to_body_33 =     T_local_to_body_33;
864     FG_Gravity =        Gravity;
865     FG_Centrifugal_relief =     Centrifugal_relief;
866     FG_Alpha =  Alpha;
867     FG_Beta =   Beta;
868     FG_Alpha_dot =      Alpha_dot;
869     FG_Beta_dot =       Beta_dot;
870     FG_Cos_alpha =      Cos_alpha;
871     FG_Sin_alpha =      Sin_alpha;
872     FG_Cos_beta =       Cos_beta;
873     FG_Sin_beta =       Sin_beta;
874     FG_Cos_phi =        Cos_phi;
875     FG_Sin_phi =        Sin_phi;
876     FG_Cos_theta =      Cos_theta;
877     FG_Sin_theta =      Sin_theta;
878     FG_Cos_psi =        Cos_psi;
879     FG_Sin_psi =        Sin_psi;
880     FG_Gamma_vert_rad = Gamma_vert_rad;
881     FG_Gamma_horiz_rad =        Gamma_horiz_rad;
882     FG_Sigma =  Sigma;
883     FG_Density =        Density;
884     FG_V_sound =        V_sound;
885     FG_Mach_number =    Mach_number;
886     FG_Static_pressure =        Static_pressure;
887     FG_Total_pressure = Total_pressure;
888     FG_Impact_pressure =        Impact_pressure;
889     FG_Dynamic_pressure =       Dynamic_pressure;
890     FG_Static_temperature =     Static_temperature;
891     FG_Total_temperature =      Total_temperature;
892     FG_Sea_level_radius =       Sea_level_radius;
893     FG_Earth_position_angle =   Earth_position_angle;
894     FG_Runway_altitude =        Runway_altitude;
895     FG_Runway_latitude =        Runway_latitude;
896     FG_Runway_longitude =       Runway_longitude;
897     FG_Runway_heading = Runway_heading;
898     FG_Radius_to_rwy =  Radius_to_rwy;
899     FG_D_cg_north_of_rwy =      D_cg_north_of_rwy;
900     FG_D_cg_east_of_rwy =       D_cg_east_of_rwy;
901     FG_D_cg_above_rwy = D_cg_above_rwy;
902     FG_X_cg_rwy =       X_cg_rwy;
903     FG_Y_cg_rwy =       Y_cg_rwy;
904     FG_H_cg_rwy =       H_cg_rwy;
905     FG_D_pilot_north_of_rwy =   D_pilot_north_of_rwy;
906     FG_D_pilot_east_of_rwy =    D_pilot_east_of_rwy;
907     FG_D_pilot_above_rwy =      D_pilot_above_rwy;
908     FG_X_pilot_rwy =    X_pilot_rwy;
909     FG_Y_pilot_rwy =    Y_pilot_rwy;
910     FG_H_pilot_rwy =    H_pilot_rwy;
911 }
912
913 /* Flight Gear Modification Log
914  *
915  * $Log$
916  * Revision 1.12  1998/01/06 01:20:16  curt
917  * Tweaks to help building with MSVC++
918  *
919  * Revision 1.11  1998/01/05 22:19:26  curt
920  * #ifdef'd out some unused code that was problematic for MSVC++ to compile.
921  *
922  * Revision 1.10  1997/12/10 22:37:43  curt
923  * Prepended "fg" on the name of all global structures that didn't have it yet.
924  * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
925  *
926  * Revision 1.9  1997/08/27 03:30:08  curt
927  * Changed naming scheme of basic shared structures.
928  *
929  * Revision 1.8  1997/06/21 17:12:50  curt
930  * Capitalized subdirectory names.
931  *
932  * Revision 1.7  1997/05/31 19:16:28  curt
933  * Elevator trim added.
934  *
935  * Revision 1.6  1997/05/31 04:13:53  curt
936  * WE CAN NOW FLY!!!
937  *
938  * Continuing work on the LaRCsim flight model integration.
939  * Added some MSFS-like keyboard input handling.
940  *
941  * Revision 1.5  1997/05/30 23:26:25  curt
942  * Added elevator/aileron controls.
943  *
944  * Revision 1.4  1997/05/30 19:30:15  curt
945  * The LaRCsim flight model is starting to look like it is working.
946  *
947  * Revision 1.3  1997/05/30 03:54:12  curt
948  * Made a bit more progress towards integrating the LaRCsim flight model.
949  *
950  * Revision 1.2  1997/05/29 22:39:59  curt
951  * Working on incorporating the LaRCsim flight model.
952  *
953  * Revision 1.1  1997/05/29 00:09:57  curt
954  * Initial Flight Gear revision.
955  *
956  */