]> git.mxchange.org Git - flightgear.git/blob - src/FDM/flight.cxx
Fix from Dave to get JSBSim engine startups working again.
[flightgear.git] / src / FDM / flight.cxx
1 // flight.cxx -- a general interface to the various flight models
2 //
3 // Written by Curtis Olson, started May 1997.
4 //
5 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #include <stdio.h>
25
26 #include <simgear/constants.h>
27 #include <simgear/debug/logstream.hxx>
28 #include <simgear/math/sg_geodesy.hxx>
29 #include <simgear/timing/timestamp.hxx>
30
31 #include <Scenery/scenery.hxx>
32 #include <FDM/LaRCsim/ls_interface.h>
33 #include <Main/globals.hxx>
34 #include <Main/fg_props.hxx>
35
36 #include "External.hxx"
37 #include "flight.hxx"
38 #include "JSBSim.hxx"
39 #include "LaRCsim.hxx"
40 #include "Balloon.h"
41
42
43 // base_fdm_state is the internal state that is updated in integer
44 // multiples of "dt".  This leads to "jitter" with respect to the real
45 // world time, so we introduce cur_fdm_state which is extrapolated by
46 // the difference between sim time and real world time
47
48 FGInterface *cur_fdm_state;
49 FGInterface base_fdm_state;
50
51 inline void init_vec(FG_VECTOR_3 vec) {
52     vec[0] = 0.0; vec[1] = 0.0; vec[2] = 0.0;
53 }  
54
55 FGEngInterface::FGEngInterface() {
56     
57     // inputs
58     Throttle=0;
59     Mixture=0;
60     Prop_Advance=0;
61
62     // outputs
63     RPM=0;
64     Manifold_Pressure=0;
65     MaxHP=0;
66     Percentage_Power=0;
67     EGT=0;
68     prop_thrust=0;
69 }
70
71 FGEngInterface::~FGEngInterface(void) {
72 }
73
74
75 // Constructor
76 FGInterface::FGInterface() {
77     _setup();
78 }  
79
80 FGInterface::FGInterface( double dt ) {
81     _setup();
82     delta_t = dt;
83     remainder = elapsed = multi_loop = 0;
84 }
85
86 // Destructor
87 FGInterface::~FGInterface() {
88 //   unbind();                  // FIXME: should be called explicitly
89 }
90
91
92 /**
93  * Set default values for the state of the FDM.
94  *
95  * This method is invoked by the constructors.
96  */
97 void
98 FGInterface::_setup ()
99 {
100     inited = false;
101     bound = false;
102
103     init_vec( d_pilot_rp_body_v );
104     init_vec( d_cg_rp_body_v );
105     init_vec( f_body_total_v );
106     init_vec( f_local_total_v );
107     init_vec( f_aero_v );
108     init_vec( f_engine_v );
109     init_vec( f_gear_v );
110     init_vec( m_total_rp_v );
111     init_vec( m_total_cg_v );
112     init_vec( m_aero_v );
113     init_vec( m_engine_v );
114     init_vec( m_gear_v );
115     init_vec( v_dot_local_v );
116     init_vec( v_dot_body_v );
117     init_vec( a_cg_body_v );
118     init_vec( a_pilot_body_v );
119     init_vec( n_cg_body_v );
120     init_vec( n_pilot_body_v );
121     init_vec( omega_dot_body_v );
122     init_vec( v_local_v );
123     init_vec( v_local_rel_ground_v ); 
124     init_vec( v_local_airmass_v );    
125     init_vec( v_local_rel_airmass_v );  
126     init_vec( v_local_gust_v ); 
127     init_vec( v_wind_body_v );     
128     init_vec( omega_body_v );         
129     init_vec( omega_local_v );        
130     init_vec( omega_total_v );       
131     init_vec( euler_rates_v );
132     init_vec( geocentric_rates_v );   
133     init_vec( geocentric_position_v );
134     init_vec( geodetic_position_v );
135     init_vec( euler_angles_v );
136     init_vec( d_cg_rwy_local_v );     
137     init_vec( d_cg_rwy_rwy_v );       
138     init_vec( d_pilot_rwy_local_v );  
139     init_vec( d_pilot_rwy_rwy_v );    
140     init_vec( t_local_to_body_m[0] );
141     init_vec( t_local_to_body_m[1] );
142     init_vec( t_local_to_body_m[2] );
143     
144     mass=i_xx=i_yy=i_zz=i_xz=0;
145     nlf=0;  
146     v_rel_wind=v_true_kts=v_rel_ground=v_inertial=0;
147     v_ground_speed=v_equiv=v_equiv_kts=0;
148     v_calibrated=v_calibrated_kts=0;
149     gravity=0;            
150     centrifugal_relief=0; 
151     alpha=beta=alpha_dot=beta_dot=0;   
152     cos_alpha=sin_alpha=cos_beta=sin_beta=0;
153     cos_phi=sin_phi=cos_theta=sin_theta=cos_psi=sin_psi=0;
154     gamma_vert_rad=gamma_horiz_rad=0;    
155     sigma=density=v_sound=mach_number=0;
156     static_pressure=total_pressure=impact_pressure=0;
157     dynamic_pressure=0;
158     static_temperature=total_temperature=0;
159     sea_level_radius=earth_position_angle=0;
160     runway_altitude=runway_latitude=runway_longitude=0;
161     runway_heading=0;
162     radius_to_rwy=0;
163     climb_rate=0;           
164     sin_lat_geocentric=cos_lat_geocentric=0;
165     sin_latitude=cos_latitude=0;
166     sin_longitude=cos_longitude=0;
167     altitude_agl=0;
168 }
169
170
171 /**
172  * Initialize the state of the FDM.
173  *
174  * Subclasses of FGInterface may do their own, additional initialization,
175  * but normally they should invoke this method explicitly first as
176  * FGInterface::init() to make sure the basic structures are set up
177  * properly.
178  */
179 void
180 FGInterface::init ()
181 {
182   SG_LOG(SG_FLIGHT, SG_INFO, "Start initializing FGInterface");
183
184   inited = true;
185
186   stamp();
187   set_remainder(0);
188
189                                 // Set initial position
190   SG_LOG(SG_FLIGHT, SG_INFO, "...initializing position...");
191   set_Longitude(fgGetDouble("/position/longitude-deg") * SGD_DEGREES_TO_RADIANS);
192   set_Latitude(fgGetDouble("/position/latitude-deg") * SGD_DEGREES_TO_RADIANS);
193   double ground_elev_m = scenery.get_cur_elev() + 1;
194   double ground_elev_ft = ground_elev_m * METERS_TO_FEET;
195   if (fgGetBool("/sim/startup/onground") ||
196       fgGetDouble("/position/altitude-ft") < ground_elev_ft)
197     fgSetDouble("/position/altitude-ft", ground_elev_ft);
198   set_Altitude(fgGetDouble("/position/altitude-ft"));
199
200                                 // Set ground elevation
201   SG_LOG(SG_FLIGHT, SG_INFO,
202          "...initializing ground elevation to "
203          << ground_elev_ft << "ft...");
204   fgFDMSetGroundElevation("jsb", ground_elev_m);
205
206                                 // Set sea-level radius
207   SG_LOG(SG_FLIGHT, SG_INFO, "...initializing sea-level radius...");
208   SG_LOG(SG_FLIGHT, SG_INFO, " lat = " << fgGetDouble("/position/latitude-deg")
209          << " alt = " << fgGetDouble("/position/altitude-ft") );
210   double sea_level_radius_meters;
211   double lat_geoc;
212   sgGeodToGeoc(fgGetDouble("/position/latitude-deg") * SGD_DEGREES_TO_RADIANS,
213                fgGetDouble("/position/altitude-ft") * SG_FEET_TO_METER,
214                &sea_level_radius_meters, &lat_geoc);
215   set_Sea_level_radius(sea_level_radius_meters * SG_METER_TO_FEET);
216
217                                 // Set initial velocities
218   SG_LOG(SG_FLIGHT, SG_INFO, "...initializing velocities...");
219   if (!fgHasNode("/sim/startup/speed-set")) {
220     set_V_calibrated_kts(0.0);
221   } else {
222     const string speedset = fgGetString("/sim/startup/speed-set");
223     if (speedset == "knots" || speedset == "KNOTS") {
224       set_V_calibrated_kts(fgGetDouble("/velocities/airspeed-kt"));
225     } else if (speedset == "mach" || speedset == "MACH") {
226       set_Mach_number(fgGetDouble("/velocities/mach"));
227     } else if (speedset == "UVW" || speedset == "uvw") {
228       set_Velocities_Wind_Body(fgGetDouble("/velocities/uBody-fps"),
229                                fgGetDouble("/velocities/vBody-fps"),
230                                fgGetDouble("/velocities/wBody-fps"));
231     } else if (speedset == "NED" || speedset == "ned") {
232       set_Velocities_Local(fgGetDouble("/velocities/speed-north-fps"),
233                            fgGetDouble("/velocities/speed-east-fps"),
234                            fgGetDouble("/velocities/speed-down-fps"));
235     } else {
236       SG_LOG(SG_FLIGHT, SG_ALERT,
237              "Unrecognized value for /sim/startup/speed-set: " << speedset);
238       set_V_calibrated_kts(0.0);
239     }
240   }
241
242                                 // Set initial Euler angles
243   SG_LOG(SG_FLIGHT, SG_INFO, "...initializing Euler angles...");
244   set_Euler_Angles
245     (fgGetDouble("/orientation/roll-deg") * SGD_DEGREES_TO_RADIANS,
246      fgGetDouble("/orientation/pitch-deg") * SGD_DEGREES_TO_RADIANS,
247      fgGetDouble("/orientation/heading-deg") * SGD_DEGREES_TO_RADIANS);
248
249   SG_LOG(SG_FLIGHT, SG_INFO, "End initializing FGInterface");
250 }
251
252
253 /**
254  * Bind getters and setters to properties.
255  *
256  * The bind() method will be invoked after init().  Note that unlike
257  * the usual implementations of FGSubsystem::bind(), this method does
258  * not automatically pick up existing values for the properties at
259  * bind time; instead, all values are set explicitly in the init()
260  * method.
261  */
262 void
263 FGInterface::bind ()
264 {
265   bound = true;
266
267                                 // Time management (read-only)
268   fgTie("/fdm/time/delta_t", this, 
269         &FGInterface::get_delta_t); // read-only
270   fgTie("/fdm/time/elapsed", this, 
271         &FGInterface::get_elapsed); // read-only
272   fgTie("/fdm/time/remainder", this, 
273         &FGInterface::get_remainder); // read-only
274   fgTie("/fdm/time/multi_loop", this, 
275         &FGInterface::get_multi_loop); // read-only
276
277                         // Aircraft position
278   fgTie("/position/latitude-deg", this,
279         &FGInterface::get_Latitude_deg,
280         &FGInterface::set_Latitude_deg,
281         false);
282   fgSetArchivable("/position/latitude-deg");
283   fgTie("/position/longitude-deg", this,
284         &FGInterface::get_Longitude_deg,
285         &FGInterface::set_Longitude_deg,
286         false);
287   fgSetArchivable("/position/longitude-deg");
288   fgTie("/position/altitude-ft", this,
289         &FGInterface::get_Altitude,
290         &FGInterface::set_Altitude,
291         false);
292   fgSetArchivable("/position/altitude-ft");
293   fgTie("/position/altitude-agl-ft", this,
294         &FGInterface::get_Altitude_AGL); // read-only
295
296                                 // Orientation
297   fgTie("/orientation/roll-deg", this,
298         &FGInterface::get_Phi_deg,
299         &FGInterface::set_Phi_deg);
300   fgSetArchivable("/orientation/roll-deg");
301   fgTie("/orientation/pitch-deg", this,
302         &FGInterface::get_Theta_deg,
303         &FGInterface::set_Theta_deg);
304   fgSetArchivable("/orientation/pitch-deg");
305   fgTie("/orientation/heading-deg", this,
306         &FGInterface::get_Psi_deg,
307         &FGInterface::set_Psi_deg);
308   fgSetArchivable("/orientation/heading-deg");
309
310                                 // Calibrated airspeed
311   fgTie("/velocities/airspeed-kt", this,
312         &FGInterface::get_V_calibrated_kts,
313         &FGInterface::set_V_calibrated_kts,
314         false);
315
316                                 // Local velocities
317 //   fgTie("/velocities/speed-north-fps", this,
318 //      &FGInterface::get_V_north,
319 //      &FGInterface::set_V_north);
320 //   fgSetArchivable("/velocities/speed-north-fps");
321 //   fgTie("/velocities/speed-east-fps", this,
322 //      &FGInterface::get_V_east,
323 //      &FGInterface::set_V_east);
324 //   fgSetArchivable("/velocities/speed-east-fps");
325 //   fgTie("/velocities/speed-down-fps", this,
326 //      &FGInterface::get_V_down,
327 //      &FGInterface::set_V_down);
328 //   fgSetArchivable("/velocities/speed-down-fps");
329                                 // FIXME: Temporarily read-only, until the
330                                 // incompatibilities between JSBSim and
331                                 // LaRCSim are fixed (LaRCSim adds the
332                                 // earth's rotation to the east velocity).
333   fgTie("/velocities/speed-north-fps", this,
334         &FGInterface::get_V_north);
335   fgTie("/velocities/speed-east-fps", this,
336         &FGInterface::get_V_east);
337   fgTie("/velocities/speed-down-fps", this,
338         &FGInterface::get_V_down);
339
340                                 // Relative wind
341                                 // FIXME: temporarily archivable, until
342                                 // the NED problem is fixed.
343   fgTie("/velocities/uBody-fps", this,
344         &FGInterface::get_uBody,
345         &FGInterface::set_uBody,
346         false);
347   fgSetArchivable("/velocities/uBody-fps");
348   fgTie("/velocities/vBody-fps", this,
349         &FGInterface::get_vBody,
350         &FGInterface::set_vBody,
351         false);
352   fgSetArchivable("/velocities/vBody-fps");
353   fgTie("/velocities/wBody-fps", this,
354         &FGInterface::get_wBody,
355         &FGInterface::set_wBody,
356         false);
357   fgSetArchivable("/velocities/wBody-fps");
358
359                                 // Climb and slip (read-only)
360   fgTie("/velocities/vertical-speed-fps", this,
361         &FGInterface::get_Climb_Rate); // read-only
362   fgTie("/velocities/side-slip-rad", this,
363         &FGInterface::get_Beta); // read-only
364 }
365
366
367 /**
368  * Unbind any properties bound to this FDM.
369  *
370  * This method allows the FDM to release properties so that a new
371  * FDM can bind them instead.
372  */
373 void
374 FGInterface::unbind ()
375 {
376   bound = false;
377
378   fgUntie("/fdm/time/delta_t");
379   fgUntie("/fdm/time/elapsed");
380   fgUntie("/fdm/time/remainder");
381   fgUntie("/fdm/time/multi_loop");
382   fgUntie("/position/latitude-deg");
383   fgUntie("/position/longitude-deg");
384   fgUntie("/position/altitude-ft");
385   fgUntie("/position/altitude-agl-ft");
386   fgUntie("/orientation/heading-deg");
387   fgUntie("/orientation/pitch-deg");
388   fgUntie("/orientation/roll-deg");
389   fgUntie("/velocities/airspeed-kt");
390   fgUntie("/velocities/speed-north-fps");
391   fgUntie("/velocities/speed-east-fps");
392   fgUntie("/velocities/speed-down-fps");
393   fgUntie("/velocities/uBody-fps");
394   fgUntie("/velocities/vBody-fps");
395   fgUntie("/velocities/wBody-fps");
396   fgUntie("/velocities/vertical-speed-fps");
397   fgUntie("/velocities/side-slip-rad");
398 }
399
400
401 /**
402  * Update the state of the FDM (i.e. run the equations of motion).
403  */
404 void
405 FGInterface::update ()
406 {
407   update(1);
408 }
409
410
411 bool FGInterface::update( int multi_loop ) {
412     cout << "dummy update() ... SHOULDN'T BE CALLED!" << endl;
413     return false;
414 }
415
416   
417 void FGInterface::_updatePosition( double lat_geoc, double lon, double alt ) {
418     double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc;
419         
420     // cout << "starting sea level rad = " << get_Sea_level_radius() << endl;
421
422     sgGeocToGeod( lat_geoc, ( get_Sea_level_radius() + alt ) * SG_FEET_TO_METER,
423                   &lat_geod, &tmp_alt, &sl_radius1 );
424     sgGeodToGeoc( lat_geod, alt * SG_FEET_TO_METER, &sl_radius2, &tmp_lat_geoc );
425
426     SG_LOG( SG_FLIGHT, SG_DEBUG, "lon = " << lon 
427             << " lat_geod = " << lat_geod
428             << " lat_geoc = " << lat_geoc
429             << " alt = " << alt 
430             << " tmp_alt = " << tmp_alt * SG_METER_TO_FEET
431             << " sl_radius1 = " << sl_radius1 * SG_METER_TO_FEET
432             << " sl_radius2 = " << sl_radius2 * SG_METER_TO_FEET
433             << " Equator = " << SG_EQUATORIAL_RADIUS_FT );
434
435     _set_Geocentric_Position( lat_geoc, lon, 
436                               sl_radius2 * SG_METER_TO_FEET + alt );
437         
438     _set_Geodetic_Position( lat_geod, lon, alt );
439         
440     _set_Sea_level_radius( sl_radius2 * SG_METER_TO_FEET );
441     _set_Runway_altitude( scenery.get_cur_elev()*METERS_TO_FEET ); 
442         
443     _set_sin_lat_geocentric( lat_geoc );
444     _set_cos_lat_geocentric( lat_geoc );
445         
446     _set_sin_cos_longitude( lon );
447         
448     _set_sin_cos_latitude( lat_geod );
449         
450     /* Norman's code for slope of the terrain */
451     /* needs to be tested -- get it on the HUD and taxi around */
452     /* double *tnorm = scenery.cur_normal;
453         
454        double sy = sin ( -get_Psi() ) ;
455        double cy = cos ( -get_Psi() ) ;
456
457        double phitb, thetatb, psitb;
458        if(tnorm[1] != 0.0) {
459                 psitb = -atan2 ( tnorm[0], tnorm[1] );
460        }
461        if(tnorm[2] != 0.0) {    
462                 thetatb =  atan2 ( tnorm[0] * cy - tnorm[1] * sy, tnorm[2] );
463                 phitb = -atan2 ( tnorm[1] * cy + tnorm[0] * sy, tnorm[2] );  
464        }        
465         
466        _set_terrain_slope(phitb, thetatb, psitb) 
467      */
468 }
469
470
471 // Extrapolate fdm based on time_offset (in usec)
472 void FGInterface::extrapolate( int time_offset ) {
473     double dt = time_offset / 1000000.0;
474
475     // -dw- metrowerks complains about ambiguous access, not critical
476     // to keep this ;)
477 #ifndef __MWERKS__
478     cout << "extrapolating FDM by dt = " << dt << endl;
479 #endif
480
481     double lat = geodetic_position_v[0] + geocentric_rates_v[0] * dt;
482     double lat_geoc = geocentric_position_v[0] + geocentric_rates_v[0] * dt;
483
484     double lon = geodetic_position_v[1] + geocentric_rates_v[1] * dt;
485     double lon_geoc = geocentric_position_v[1] + geocentric_rates_v[1] * dt;
486
487     double alt = geodetic_position_v[2] + geocentric_rates_v[2] * dt;
488     double radius = geocentric_position_v[2] + geocentric_rates_v[2] * dt;
489
490     geodetic_position_v[0] = lat;
491     geocentric_position_v[0] = lat_geoc;
492
493     geodetic_position_v[1] = lon;
494     geocentric_position_v[1] = lon_geoc;
495
496     geodetic_position_v[2] = alt;
497     geocentric_position_v[2] = radius;
498 }
499
500
501 // Set the altitude (force)
502 void fgFDMForceAltitude(const string &model, double alt_meters) {
503     SG_LOG(SG_FLIGHT,SG_INFO, "fgFDMForceAltitude: " << alt_meters );
504     
505     double sea_level_radius_meters;
506     double lat_geoc;
507
508     // Set the FG variables first
509     sgGeodToGeoc( base_fdm_state.get_Latitude(), alt_meters, 
510                   &sea_level_radius_meters, &lat_geoc);
511
512     base_fdm_state.set_Altitude( alt_meters * SG_METER_TO_FEET );
513     base_fdm_state.set_Sea_level_radius( sea_level_radius_meters *
514                                          SG_METER_TO_FEET ); 
515                 
516     cur_fdm_state->set_Altitude( alt_meters * SG_METER_TO_FEET );
517     cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters * 
518            SG_METER_TO_FEET );                    
519
520     // additional work needed for some flight models
521     if ( model == "larcsim" ) {
522         ls_ForceAltitude( base_fdm_state.get_Altitude() );
523     }
524 }
525
526
527 // Set the local ground elevation
528 void fgFDMSetGroundElevation(const string &model, double ground_meters) {
529     SG_LOG( SG_FLIGHT,SG_INFO, "fgFDMSetGroundElevation: "
530             << ground_meters*SG_METER_TO_FEET ); 
531     base_fdm_state.set_Runway_altitude( ground_meters * SG_METER_TO_FEET );
532     cur_fdm_state->set_Runway_altitude( ground_meters * SG_METER_TO_FEET );
533 }
534
535
536 // Positions
537 void FGInterface::set_Latitude(double lat) { 
538     geodetic_position_v[0] = lat;
539 }  
540
541 void FGInterface::set_Longitude(double lon) {
542     geodetic_position_v[1] = lon;
543 }       
544
545 void FGInterface::set_Altitude(double alt) {
546     geodetic_position_v[2] = alt;
547 }          
548
549 void FGInterface::set_AltitudeAGL(double altagl) {
550     altitude_agl=altagl;
551 }  
552
553 // Velocities
554 void FGInterface::set_V_calibrated_kts(double vc) {
555     v_calibrated_kts = vc;
556 }  
557
558 void FGInterface::set_Mach_number(double mach) {
559     mach_number = mach;
560 }  
561
562 void FGInterface::set_Velocities_Local( double north, 
563                                         double east, 
564                                         double down ){
565     v_local_v[0] = north;
566     v_local_v[1] = east;
567     v_local_v[2] = down;                                                 
568 }  
569
570 void FGInterface::set_Velocities_Wind_Body( double u, 
571                                             double v, 
572                                             double w){
573     v_wind_body_v[0] = u;
574     v_wind_body_v[1] = v;
575     v_wind_body_v[2] = w;
576
577
578 // Euler angles 
579 void FGInterface::set_Euler_Angles( double phi, 
580                                     double theta, 
581                                     double psi ) {
582     euler_angles_v[0] = phi;
583     euler_angles_v[1] = theta;
584     euler_angles_v[2] = psi;                                            
585 }  
586
587 // Flight Path
588 void FGInterface::set_Climb_Rate( double roc) {
589     climb_rate = roc;
590 }  
591
592 void FGInterface::set_Gamma_vert_rad( double gamma) {
593     gamma_vert_rad = gamma;
594 }  
595
596 // Earth
597 void FGInterface::set_Sea_level_radius(double slr) {
598     sea_level_radius = slr;
599 }  
600
601 void FGInterface::set_Runway_altitude(double ralt) {
602     runway_altitude = ralt;
603 }  
604
605 void FGInterface::set_Static_pressure(double p) { static_pressure = p; }
606 void FGInterface::set_Static_temperature(double T) { static_temperature = T; }
607 void FGInterface::set_Density(double rho) { density = rho; }
608
609 void FGInterface::set_Velocities_Local_Airmass (double wnorth, 
610                                                 double weast, 
611                                                 double wdown ) {
612     v_local_airmass_v[0] = wnorth;
613     v_local_airmass_v[1] = weast;
614     v_local_airmass_v[2] = wdown;
615 }     
616
617
618 void FGInterface::_busdump(void) {
619
620     SG_LOG(SG_FLIGHT,SG_INFO,"d_pilot_rp_body_v[3]: " << d_pilot_rp_body_v[0] << ", " << d_pilot_rp_body_v[1] << ", " << d_pilot_rp_body_v[2]);
621     SG_LOG(SG_FLIGHT,SG_INFO,"d_cg_rp_body_v[3]: " << d_cg_rp_body_v[0] << ", " << d_cg_rp_body_v[1] << ", " << d_cg_rp_body_v[2]);
622     SG_LOG(SG_FLIGHT,SG_INFO,"f_body_total_v[3]: " << f_body_total_v[0] << ", " << f_body_total_v[1] << ", " << f_body_total_v[2]);
623     SG_LOG(SG_FLIGHT,SG_INFO,"f_local_total_v[3]: " << f_local_total_v[0] << ", " << f_local_total_v[1] << ", " << f_local_total_v[2]);
624     SG_LOG(SG_FLIGHT,SG_INFO,"f_aero_v[3]: " << f_aero_v[0] << ", " << f_aero_v[1] << ", " << f_aero_v[2]);
625     SG_LOG(SG_FLIGHT,SG_INFO,"f_engine_v[3]: " << f_engine_v[0] << ", " << f_engine_v[1] << ", " << f_engine_v[2]);
626     SG_LOG(SG_FLIGHT,SG_INFO,"f_gear_v[3]: " << f_gear_v[0] << ", " << f_gear_v[1] << ", " << f_gear_v[2]);
627     SG_LOG(SG_FLIGHT,SG_INFO,"m_total_rp_v[3]: " << m_total_rp_v[0] << ", " << m_total_rp_v[1] << ", " << m_total_rp_v[2]);
628     SG_LOG(SG_FLIGHT,SG_INFO,"m_total_cg_v[3]: " << m_total_cg_v[0] << ", " << m_total_cg_v[1] << ", " << m_total_cg_v[2]);
629     SG_LOG(SG_FLIGHT,SG_INFO,"m_aero_v[3]: " << m_aero_v[0] << ", " << m_aero_v[1] << ", " << m_aero_v[2]);
630     SG_LOG(SG_FLIGHT,SG_INFO,"m_engine_v[3]: " << m_engine_v[0] << ", " << m_engine_v[1] << ", " << m_engine_v[2]);
631     SG_LOG(SG_FLIGHT,SG_INFO,"m_gear_v[3]: " << m_gear_v[0] << ", " << m_gear_v[1] << ", " << m_gear_v[2]);
632     SG_LOG(SG_FLIGHT,SG_INFO,"v_dot_local_v[3]: " << v_dot_local_v[0] << ", " << v_dot_local_v[1] << ", " << v_dot_local_v[2]);
633     SG_LOG(SG_FLIGHT,SG_INFO,"v_dot_body_v[3]: " << v_dot_body_v[0] << ", " << v_dot_body_v[1] << ", " << v_dot_body_v[2]);
634     SG_LOG(SG_FLIGHT,SG_INFO,"a_cg_body_v[3]: " << a_cg_body_v[0] << ", " << a_cg_body_v[1] << ", " << a_cg_body_v[2]);
635     SG_LOG(SG_FLIGHT,SG_INFO,"a_pilot_body_v[3]: " << a_pilot_body_v[0] << ", " << a_pilot_body_v[1] << ", " << a_pilot_body_v[2]);
636     SG_LOG(SG_FLIGHT,SG_INFO,"n_cg_body_v[3]: " << n_cg_body_v[0] << ", " << n_cg_body_v[1] << ", " << n_cg_body_v[2]);
637     SG_LOG(SG_FLIGHT,SG_INFO,"n_pilot_body_v[3]: " << n_pilot_body_v[0] << ", " << n_pilot_body_v[1] << ", " << n_pilot_body_v[2]);
638     SG_LOG(SG_FLIGHT,SG_INFO,"omega_dot_body_v[3]: " << omega_dot_body_v[0] << ", " << omega_dot_body_v[1] << ", " << omega_dot_body_v[2]);
639     SG_LOG(SG_FLIGHT,SG_INFO,"v_local_v[3]: " << v_local_v[0] << ", " << v_local_v[1] << ", " << v_local_v[2]);
640     SG_LOG(SG_FLIGHT,SG_INFO,"v_local_rel_ground_v[3]: " << v_local_rel_ground_v[0] << ", " << v_local_rel_ground_v[1] << ", " << v_local_rel_ground_v[2]);
641     SG_LOG(SG_FLIGHT,SG_INFO,"v_local_airmass_v[3]: " << v_local_airmass_v[0] << ", " << v_local_airmass_v[1] << ", " << v_local_airmass_v[2]);
642     SG_LOG(SG_FLIGHT,SG_INFO,"v_local_rel_airmass_v[3]: " << v_local_rel_airmass_v[0] << ", " << v_local_rel_airmass_v[1] << ", " << v_local_rel_airmass_v[2]);
643     SG_LOG(SG_FLIGHT,SG_INFO,"v_local_gust_v[3]: " << v_local_gust_v[0] << ", " << v_local_gust_v[1] << ", " << v_local_gust_v[2]);
644     SG_LOG(SG_FLIGHT,SG_INFO,"v_wind_body_v[3]: " << v_wind_body_v[0] << ", " << v_wind_body_v[1] << ", " << v_wind_body_v[2]);
645     SG_LOG(SG_FLIGHT,SG_INFO,"omega_body_v[3]: " << omega_body_v[0] << ", " << omega_body_v[1] << ", " << omega_body_v[2]);
646     SG_LOG(SG_FLIGHT,SG_INFO,"omega_local_v[3]: " << omega_local_v[0] << ", " << omega_local_v[1] << ", " << omega_local_v[2]);
647     SG_LOG(SG_FLIGHT,SG_INFO,"omega_total_v[3]: " << omega_total_v[0] << ", " << omega_total_v[1] << ", " << omega_total_v[2]);
648     SG_LOG(SG_FLIGHT,SG_INFO,"euler_rates_v[3]: " << euler_rates_v[0] << ", " << euler_rates_v[1] << ", " << euler_rates_v[2]);
649     SG_LOG(SG_FLIGHT,SG_INFO,"geocentric_rates_v[3]: " << geocentric_rates_v[0] << ", " << geocentric_rates_v[1] << ", " << geocentric_rates_v[2]);
650     SG_LOG(SG_FLIGHT,SG_INFO,"geocentric_position_v[3]: " << geocentric_position_v[0] << ", " << geocentric_position_v[1] << ", " << geocentric_position_v[2]);
651     SG_LOG(SG_FLIGHT,SG_INFO,"geodetic_position_v[3]: " << geodetic_position_v[0] << ", " << geodetic_position_v[1] << ", " << geodetic_position_v[2]);
652     SG_LOG(SG_FLIGHT,SG_INFO,"euler_angles_v[3]: " << euler_angles_v[0] << ", " << euler_angles_v[1] << ", " << euler_angles_v[2]);
653     SG_LOG(SG_FLIGHT,SG_INFO,"d_cg_rwy_local_v[3]: " << d_cg_rwy_local_v[0] << ", " << d_cg_rwy_local_v[1] << ", " << d_cg_rwy_local_v[2]);
654     SG_LOG(SG_FLIGHT,SG_INFO,"d_cg_rwy_rwy_v[3]: " << d_cg_rwy_rwy_v[0] << ", " << d_cg_rwy_rwy_v[1] << ", " << d_cg_rwy_rwy_v[2]);
655     SG_LOG(SG_FLIGHT,SG_INFO,"d_pilot_rwy_local_v[3]: " << d_pilot_rwy_local_v[0] << ", " << d_pilot_rwy_local_v[1] << ", " << d_pilot_rwy_local_v[2]);
656     SG_LOG(SG_FLIGHT,SG_INFO,"d_pilot_rwy_rwy_v[3]: " << d_pilot_rwy_rwy_v[0] << ", " << d_pilot_rwy_rwy_v[1] << ", " << d_pilot_rwy_rwy_v[2]);
657   
658     SG_LOG(SG_FLIGHT,SG_INFO,"t_local_to_body_m[0][3]: " << t_local_to_body_m[0][0] << ", " << t_local_to_body_m[0][1] << ", " << t_local_to_body_m[0][2]);
659     SG_LOG(SG_FLIGHT,SG_INFO,"t_local_to_body_m[1][3]: " << t_local_to_body_m[1][0] << ", " << t_local_to_body_m[1][1] << ", " << t_local_to_body_m[1][2]);
660     SG_LOG(SG_FLIGHT,SG_INFO,"t_local_to_body_m[2][3]: " << t_local_to_body_m[2][0] << ", " << t_local_to_body_m[2][1] << ", " << t_local_to_body_m[2][2]);
661
662     SG_LOG(SG_FLIGHT,SG_INFO,"mass: " << mass );
663     SG_LOG(SG_FLIGHT,SG_INFO,"i_xx: " << i_xx );
664     SG_LOG(SG_FLIGHT,SG_INFO,"i_yy: " << i_yy );
665     SG_LOG(SG_FLIGHT,SG_INFO,"i_zz: " << i_zz );
666     SG_LOG(SG_FLIGHT,SG_INFO,"i_xz: " << i_xz );
667     SG_LOG(SG_FLIGHT,SG_INFO,"nlf: " << nlf );
668     SG_LOG(SG_FLIGHT,SG_INFO,"v_rel_wind: " << v_rel_wind );
669     SG_LOG(SG_FLIGHT,SG_INFO,"v_true_kts: " << v_true_kts );
670     SG_LOG(SG_FLIGHT,SG_INFO,"v_rel_ground: " << v_rel_ground );
671     SG_LOG(SG_FLIGHT,SG_INFO,"v_inertial: " << v_inertial );
672     SG_LOG(SG_FLIGHT,SG_INFO,"v_ground_speed: " << v_ground_speed );
673     SG_LOG(SG_FLIGHT,SG_INFO,"v_equiv: " << v_equiv );
674     SG_LOG(SG_FLIGHT,SG_INFO,"v_equiv_kts: " << v_equiv_kts );
675     SG_LOG(SG_FLIGHT,SG_INFO,"v_calibrated: " << v_calibrated );
676     SG_LOG(SG_FLIGHT,SG_INFO,"v_calibrated_kts: " << v_calibrated_kts );
677     SG_LOG(SG_FLIGHT,SG_INFO,"gravity: " << gravity );
678     SG_LOG(SG_FLIGHT,SG_INFO,"centrifugal_relief: " << centrifugal_relief );
679     SG_LOG(SG_FLIGHT,SG_INFO,"alpha: " << alpha );
680     SG_LOG(SG_FLIGHT,SG_INFO,"beta: " << beta );
681     SG_LOG(SG_FLIGHT,SG_INFO,"alpha_dot: " << alpha_dot );
682     SG_LOG(SG_FLIGHT,SG_INFO,"beta_dot: " << beta_dot );
683     SG_LOG(SG_FLIGHT,SG_INFO,"cos_alpha: " << cos_alpha );
684     SG_LOG(SG_FLIGHT,SG_INFO,"sin_alpha: " << sin_alpha );
685     SG_LOG(SG_FLIGHT,SG_INFO,"cos_beta: " << cos_beta );
686     SG_LOG(SG_FLIGHT,SG_INFO,"sin_beta: " << sin_beta );
687     SG_LOG(SG_FLIGHT,SG_INFO,"cos_phi: " << cos_phi );
688     SG_LOG(SG_FLIGHT,SG_INFO,"sin_phi: " << sin_phi );
689     SG_LOG(SG_FLIGHT,SG_INFO,"cos_theta: " << cos_theta );
690     SG_LOG(SG_FLIGHT,SG_INFO,"sin_theta: " << sin_theta );
691     SG_LOG(SG_FLIGHT,SG_INFO,"cos_psi: " << cos_psi );
692     SG_LOG(SG_FLIGHT,SG_INFO,"sin_psi: " << sin_psi );
693     SG_LOG(SG_FLIGHT,SG_INFO,"gamma_vert_rad: " << gamma_vert_rad );
694     SG_LOG(SG_FLIGHT,SG_INFO,"gamma_horiz_rad: " << gamma_horiz_rad );
695     SG_LOG(SG_FLIGHT,SG_INFO,"sigma: " << sigma );
696     SG_LOG(SG_FLIGHT,SG_INFO,"density: " << density );
697     SG_LOG(SG_FLIGHT,SG_INFO,"v_sound: " << v_sound );
698     SG_LOG(SG_FLIGHT,SG_INFO,"mach_number: " << mach_number );
699     SG_LOG(SG_FLIGHT,SG_INFO,"static_pressure: " << static_pressure );
700     SG_LOG(SG_FLIGHT,SG_INFO,"total_pressure: " << total_pressure );
701     SG_LOG(SG_FLIGHT,SG_INFO,"impact_pressure: " << impact_pressure );
702     SG_LOG(SG_FLIGHT,SG_INFO,"dynamic_pressure: " << dynamic_pressure );
703     SG_LOG(SG_FLIGHT,SG_INFO,"static_temperature: " << static_temperature );
704     SG_LOG(SG_FLIGHT,SG_INFO,"total_temperature: " << total_temperature );
705     SG_LOG(SG_FLIGHT,SG_INFO,"sea_level_radius: " << sea_level_radius );
706     SG_LOG(SG_FLIGHT,SG_INFO,"earth_position_angle: " << earth_position_angle );
707     SG_LOG(SG_FLIGHT,SG_INFO,"runway_altitude: " << runway_altitude );
708     SG_LOG(SG_FLIGHT,SG_INFO,"runway_latitude: " << runway_latitude );
709     SG_LOG(SG_FLIGHT,SG_INFO,"runway_longitude: " << runway_longitude );
710     SG_LOG(SG_FLIGHT,SG_INFO,"runway_heading: " << runway_heading );
711     SG_LOG(SG_FLIGHT,SG_INFO,"radius_to_rwy: " << radius_to_rwy );
712     SG_LOG(SG_FLIGHT,SG_INFO,"climb_rate: " << climb_rate );
713     SG_LOG(SG_FLIGHT,SG_INFO,"sin_lat_geocentric: " << sin_lat_geocentric );
714     SG_LOG(SG_FLIGHT,SG_INFO,"cos_lat_geocentric: " << cos_lat_geocentric );
715     SG_LOG(SG_FLIGHT,SG_INFO,"sin_longitude: " << sin_longitude );
716     SG_LOG(SG_FLIGHT,SG_INFO,"cos_longitude: " << cos_longitude );
717     SG_LOG(SG_FLIGHT,SG_INFO,"sin_latitude: " << sin_latitude );
718     SG_LOG(SG_FLIGHT,SG_INFO,"cos_latitude: " << cos_latitude );
719     SG_LOG(SG_FLIGHT,SG_INFO,"altitude_agl: " << altitude_agl );
720 }  
721
722
723 void fgToggleFDMdataLogging(void) {
724   cur_fdm_state->ToggleDataLogging();
725 }
726