]> git.mxchange.org Git - flightgear.git/blob - LaRCsim/ls_interface.c
Working on incorporating the LaRCsim flight model.
[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
240 /* global variable declarations */
241
242 /* TAPE         *Tape; */
243 GENERIC         generic_;
244 SIM_CONTROL     sim_control_;
245 COCKPIT         cockpit_;
246
247 SCALAR          Simtime;
248
249 /* #define DEFAULT_TERM_UPDATE_HZ 20 */ /* original value */
250 #define DEFAULT_TERM_UPDATE_HZ 20
251 #define DEFAULT_MODEL_HZ 120
252 #define DEFAULT_END_TIME 3600.
253 #define DEFAULT_SAVE_SPACING 8
254 #define DEFAULT_WRITE_SPACING 1
255 #define MAX_FILE_NAME_LENGTH 80
256
257 /* global variables */
258
259 char    *progname;
260 char    *fullname;
261
262 /* file variables - default simulation settings */
263
264 static double model_dt;
265 static double speedup;
266 static char  asc1name[MAX_FILE_NAME_LENGTH] = "run.asc1";
267 static char  tabname[MAX_FILE_NAME_LENGTH]  = "run.dat";
268 static char  fltname[MAX_FILE_NAME_LENGTH]  = "run.flt";
269 static char  matname[MAX_FILE_NAME_LENGTH]  = "run.m";
270
271
272
273 void ls_stamp()
274 {
275     char rcsid[] = "$Id$";
276     char revid[] = "$Revision$";
277     char dateid[] = "$Date$";
278     struct tm *nowtime;
279     time_t nowtime_t;
280     long date;
281     
282     /* report version of LaRCsim*/
283     printf("\nLaRCsim %s, %s\n\n", revid, dateid); 
284     
285     nowtime_t = time( 0 );
286     nowtime = localtime( &nowtime_t ); /* set fields to correct time values */
287     date = (nowtime->tm_year)*10000 
288          + (nowtime->tm_mon + 1)*100
289          + (nowtime->tm_mday);
290     sprintf(sim_control_.date_string, "%06d\0", date);
291     sprintf(sim_control_.time_stamp, "%02d:%02d:%02d\0", 
292         nowtime->tm_hour, nowtime->tm_min, nowtime->tm_sec);
293     cuserid( sim_control_.userid );     /* set up user id */
294
295     return;
296 }
297
298 void ls_setdefopts()
299 {
300     /* set default values for most options */
301
302     sim_control_.debug = 0;             /* change to non-zero if in dbx! */
303     sim_control_.vision = 0;
304     sim_control_.write_av = 0;          /* write Agile-Vu '.flt' file */
305     sim_control_.write_mat = 0;         /* write matrix-x/matlab script */
306     sim_control_.write_tab = 0;         /* write tab delim. history file */
307     sim_control_.write_asc1 = 0;        /* write GetData file */
308     sim_control_.sim_type = GLmouse;    /* hook up to mouse */
309     sim_control_.save_spacing = DEFAULT_SAVE_SPACING;   
310                                         /* interpolation on recording */
311     sim_control_.write_spacing = DEFAULT_WRITE_SPACING; 
312                                         /* interpolation on output */
313     sim_control_.end_time = DEFAULT_END_TIME;
314     sim_control_.model_hz = DEFAULT_MODEL_HZ;
315     sim_control_.term_update_hz = DEFAULT_TERM_UPDATE_HZ;
316     sim_control_.time_slices = DEFAULT_END_TIME * DEFAULT_MODEL_HZ / 
317         DEFAULT_SAVE_SPACING;
318     sim_control_.paused = 0;
319
320     speedup = 1.0;
321 }
322
323
324 /* return result codes from ls_checkopts */
325
326 #define OPT_OK 0
327 #define OPT_ERR 1
328
329 extern char *optarg;
330 extern int optind;
331
332 int ls_checkopts(argc, argv)    /* check and set options flags */
333   int argc;
334   char *argv[];
335   {
336     int c;
337     int opt_err = 0;
338     int mod_end_time = 0;
339     int mod_buf_size = 0;
340     float buffer_time, data_rate;
341
342     /* set default values */
343
344     buffer_time = sim_control_.time_slices * sim_control_.save_spacing / 
345         sim_control_.model_hz;
346     data_rate   = sim_control_.model_hz / sim_control_.save_spacing;
347
348     while ((c = getopt(argc, argv, "Aa:b:de:f:hi:kmo:r:s:t:x:")) != EOF)
349         switch (c) {
350             case 'A':
351                 if (sim_control_.sim_type == GLmouse)
352                   {
353                     fprintf(stderr, "Cannot specify both keyboard (k) and ACES (A) cockpits option\n");
354                     fprintf(stderr, "Keyboard operation assumed.\n");
355                     break;
356                   }
357                 sim_control_.sim_type = cockpit;
358                 break;
359             case 'a':
360                 sim_control_.write_av = 1;
361                 if (optarg != NULL)
362                 if (*optarg != '-') 
363                     strncpy(fltname, optarg, MAX_FILE_NAME_LENGTH);
364                 else
365                     optind--;
366                 break;
367             case 'b':   
368                 buffer_time = atof(optarg);
369                 if (buffer_time <= 0.) opt_err = -1;
370                 mod_buf_size++;
371                 break;
372             case 'd':
373                 sim_control_.debug = 1;
374                 break;
375             case 'e':
376                 sim_control_.end_time = atof(optarg);
377                 mod_end_time++;
378                 break;
379             case 'f':
380                 sim_control_.model_hz = atof(optarg);
381                 break;
382             case 'h': 
383                 opt_err = 1;
384                 break;
385             case 'i':
386                 /* ls_get_settings( optarg ); */
387                 break;
388             case 'k':
389                 sim_control_.sim_type = GLmouse;
390                 break;
391             case 'm':
392                 sim_control_.vision = 1;
393                 break;
394             case 'o': 
395                 sim_control_.term_update_hz = atof(optarg);
396                 if (sim_control_.term_update_hz <= 0.) opt_err = 1;
397                 break;
398             case 'r':
399                 sim_control_.write_mat = 1;
400                 if (optarg != NULL)
401                 if (*optarg != '-') 
402                     strncpy(matname, optarg, MAX_FILE_NAME_LENGTH);
403                 else
404                     optind--;
405                 break;
406             case 's':
407                 data_rate = atof(optarg);
408                 if (data_rate <= 0.) opt_err = -1;
409                 break;
410             case 't':
411                 sim_control_.write_tab = 1;
412                 if (optarg != NULL)
413                 if (*optarg != '-') 
414                     strncpy(tabname, optarg, MAX_FILE_NAME_LENGTH);
415                 else
416                     optind--;
417                 break;
418             case 'x':
419                 sim_control_.write_asc1 = 1;
420                 if (optarg != NULL)
421                 if (*optarg != '-') 
422                     strncpy(asc1name, optarg, MAX_FILE_NAME_LENGTH);
423                 else
424                     optind--;
425                 break;
426             default:
427                 opt_err = 1;
428             
429         }
430
431     if (opt_err)
432       {
433         fprintf(stderr, "Usage: %s [-options]\n", progname);
434         fprintf(stderr, "\n");
435         fprintf(stderr, "  where [-options] is zero or more of the following:\n");
436         fprintf(stderr, "\n");
437         fprintf(stderr, "  [A|k]           Run mode: [A]CES cockpit   [default]\n");
438         fprintf(stderr, "                         or [k]eyboard\n");
439         fprintf(stderr, "\n");
440         fprintf(stderr, "  [i <filename>]  [i]nitial conditions filename\n");
441         fprintf(stderr, "\n");
442         fprintf(stderr, "  [f <value>]     Iteration rate [f]requency, Hz (default is %5.2f Hz)\n", 
443                                                 sim_control_.model_hz);
444         fprintf(stderr, "\n");
445         fprintf(stderr, "  [o <value>]     Display [o]utput frequency, Hz (default is %5.2f Hz)\n", 
446                                                 sim_control_.term_update_hz);
447         fprintf(stderr, "\n");
448         fprintf(stderr, "  [s <value>]     Data storage frequency, Hz (default is %5.2f Hz)\n",
449                                                 data_rate);
450         fprintf(stderr, "\n");
451         fprintf(stderr, "  [e <value>]     [e]nd time in seconds (default %5.1f seconds)\n", 
452                                                 sim_control_.end_time);
453         fprintf(stderr, "\n");
454         fprintf(stderr, "  [b <value>]     circular time history storage [b]uffer size, in seconds \n");
455         fprintf(stderr, "                  (default %5.1f seconds) (normally same as end time)\n", 
456                                                 sim_control_.time_slices*sim_control_.save_spacing/
457                                                         sim_control_.model_hz);
458         fprintf(stderr, "\n");
459         fprintf(stderr, "  [atxr [<filename>]] Output: [a]gile-vu  (default name: %s )\n", fltname);
460         fprintf(stderr, "                       and/or [t]ab delimited ( '' name: %s )\n", tabname);
461         fprintf(stderr, "                       and/or [x]plot     (default name: %s)\n", asc1name);
462         fprintf(stderr, "                       and/or mat[r]ix script ( '' name: %s   )\n", matname);
463         fprintf(stderr, "\n");
464         return OPT_ERR;
465       }
466
467 /* calculate additional controls */
468
469     sim_control_.save_spacing = (int) (0.5 + sim_control_.model_hz / data_rate);
470     if (sim_control_.save_spacing < 1) sim_control_.save_spacing = 1;
471
472     sim_control_.time_slices = buffer_time * sim_control_.model_hz / 
473         sim_control_.save_spacing;
474     if (sim_control_.time_slices < 2) sim_control_.time_slices = 2;
475          
476     return OPT_OK;
477   }
478
479
480 void ls_loop( dt, initialize )
481
482 SCALAR dt;
483 int initialize;
484
485 {
486     /* printf ("  In ls_loop()\n"); */
487     ls_step( dt, initialize );
488     /* if (sim_control_.sim_type == cockpit ) ls_ACES();  */
489     ls_aux();
490     ls_model( dt, initialize );
491     ls_accel();
492 }
493
494
495
496 int ls_cockpit() {
497     sim_control_.paused = 0;
498
499     Throttle_pct = 0.25;
500
501     printf("Mach = %.2f  ", Mach_number);
502     printf("%.4f,%.4f,%.2f  ", Latitude, Longitude, Altitude);
503     printf("%.2f,%.2f,%.2f\n", Phi, Theta, Psi);
504
505 }
506
507
508 /* Initialize the LaRCsim flight model, dt is the time increment for
509    each subsequent iteration through the EOM */
510 int fgLaRCsimInit(double dt) {
511     model_dt = dt;
512
513     ls_setdefopts();            /* set default options */
514         
515     ls_stamp();   /* ID stamp; record time and date of run */
516
517     if (speedup == 0.0) {
518         fprintf(stderr, "%s: Cannot run with speedup of 0.\n", progname);
519         return 1;
520     }
521
522     printf("LS pre Init pos = %.2f\n", Latitude);
523
524     ls_init();
525
526     printf("LS post Init pos = %.2f\n", Latitude);
527
528     if (speedup > 0) {
529         /* Initialize (get) cockpit (controls) settings */
530         ls_cockpit();
531     }
532
533     return(1);
534 }
535
536
537 /* Run an iteration of the EOM (equations of motion) */
538 int fgLaRCsimUpdate(int multiloop) {
539     int i;
540
541     if (speedup > 0) {
542         ls_cockpit();
543     }
544
545     for ( i = 0; i < multiloop; i++ ) {
546         ls_loop( model_dt, 0);
547     }
548
549     return(1);
550 }
551
552
553 /* Convert from the FG flight_params struct to the LaRCsim generic_ struct */
554 int fgFlight_2_LaRCsim (struct flight_params *f) {
555     Mass =      FG_Mass;
556     I_xx =      FG_I_xx;
557     I_yy =      FG_I_yy;
558     I_zz =      FG_I_zz;
559     I_xz =      FG_I_xz;
560     Dx_pilot =  FG_Dx_pilot;
561     Dy_pilot =  FG_Dy_pilot;
562     Dz_pilot =  FG_Dz_pilot;
563     Dx_cg =     FG_Dx_cg;
564     Dy_cg =     FG_Dy_cg;
565     Dz_cg =     FG_Dz_cg;
566     F_X =       FG_F_X;
567     F_Y =       FG_F_Y;
568     F_Z =       FG_F_Z;
569     F_north =   FG_F_north;
570     F_east =    FG_F_east;
571     F_down =    FG_F_down;
572     F_X_aero =  FG_F_X_aero;
573     F_Y_aero =  FG_F_Y_aero;
574     F_Z_aero =  FG_F_Z_aero;
575     F_X_engine =        FG_F_X_engine;
576     F_Y_engine =        FG_F_Y_engine;
577     F_Z_engine =        FG_F_Z_engine;
578     F_X_gear =  FG_F_X_gear;
579     F_Y_gear =  FG_F_Y_gear;
580     F_Z_gear =  FG_F_Z_gear;
581     M_l_rp =    FG_M_l_rp;
582     M_m_rp =    FG_M_m_rp;
583     M_n_rp =    FG_M_n_rp;
584     M_l_cg =    FG_M_l_cg;
585     M_m_cg =    FG_M_m_cg;
586     M_n_cg =    FG_M_n_cg;
587     M_l_aero =  FG_M_l_aero;
588     M_m_aero =  FG_M_m_aero;
589     M_n_aero =  FG_M_n_aero;
590     M_l_engine =        FG_M_l_engine;
591     M_m_engine =        FG_M_m_engine;
592     M_n_engine =        FG_M_n_engine;
593     M_l_gear =  FG_M_l_gear;
594     M_m_gear =  FG_M_m_gear;
595     M_n_gear =  FG_M_n_gear;
596     V_dot_north =       FG_V_dot_north;
597     V_dot_east =        FG_V_dot_east;
598     V_dot_down =        FG_V_dot_down;
599     U_dot_body =        FG_U_dot_body;
600     V_dot_body =        FG_V_dot_body;
601     W_dot_body =        FG_W_dot_body;
602     A_X_cg =    FG_A_X_cg;
603     A_Y_cg =    FG_A_Y_cg;
604     A_Z_cg =    FG_A_Z_cg;
605     A_X_pilot = FG_A_X_pilot;
606     A_Y_pilot = FG_A_Y_pilot;
607     A_Z_pilot = FG_A_Z_pilot;
608     N_X_cg =    FG_N_X_cg;
609     N_Y_cg =    FG_N_Y_cg;
610     N_Z_cg =    FG_N_Z_cg;
611     N_X_pilot = FG_N_X_pilot;
612     N_Y_pilot = FG_N_Y_pilot;
613     N_Z_pilot = FG_N_Z_pilot;
614     P_dot_body =        FG_P_dot_body;
615     Q_dot_body =        FG_Q_dot_body;
616     R_dot_body =        FG_R_dot_body;
617     V_north =   FG_V_north;
618     V_east =    FG_V_east;
619     V_down =    FG_V_down;
620     V_north_rel_ground =        FG_V_north_rel_ground;
621     V_east_rel_ground = FG_V_east_rel_ground;
622     V_down_rel_ground = FG_V_down_rel_ground;
623     V_north_airmass =   FG_V_north_airmass;
624     V_east_airmass =    FG_V_east_airmass;
625     V_down_airmass =    FG_V_down_airmass;
626     V_north_rel_airmass =       FG_V_north_rel_airmass;
627     V_east_rel_airmass =        FG_V_east_rel_airmass;
628     V_down_rel_airmass =        FG_V_down_rel_airmass;
629     U_gust =    FG_U_gust;
630     V_gust =    FG_V_gust;
631     W_gust =    FG_W_gust;
632     U_body =    FG_U_body;
633     V_body =    FG_V_body;
634     W_body =    FG_W_body;
635     V_rel_wind =        FG_V_rel_wind;
636     V_true_kts =        FG_V_true_kts;
637     V_rel_ground =      FG_V_rel_ground;
638     V_inertial =        FG_V_inertial;
639     V_ground_speed =    FG_V_ground_speed;
640     V_equiv =   FG_V_equiv;
641     V_equiv_kts =       FG_V_equiv_kts;
642     V_calibrated =      FG_V_calibrated;
643     V_calibrated_kts =  FG_V_calibrated_kts;
644     P_body =    FG_P_body;
645     Q_body =    FG_Q_body;
646     R_body =    FG_R_body;
647     P_local =   FG_P_local;
648     Q_local =   FG_Q_local;
649     R_local =   FG_R_local;
650     P_total =   FG_P_total;
651     Q_total =   FG_Q_total;
652     R_total =   FG_R_total;
653     Phi_dot =   FG_Phi_dot;
654     Theta_dot = FG_Theta_dot;
655     Psi_dot =   FG_Psi_dot;
656     Latitude_dot =      FG_Latitude_dot;
657     Longitude_dot =     FG_Longitude_dot;
658     Radius_dot =        FG_Radius_dot;
659     Lat_geocentric =    FG_Lat_geocentric;
660     Lon_geocentric =    FG_Lon_geocentric;
661     Radius_to_vehicle = FG_Radius_to_vehicle;
662     Latitude =  FG_Latitude;
663     Longitude = FG_Longitude;
664     Altitude =  FG_Altitude;
665     Phi =       FG_Phi;
666     Theta =     FG_Theta;
667     Psi =       FG_Psi;
668     T_local_to_body_11 =        FG_T_local_to_body_11;
669     T_local_to_body_12 =        FG_T_local_to_body_12;
670     T_local_to_body_13 =        FG_T_local_to_body_13;
671     T_local_to_body_21 =        FG_T_local_to_body_21;
672     T_local_to_body_22 =        FG_T_local_to_body_22;
673     T_local_to_body_23 =        FG_T_local_to_body_23;
674     T_local_to_body_31 =        FG_T_local_to_body_31;
675     T_local_to_body_32 =        FG_T_local_to_body_32;
676     T_local_to_body_33 =        FG_T_local_to_body_33;
677     Gravity =   FG_Gravity;
678     Centrifugal_relief =        FG_Centrifugal_relief;
679     Alpha =     FG_Alpha;
680     Beta =      FG_Beta;
681     Alpha_dot = FG_Alpha_dot;
682     Beta_dot =  FG_Beta_dot;
683     Cos_alpha = FG_Cos_alpha;
684     Sin_alpha = FG_Sin_alpha;
685     Cos_beta =  FG_Cos_beta;
686     Sin_beta =  FG_Sin_beta;
687     Cos_phi =   FG_Cos_phi;
688     Sin_phi =   FG_Sin_phi;
689     Cos_theta = FG_Cos_theta;
690     Sin_theta = FG_Sin_theta;
691     Cos_psi =   FG_Cos_psi;
692     Sin_psi =   FG_Sin_psi;
693     Gamma_vert_rad =    FG_Gamma_vert_rad;
694     Gamma_horiz_rad =   FG_Gamma_horiz_rad;
695     Sigma =     FG_Sigma;
696     Density =   FG_Density;
697     V_sound =   FG_V_sound;
698     Mach_number =       FG_Mach_number;
699     Static_pressure =   FG_Static_pressure;
700     Total_pressure =    FG_Total_pressure;
701     Impact_pressure =   FG_Impact_pressure;
702     Dynamic_pressure =  FG_Dynamic_pressure;
703     Static_temperature =        FG_Static_temperature;
704     Total_temperature = FG_Total_temperature;
705     Sea_level_radius =  FG_Sea_level_radius;
706     Earth_position_angle =      FG_Earth_position_angle;
707     Runway_altitude =   FG_Runway_altitude;
708     Runway_latitude =   FG_Runway_latitude;
709     Runway_longitude =  FG_Runway_longitude;
710     Runway_heading =    FG_Runway_heading;
711     Radius_to_rwy =     FG_Radius_to_rwy;
712     D_cg_north_of_rwy = FG_D_cg_north_of_rwy;
713     D_cg_east_of_rwy =  FG_D_cg_east_of_rwy;
714     D_cg_above_rwy =    FG_D_cg_above_rwy;
715     X_cg_rwy =  FG_X_cg_rwy;
716     Y_cg_rwy =  FG_Y_cg_rwy;
717     H_cg_rwy =  FG_H_cg_rwy;
718     D_pilot_north_of_rwy =      FG_D_pilot_north_of_rwy;
719     D_pilot_east_of_rwy =       FG_D_pilot_east_of_rwy;
720     D_pilot_above_rwy = FG_D_pilot_above_rwy;
721     X_pilot_rwy =       FG_X_pilot_rwy;
722     Y_pilot_rwy =       FG_Y_pilot_rwy;
723     H_pilot_rwy =       FG_H_pilot_rwy;
724 }
725
726
727 /* Convert from the LaRCsim generic_ struct to the FG flight_params struct */
728 int fgLaRCsim_2_Flight (struct flight_params *f) {
729     FG_Mass =   Mass;
730     FG_I_xx =   I_xx;
731     FG_I_yy =   I_yy;
732     FG_I_zz =   I_zz;
733     FG_I_xz =   I_xz;
734     FG_Dx_pilot =       Dx_pilot;
735     FG_Dy_pilot =       Dy_pilot;
736     FG_Dz_pilot =       Dz_pilot;
737     FG_Dx_cg =  Dx_cg;
738     FG_Dy_cg =  Dy_cg;
739     FG_Dz_cg =  Dz_cg;
740     FG_F_X =    F_X;
741     FG_F_Y =    F_Y;
742     FG_F_Z =    F_Z;
743     FG_F_north =        F_north;
744     FG_F_east = F_east;
745     FG_F_down = F_down;
746     FG_F_X_aero =       F_X_aero;
747     FG_F_Y_aero =       F_Y_aero;
748     FG_F_Z_aero =       F_Z_aero;
749     FG_F_X_engine =     F_X_engine;
750     FG_F_Y_engine =     F_Y_engine;
751     FG_F_Z_engine =     F_Z_engine;
752     FG_F_X_gear =       F_X_gear;
753     FG_F_Y_gear =       F_Y_gear;
754     FG_F_Z_gear =       F_Z_gear;
755     FG_M_l_rp = M_l_rp;
756     FG_M_m_rp = M_m_rp;
757     FG_M_n_rp = M_n_rp;
758     FG_M_l_cg = M_l_cg;
759     FG_M_m_cg = M_m_cg;
760     FG_M_n_cg = M_n_cg;
761     FG_M_l_aero =       M_l_aero;
762     FG_M_m_aero =       M_m_aero;
763     FG_M_n_aero =       M_n_aero;
764     FG_M_l_engine =     M_l_engine;
765     FG_M_m_engine =     M_m_engine;
766     FG_M_n_engine =     M_n_engine;
767     FG_M_l_gear =       M_l_gear;
768     FG_M_m_gear =       M_m_gear;
769     FG_M_n_gear =       M_n_gear;
770     FG_V_dot_north =    V_dot_north;
771     FG_V_dot_east =     V_dot_east;
772     FG_V_dot_down =     V_dot_down;
773     FG_U_dot_body =     U_dot_body;
774     FG_V_dot_body =     V_dot_body;
775     FG_W_dot_body =     W_dot_body;
776     FG_A_X_cg = A_X_cg;
777     FG_A_Y_cg = A_Y_cg;
778     FG_A_Z_cg = A_Z_cg;
779     FG_A_X_pilot =      A_X_pilot;
780     FG_A_Y_pilot =      A_Y_pilot;
781     FG_A_Z_pilot =      A_Z_pilot;
782     FG_N_X_cg = N_X_cg;
783     FG_N_Y_cg = N_Y_cg;
784     FG_N_Z_cg = N_Z_cg;
785     FG_N_X_pilot =      N_X_pilot;
786     FG_N_Y_pilot =      N_Y_pilot;
787     FG_N_Z_pilot =      N_Z_pilot;
788     FG_P_dot_body =     P_dot_body;
789     FG_Q_dot_body =     Q_dot_body;
790     FG_R_dot_body =     R_dot_body;
791     FG_V_north =        V_north;
792     FG_V_east = V_east;
793     FG_V_down = V_down;
794     FG_V_north_rel_ground =     V_north_rel_ground;
795     FG_V_east_rel_ground =      V_east_rel_ground;
796     FG_V_down_rel_ground =      V_down_rel_ground;
797     FG_V_north_airmass =        V_north_airmass;
798     FG_V_east_airmass = V_east_airmass;
799     FG_V_down_airmass = V_down_airmass;
800     FG_V_north_rel_airmass =    V_north_rel_airmass;
801     FG_V_east_rel_airmass =     V_east_rel_airmass;
802     FG_V_down_rel_airmass =     V_down_rel_airmass;
803     FG_U_gust = U_gust;
804     FG_V_gust = V_gust;
805     FG_W_gust = W_gust;
806     FG_U_body = U_body;
807     FG_V_body = V_body;
808     FG_W_body = W_body;
809     FG_V_rel_wind =     V_rel_wind;
810     FG_V_true_kts =     V_true_kts;
811     FG_V_rel_ground =   V_rel_ground;
812     FG_V_inertial =     V_inertial;
813     FG_V_ground_speed = V_ground_speed;
814     FG_V_equiv =        V_equiv;
815     FG_V_equiv_kts =    V_equiv_kts;
816     FG_V_calibrated =   V_calibrated;
817     FG_V_calibrated_kts =       V_calibrated_kts;
818     FG_P_body = P_body;
819     FG_Q_body = Q_body;
820     FG_R_body = R_body;
821     FG_P_local =        P_local;
822     FG_Q_local =        Q_local;
823     FG_R_local =        R_local;
824     FG_P_total =        P_total;
825     FG_Q_total =        Q_total;
826     FG_R_total =        R_total;
827     FG_Phi_dot =        Phi_dot;
828     FG_Theta_dot =      Theta_dot;
829     FG_Psi_dot =        Psi_dot;
830     FG_Latitude_dot =   Latitude_dot;
831     FG_Longitude_dot =  Longitude_dot;
832     FG_Radius_dot =     Radius_dot;
833     FG_Lat_geocentric = Lat_geocentric;
834     FG_Lon_geocentric = Lon_geocentric;
835     FG_Radius_to_vehicle =      Radius_to_vehicle;
836     FG_Latitude =       Latitude;
837     FG_Longitude =      Longitude;
838     FG_Altitude =       Altitude;
839     FG_Phi =    Phi;
840     FG_Theta =  Theta;
841     FG_Psi =    Psi;
842     FG_T_local_to_body_11 =     T_local_to_body_11;
843     FG_T_local_to_body_12 =     T_local_to_body_12;
844     FG_T_local_to_body_13 =     T_local_to_body_13;
845     FG_T_local_to_body_21 =     T_local_to_body_21;
846     FG_T_local_to_body_22 =     T_local_to_body_22;
847     FG_T_local_to_body_23 =     T_local_to_body_23;
848     FG_T_local_to_body_31 =     T_local_to_body_31;
849     FG_T_local_to_body_32 =     T_local_to_body_32;
850     FG_T_local_to_body_33 =     T_local_to_body_33;
851     FG_Gravity =        Gravity;
852     FG_Centrifugal_relief =     Centrifugal_relief;
853     FG_Alpha =  Alpha;
854     FG_Beta =   Beta;
855     FG_Alpha_dot =      Alpha_dot;
856     FG_Beta_dot =       Beta_dot;
857     FG_Cos_alpha =      Cos_alpha;
858     FG_Sin_alpha =      Sin_alpha;
859     FG_Cos_beta =       Cos_beta;
860     FG_Sin_beta =       Sin_beta;
861     FG_Cos_phi =        Cos_phi;
862     FG_Sin_phi =        Sin_phi;
863     FG_Cos_theta =      Cos_theta;
864     FG_Sin_theta =      Sin_theta;
865     FG_Cos_psi =        Cos_psi;
866     FG_Sin_psi =        Sin_psi;
867     FG_Gamma_vert_rad = Gamma_vert_rad;
868     FG_Gamma_horiz_rad =        Gamma_horiz_rad;
869     FG_Sigma =  Sigma;
870     FG_Density =        Density;
871     FG_V_sound =        V_sound;
872     FG_Mach_number =    Mach_number;
873     FG_Static_pressure =        Static_pressure;
874     FG_Total_pressure = Total_pressure;
875     FG_Impact_pressure =        Impact_pressure;
876     FG_Dynamic_pressure =       Dynamic_pressure;
877     FG_Static_temperature =     Static_temperature;
878     FG_Total_temperature =      Total_temperature;
879     FG_Sea_level_radius =       Sea_level_radius;
880     FG_Earth_position_angle =   Earth_position_angle;
881     FG_Runway_altitude =        Runway_altitude;
882     FG_Runway_latitude =        Runway_latitude;
883     FG_Runway_longitude =       Runway_longitude;
884     FG_Runway_heading = Runway_heading;
885     FG_Radius_to_rwy =  Radius_to_rwy;
886     FG_D_cg_north_of_rwy =      D_cg_north_of_rwy;
887     FG_D_cg_east_of_rwy =       D_cg_east_of_rwy;
888     FG_D_cg_above_rwy = D_cg_above_rwy;
889     FG_X_cg_rwy =       X_cg_rwy;
890     FG_Y_cg_rwy =       Y_cg_rwy;
891     FG_H_cg_rwy =       H_cg_rwy;
892     FG_D_pilot_north_of_rwy =   D_pilot_north_of_rwy;
893     FG_D_pilot_east_of_rwy =    D_pilot_east_of_rwy;
894     FG_D_pilot_above_rwy =      D_pilot_above_rwy;
895     FG_X_pilot_rwy =    X_pilot_rwy;
896     FG_Y_pilot_rwy =    Y_pilot_rwy;
897     FG_H_pilot_rwy =    H_pilot_rwy;
898 }
899
900 /* Flight Gear Modification Log
901  *
902  * $Log$
903  * Revision 1.2  1997/05/29 22:39:59  curt
904  * Working on incorporating the LaRCsim flight model.
905  *
906  * Revision 1.1  1997/05/29 00:09:57  curt
907  * Initial Flight Gear revision.
908  *
909  */