1 // fg_init.cxx -- Flight Gear top level initialization routines
3 // Written by Curtis Olson, started August 1997.
5 // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
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.
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.
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.
29 // For BC 5.01 this must be included before OpenGL includes.
30 #ifdef SG_MATH_EXCEPTION_CLASH
35 #include <simgear/xgl/xgl.h>
41 #if defined( unix ) || defined( __CYGWIN__ )
42 # include <unistd.h> // for gethostname()
45 // work around a stdc++ lib bug in some versions of linux, but doesn't
46 // seem to hurt to have this here for all versions of Linux.
48 # define _G_NO_EXTERN_TEMPLATES
51 #include <simgear/compiler.h>
55 #include <simgear/constants.h>
56 #include <simgear/debug/logstream.hxx>
57 #include <simgear/math/point3d.hxx>
58 #include <simgear/math/polar3d.hxx>
59 #include <simgear/math/sg_geodesy.hxx>
60 #include <simgear/misc/sg_path.hxx>
61 #include <simgear/timing/sg_time.hxx>
63 #include <Aircraft/aircraft.hxx>
64 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
65 #include <Airports/runways.hxx>
66 #include <Airports/simple.hxx>
67 #include <Autopilot/auto_gui.hxx>
68 #include <Autopilot/newauto.hxx>
69 #include <Cockpit/cockpit.hxx>
70 #include <Cockpit/radiostack.hxx>
71 #include <Cockpit/panel.hxx>
72 #include <Cockpit/panel_io.hxx>
73 #include <FDM/ADA.hxx>
74 #include <FDM/Balloon.h>
75 #include <FDM/External.hxx>
76 #include <FDM/JSBSim.hxx>
77 #include <FDM/LaRCsim.hxx>
78 #include <FDM/MagicCarpet.hxx>
79 #include <Include/general.hxx>
80 #include <Joystick/joystick.hxx>
81 #include <Objects/matlib.hxx>
82 #include <Navaids/fixlist.hxx>
83 #include <Navaids/ilslist.hxx>
84 #include <Navaids/mkrbeacons.hxx>
85 #include <Navaids/navlist.hxx>
86 #include <Scenery/scenery.hxx>
87 #include <Scenery/tilemgr.hxx>
88 #include <Time/event.hxx>
89 #include <Time/light.hxx>
90 #include <Time/sunpos.hxx>
91 #include <Time/moonpos.hxx>
92 #include <Time/tmp.hxx>
94 #ifndef FG_OLD_WEATHER
95 # include <WeatherCM/FGLocalWeatherDatabase.h>
97 # include <Weather/weather.hxx>
100 #include "fg_init.hxx"
102 #include "options.hxx"
103 #include "globals.hxx"
106 #if defined(FX) && defined(XMESA)
107 #include <GL/xmesa.h>
110 SG_USING_STD(string);
112 extern const char *default_root;
115 // Read in configuration (file and command line) and just set fg_root
116 bool fgInitFGRoot ( int argc, char **argv ) {
120 // First parse command line options looking for fg-root, this will
121 // override anything specified in a config file
122 root = fgScanForRoot(argc, argv);
124 #if defined( unix ) || defined( __CYGWIN__ )
125 // Next check home directory for .fgfsrc.hostname file
127 envp = ::getenv( "HOME" );
128 if ( envp != NULL ) {
129 SGPath config( envp );
130 config.append( ".fgfsrc" );
132 gethostname( name, 256 );
133 config.concat( "." );
134 config.concat( name );
135 root = fgScanForRoot(config.str());
140 // Next check home directory for .fgfsrc file
142 envp = ::getenv( "HOME" );
143 if ( envp != NULL ) {
144 SGPath config( envp );
145 config.append( ".fgfsrc" );
146 root = fgScanForRoot(config.str());
150 // Next check if fg-root is set as an env variable
152 envp = ::getenv( "FG_ROOT" );
153 if ( envp != NULL ) {
158 // Otherwise, default to a random compiled-in location if we can't
159 // find fg-root any other way.
162 root = "\\FlightGear";
163 #elif defined( macintosh )
170 SG_LOG(SG_INPUT, SG_INFO, "fg_root = " << root );
171 globals->set_fg_root(root);
177 // Read in configuration (file and command line)
178 bool fgInitConfig ( int argc, char **argv ) {
180 // First, set some sane default values
183 // Read global preferences from $FG_ROOT/preferences.xml
184 SGPath props_path(globals->get_fg_root());
185 props_path.append("preferences.xml");
186 SG_LOG(SG_INPUT, SG_INFO, "Reading global preferences");
187 if (!readProperties(props_path.str(), globals->get_props())) {
188 SG_LOG(SG_INPUT, SG_ALERT, "Failed to read global preferences from "
189 << props_path.str());
191 SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences");
194 // Attempt to locate and parse the various config files in order
195 // from least precidence to greatest precidence
197 // Check for $fg_root/system.fgfsrc
198 SGPath config( globals->get_fg_root() );
199 config.append( "system.fgfsrc" );
200 fgParseOptions(config.str());
203 #if defined( unix ) || defined( __CYGWIN__ )
204 // Check for $fg_root/system.fgfsrc.hostname
205 gethostname( name, 256 );
206 config.concat( "." );
207 config.concat( name );
208 fgParseOptions(config.str());
211 // Check for ~/.fgfsrc
212 char* envp = ::getenv( "HOME" );
213 if ( envp != NULL ) {
215 config.append( ".fgfsrc" );
216 fgParseOptions(config.str());
219 #if defined( unix ) || defined( __CYGWIN__ )
220 // Check for ~/.fgfsrc.hostname
221 gethostname( name, 256 );
222 config.concat( "." );
223 config.concat( name );
224 fgParseOptions(config.str());
227 // Parse remaining command line options
228 // These will override anything specified in a config file
229 fgParseOptions(argc, argv);
235 // find basic airport location info from airport database
236 bool fgFindAirportID( const string& id, FGAirport *a ) {
238 SGPath path( globals->get_fg_root() );
239 path.append( "Airports" );
240 path.append( "simple.mk4" );
241 FGAirports airports( path.c_str() );
243 SG_LOG( SG_GENERAL, SG_INFO, "Searching for airport code = " << id );
245 if ( ! airports.search( id, a ) ) {
246 SG_LOG( SG_GENERAL, SG_ALERT,
247 "Failed to find " << id << " in " << path.str() );
254 SG_LOG( SG_GENERAL, SG_INFO,
255 "Position for " << id << " is ("
256 << a->longitude << ", "
257 << a->latitude << ")" );
263 // Set current_options lon/lat given an airport id
264 bool fgSetPosFromAirportID( const string& id ) {
268 SG_LOG( SG_GENERAL, SG_INFO,
269 "Attempting to set starting position from airport code " << id );
271 if ( fgFindAirportID( id, &a ) ) {
272 fgSetDouble("/position/longitude", a.longitude );
273 fgSetDouble("/position/latitude", a.latitude );
274 SG_LOG( SG_GENERAL, SG_INFO,
275 "Position for " << id << " is ("
276 << a.longitude << ", "
277 << a.latitude << ")" );
287 // Set current_options lon/lat given an airport id and heading (degrees)
288 bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) {
291 double found_dir = 0.0;
294 // set initial position from runway and heading
296 SGPath path( globals->get_fg_root() );
297 path.append( "Airports" );
298 path.append( "runways.mk4" );
299 FGRunways runways( path.c_str() );
301 SG_LOG( SG_GENERAL, SG_INFO,
302 "Attempting to set starting position from runway code "
303 << id << " heading " << tgt_hdg );
305 // SGPath inpath( globals->get_fg_root() );
306 // inpath.append( "Airports" );
307 // inpath.append( "apt_simple" );
308 // airports.load( inpath.c_str() );
310 // SGPath outpath( globals->get_fg_root() );
311 // outpath.append( "Airports" );
312 // outpath.append( "simple.gdbm" );
313 // airports.dump_gdbm( outpath.c_str() );
315 if ( ! runways.search( id, &r ) ) {
316 SG_LOG( SG_GENERAL, SG_ALERT,
317 "Failed to find " << id << " in database." );
322 double min_diff = 360.0;
324 while ( r.id == id ) {
326 diff = tgt_hdg - r.heading;
327 while ( diff < -180.0 ) { diff += 360.0; }
328 while ( diff > 180.0 ) { diff -= 360.0; }
330 SG_LOG( SG_GENERAL, SG_INFO,
331 "Runway " << r.rwy_no << " heading = " << r.heading <<
332 " diff = " << diff );
333 if ( diff < min_diff ) {
340 diff = tgt_hdg - r.heading - 180.0;
341 while ( diff < -180.0 ) { diff += 360.0; }
342 while ( diff > 180.0 ) { diff -= 360.0; }
344 SG_LOG( SG_GENERAL, SG_INFO,
345 "Runway -" << r.rwy_no << " heading = " <<
347 " diff = " << diff );
348 if ( diff < min_diff ) {
357 SG_LOG( SG_GENERAL, SG_INFO, "closest runway = " << found_r.rwy_no
358 << " + " << found_dir );
364 double heading = found_r.heading + found_dir;
365 while ( heading >= 360.0 ) { heading -= 360.0; }
367 double lat2, lon2, az2;
368 double azimuth = found_r.heading + found_dir + 180.0;
369 while ( azimuth >= 360.0 ) { azimuth -= 360.0; }
371 SG_LOG( SG_GENERAL, SG_INFO,
372 "runway = " << found_r.lon << ", " << found_r.lat
373 << " length = " << found_r.length * SG_FEET_TO_METER * 0.5
374 << " heading = " << azimuth );
376 geo_direct_wgs_84 ( 0, found_r.lat, found_r.lon,
377 azimuth, found_r.length * SG_FEET_TO_METER * 0.5 - 5.0,
378 &lat2, &lon2, &az2 );
380 if ( fabs( fgGetDouble("/sim/startup/offset-distance") ) > SG_EPSILON ) {
382 double odist = fgGetDouble("/sim/startup/offset-distance");
383 odist *= SG_NM_TO_METER;
384 double oaz = azimuth;
385 if ( fabs(fgGetDouble("/sim/startup/offset-azimuth")) > SG_EPSILON ) {
386 oaz = fgGetDouble("/sim/startup/offset-azimuth") + 180;
388 while ( oaz >= 360.0 ) { oaz -= 360.0; }
389 geo_direct_wgs_84 ( 0, lat2, lon2, oaz, odist, &olat, &olon, &az2 );
393 fgSetDouble("/position/longitude", lon2 );
394 fgSetDouble("/position/latitude", lat2 );
395 fgSetDouble("/orientation/heading", heading );
397 SG_LOG( SG_GENERAL, SG_INFO,
398 "Position for " << id << " is ("
400 << lat2 << ") new heading is "
407 // General house keeping initializations
408 bool fgInitGeneral( void ) {
411 #if defined(FX) && defined(XMESA)
412 char *mesa_win_state;
415 SG_LOG( SG_GENERAL, SG_INFO, "General Initialization" );
416 SG_LOG( SG_GENERAL, SG_INFO, "======= ==============" );
418 root = globals->get_fg_root();
419 if ( ! root.length() ) {
420 // No root path set? Then bail ...
421 SG_LOG( SG_GENERAL, SG_ALERT,
422 "Cannot continue without environment variable FG_ROOT"
423 << "being defined." );
426 SG_LOG( SG_GENERAL, SG_INFO, "FG_ROOT = " << '"' << root << '"' << endl );
428 #if defined(FX) && defined(XMESA)
429 // initialize full screen flag
430 global_fullscreen = false;
431 if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
432 // Test for the MESA_GLX_FX env variable
433 if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
434 // test if we are fullscreen mesa/glide
435 if ( (mesa_win_state[0] == 'f') ||
436 (mesa_win_state[0] == 'F') ) {
437 global_fullscreen = true;
447 // This is the top level init routine which calls all the other
448 // initialization routines. If you are adding a subsystem to flight
449 // gear, its initialization call should located in this routine.
450 // Returns non-zero if a problem encountered.
451 bool fgInitSubsystems( void ) {
452 fgLIGHT *l = &cur_light_params;
454 SG_LOG( SG_GENERAL, SG_INFO, "Initialize Subsystems");
455 SG_LOG( SG_GENERAL, SG_INFO, "========== ==========");
458 ////////////////////////////////////////////////////////////////////
459 // Initialize the material property subsystem.
460 ////////////////////////////////////////////////////////////////////
462 SGPath mpath( globals->get_fg_root() );
463 mpath.append( "materials" );
464 if ( material_lib.load( mpath.str() ) ) {
466 SG_LOG( SG_GENERAL, SG_ALERT, "Error loading material lib!" );
471 ////////////////////////////////////////////////////////////////////
472 // Initialize the scenery management subsystem.
473 ////////////////////////////////////////////////////////////////////
475 if ( fgSceneryInit() ) {
476 // Material lib initialized ok.
478 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Scenery initialization!" );
482 if ( global_tile_mgr.init() ) {
483 // Load the local scenery data
484 global_tile_mgr.update( fgGetDouble("/position/longitude"),
485 fgGetDouble("/position/latitude") );
487 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" );
491 SG_LOG( SG_GENERAL, SG_DEBUG,
492 "Current terrain elevation after tile mgr init " <<
496 ////////////////////////////////////////////////////////////////////
497 // Initialize the flight model subsystem.
498 ////////////////////////////////////////////////////////////////////
500 double dt = 1.0 / fgGetInt("/sim/model-hz");
501 // cout << "dt = " << dt << endl;
503 aircraft_dir = fgGetString("/sim/aircraft-dir");
504 const string &model = fgGetString("/sim/flight-model");
505 if (model == "larcsim") {
506 cur_fdm_state = new FGLaRCsim( dt );
507 } else if (model == "jsb") {
508 cur_fdm_state = new FGJSBsim( dt );
509 } else if (model == "ada") {
510 cur_fdm_state = new FGADA( dt );
511 } else if (model == "balloon") {
512 cur_fdm_state = new FGBalloonSim( dt );
513 } else if (model == "magic") {
514 cur_fdm_state = new FGMagicCarpet( dt );
515 } else if (model == "external") {
516 cur_fdm_state = new FGExternal( dt );
518 SG_LOG(SG_GENERAL, SG_ALERT,
519 "Unrecognized flight model '" << model
520 << ", can't init aircraft");
523 cur_fdm_state->init();
524 cur_fdm_state->bind();
526 // allocates structures so must happen before any of the flight
527 // model or control parameters are set
528 fgAircraftInit(); // In the future this might not be the case.
531 ////////////////////////////////////////////////////////////////////
532 // Initialize the event manager subsystem.
533 ////////////////////////////////////////////////////////////////////
535 global_events.Init();
537 // Output event stats every 60 seconds
538 global_events.Register( "fgEVENT_MGR::PrintStats()",
539 fgMethodCallback<fgEVENT_MGR>( &global_events,
540 &fgEVENT_MGR::PrintStats),
541 fgEVENT::FG_EVENT_READY, 60000 );
544 ////////////////////////////////////////////////////////////////////
545 // Initialize the view manager subsystem.
546 ////////////////////////////////////////////////////////////////////
548 // Initialize win_ratio parameters
549 for ( int i = 0; i < globals->get_viewmgr()->size(); ++i ) {
550 globals->get_viewmgr()->get_view(i)->
551 set_win_ratio( fgGetInt("/sim/startup/xsize") /
552 fgGetInt("/sim/startup/ysize") );
555 // Initialize pilot view
556 FGViewerRPH *pilot_view =
557 (FGViewerRPH *)globals->get_viewmgr()->get_view( 0 );
559 pilot_view->set_geod_view_pos( cur_fdm_state->get_Longitude(),
560 cur_fdm_state->get_Lat_geocentric(),
561 cur_fdm_state->get_Altitude() *
563 pilot_view->set_sea_level_radius( cur_fdm_state->get_Sea_level_radius() *
565 pilot_view->set_rph( cur_fdm_state->get_Phi(),
566 cur_fdm_state->get_Theta(),
567 cur_fdm_state->get_Psi() );
569 // set current view to 0 (first) which is our main pilot view
570 globals->set_current_view( pilot_view );
572 SG_LOG( SG_GENERAL, SG_DEBUG, " abs_view_pos = "
573 << globals->get_current_view()->get_abs_view_pos());
576 ////////////////////////////////////////////////////////////////////
577 // Initialize the lighting subsystem.
578 ////////////////////////////////////////////////////////////////////
580 // fgUpdateSunPos() needs a few position and view parameters set
581 // so it can calculate local relative sun angle and a few other
582 // things for correctly orienting the sky.
585 global_events.Register( "fgUpdateSunPos()", fgUpdateSunPos,
586 fgEVENT::FG_EVENT_READY, 60000);
587 global_events.Register( "fgUpdateMoonPos()", fgUpdateMoonPos,
588 fgEVENT::FG_EVENT_READY, 60000);
590 // Initialize Lighting interpolation tables
593 // update the lighting parameters (based on sun angle)
594 global_events.Register( "fgLight::Update()",
595 fgMethodCallback<fgLIGHT>( &cur_light_params,
597 fgEVENT::FG_EVENT_READY, 30000 );
600 ////////////////////////////////////////////////////////////////////
601 // Initialize the local time subsystem.
602 ////////////////////////////////////////////////////////////////////
604 // update the current timezone each 30 minutes
605 global_events.Register( "fgUpdateLocalTime()", fgUpdateLocalTime,
606 fgEVENT::FG_EVENT_READY, 1800000);
609 ////////////////////////////////////////////////////////////////////
610 // Initialize the weather subsystem.
611 ////////////////////////////////////////////////////////////////////
613 // Initialize the weather modeling subsystem
614 #ifndef FG_OLD_WEATHER
615 // Initialize the WeatherDatabase
616 SG_LOG(SG_GENERAL, SG_INFO, "Creating LocalWeatherDatabase");
618 sgSetVec3( position, current_aircraft.fdm_state->get_Latitude(),
619 current_aircraft.fdm_state->get_Longitude(),
620 current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER );
621 FGLocalWeatherDatabase::theFGLocalWeatherDatabase =
622 new FGLocalWeatherDatabase( position,
623 globals->get_fg_root() );
624 // cout << theFGLocalWeatherDatabase << endl;
625 // cout << "visibility = "
626 // << theFGLocalWeatherDatabase->getWeatherVisibility() << endl;
628 WeatherDatabase = FGLocalWeatherDatabase::theFGLocalWeatherDatabase;
630 double init_vis = fgGetDouble("/environment/visibility");
631 if ( init_vis > 0 ) {
632 WeatherDatabase->setWeatherVisibility( init_vis );
635 // register the periodic update of the weather
636 global_events.Register( "weather update", fgUpdateWeatherDatabase,
637 fgEVENT::FG_EVENT_READY, 30000);
639 current_weather.Init();
642 ////////////////////////////////////////////////////////////////////
643 // Initialize vor/ndb/ils/fix list management and query systems
644 ////////////////////////////////////////////////////////////////////
646 SG_LOG(SG_GENERAL, SG_INFO, "Loading Navaids");
648 SG_LOG(SG_GENERAL, SG_INFO, " VOR/NDB");
649 current_navlist = new FGNavList;
650 SGPath p_nav( globals->get_fg_root() );
651 p_nav.append( "Navaids/default.nav" );
652 current_navlist->init( p_nav );
654 SG_LOG(SG_GENERAL, SG_INFO, " ILS and Marker Beacons");
655 current_beacons = new FGMarkerBeacons;
656 current_beacons->init();
657 current_ilslist = new FGILSList;
658 SGPath p_ils( globals->get_fg_root() );
659 p_ils.append( "Navaids/default.ils" );
660 current_ilslist->init( p_ils );
662 SG_LOG(SG_GENERAL, SG_INFO, " Fixes");
663 current_fixlist = new FGFixList;
664 SGPath p_fix( globals->get_fg_root() );
665 p_fix.append( "Navaids/default.fix" );
666 current_fixlist->init( p_fix );
669 ////////////////////////////////////////////////////////////////////
670 // Initialize the radio stack subsystem.
671 ////////////////////////////////////////////////////////////////////
673 // A textbook example of how FGSubsystem
675 current_radiostack = new FGRadioStack;
676 current_radiostack->init();
677 current_radiostack->bind();
680 ////////////////////////////////////////////////////////////////////
681 // Initialize the cockpit subsystem
682 ////////////////////////////////////////////////////////////////////
684 if( fgCockpitInit( ¤t_aircraft )) {
685 // Cockpit initialized ok.
687 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Cockpit initialization!" );
692 ////////////////////////////////////////////////////////////////////
693 // Initialize the joystick subsystem.
694 ////////////////////////////////////////////////////////////////////
696 if ( ! fgJoystickInit() ) {
697 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Joystick initialization!" );
701 ////////////////////////////////////////////////////////////////////
702 // Initialize the autopilot subsystem.
703 ////////////////////////////////////////////////////////////////////
705 current_autopilot = new FGAutopilot;
706 current_autopilot->init();
708 // initialize the gui parts of the autopilot
715 ////////////////////////////////////////////////////////////////////
716 // Initialize I/O subsystem.
717 ////////////////////////////////////////////////////////////////////
719 #if ! defined( macintosh )
723 // Initialize the 2D panel.
724 string panel_path = fgGetString("/sim/panel/path",
725 "Panels/Default/default.xml");
726 current_panel = fgReadPanel(panel_path);
727 if (current_panel == 0) {
728 SG_LOG( SG_INPUT, SG_ALERT,
729 "Error reading new panel from " << panel_path );
731 SG_LOG( SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path );
732 current_panel->init();
733 current_panel->bind();
737 ////////////////////////////////////////////////////////////////////
738 // Initialize the BFI.
739 ////////////////////////////////////////////////////////////////////
744 ////////////////////////////////////////////////////////////////////
745 // Initialize the controls subsystem.
746 ////////////////////////////////////////////////////////////////////
752 ////////////////////////////////////////////////////////////////////////
753 // End of subsystem initialization.
754 ////////////////////////////////////////////////////////////////////
756 SG_LOG( SG_GENERAL, SG_INFO, endl);
758 // Save the initial state for future
760 globals->saveInitialState();
766 void fgReInitSubsystems( void )
768 SG_LOG( SG_GENERAL, SG_INFO,
769 "/position/altitude = " << fgGetDouble("/position/altitude") );
771 bool freeze = globals->get_freeze();
773 globals->set_freeze( true );
775 // Initialize the Scenery Management subsystem
776 if ( ! fgSceneryInit() ) {
777 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Scenery initialization!" );
781 if( global_tile_mgr.init() ) {
782 // Load the local scenery data
783 global_tile_mgr.update( fgGetDouble("/position/longitude"),
784 fgGetDouble("/position/latitude") );
786 SG_LOG( SG_GENERAL, SG_ALERT, "Error in Tile Manager initialization!" );
790 // Initialize view parameters
791 FGViewerRPH *pilot_view =
792 (FGViewerRPH *)globals->get_viewmgr()->get_view( 0 );
794 pilot_view->set_view_offset( 0.0 );
795 pilot_view->set_goal_view_offset( 0.0 );
797 pilot_view->set_geod_view_pos( cur_fdm_state->get_Longitude(),
798 cur_fdm_state->get_Lat_geocentric(),
799 cur_fdm_state->get_Altitude() *
801 pilot_view->set_sea_level_radius( cur_fdm_state->get_Sea_level_radius() *
803 pilot_view->set_rph( cur_fdm_state->get_Phi(),
804 cur_fdm_state->get_Theta(),
805 cur_fdm_state->get_Psi() );
807 // set current view to 0 (first) which is our main pilot view
808 globals->set_current_view( pilot_view );
810 SG_LOG( SG_GENERAL, SG_DEBUG, " abs_view_pos = "
811 << globals->get_current_view()->get_abs_view_pos());
813 cur_fdm_state->init();
815 controls.reset_all();
816 current_autopilot->reset();
819 globals->set_freeze( false );