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