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