The Flightgear Flight Simulator
Total Page:16
File Type:pdf, Size:1020Kb
The FlightGear Flight Simulator Alexander R. Perry PAMurray, San Diego, CA alex.perry@flightgear.org http://www.flightgear.org/ Abstract convenience most open source projects, in order to to run on Intel x86, AMD64, PowerPC and Sparc processors. The open source flight simulator FlightGear is developed from contributions by many talented people around the world. In addition to running the simulation of the aircraft in The main focus is a desire to ‘do things right’ and to min- real time, the application must also use whatever peripher- imize short cuts. FlightGear has become more configurable als are available to deliver an immersive cockpit environ- and flexible in recent years making for a huge improvement ment to the aircraft pilot. Those peripherals, such as sound in the user’s overall experience. This overview discusses the through speakers, are accessed through operating system ser- project, recent advances, some of the new opportunities and vices whose implementation may be equivalent, yet very dif- newer applications. ferent, under the various operating systems. FlightGear cur- rently supports Windows, FreeBSD, Linux, Solaris, MacOS, Irix and OS-X. Introduction For those services which are common across most video games, the independent project PLIB offers a simple API The open source flight simulator FlightGear has come a long that acts as a Portable Library[2]. Compared to Windows, way since first being showcased at LinuxWorld in San Jose. MacOS and the Unix’s, the various distributions and releases In April 1996, David Murr proposed a new flight simulator of Linux-based operating systems are very similar. There are developed by volunteers over the Internet. This flight simu- important differences, most of which cause problems when lator was to be distributed free of charge via the Internet and trying to build and test PLIB, so these rarely impact Flight- similar networks. Curt Olson made a multi-platform release Gear directly. Once the facilities required by video games are of FlightGear[1] in July 1997. available through the Portable Library, the remainder of the Since then, it has expanded beyond flight aerodynamics code acts as a conventional application. by improving graphics, adding a shaded sky with sun, moon Any Linux user can download the source, compile it and and stars correctly drawn, automatically generated world- safely expect it to run. FlightGear, and other applications with wide scenery, clouds and fog, head up display and instrument extensive 3D visual effects as in figure 1, may use different panel, electronic navigation systems, airports and runways, libraries under the same Linux distribution so that the binary network play, and much more. may not be portable between computers. Some hardware only Recent changes to the simulator have simplified the cus- has accelerated 3D under XFree86 version 3, other hardware tomization of those features by the user, as discussed in more requires version 4, and their GLX APIs differ. This is being detail below. Instead of being in the source code, the con- addressed by the Linux OpenGL Application Binary Interface figuration data is now specified on the command line and/or (ABI)[4] but continues to be a source of frustration for new accessible using menu items and/or loaded from simple files. would-be users. Once the issues associated with running the simulation pro- Simulator Portability gram on a specific computer are resolved, everything else is portable. The configuration information can be freely trans- FlightGear aims to be portable across many different proces- ferred across processors and operating systems. Each instal- sors and operating systems, as well as scale upwards from lation can benefit from the broad range of scenery, aircraft commodity computers. The source has to be clean with re- models, scenarios and other adaptations that have been made spect to address width and endianness, two issues which in- available by any user. Figure 1: Pilot’s view from a Cessna 172 making a poor approach for landing at San Francisco International Airport. The “Time of Day” pop up menu is partially visible, with seven quick selects and an additional button for typing in the time. Seven consecutive screen dumps, from a wide screen display, have been combined to demonstrate the simulator’s lighting model Simulator Structure through the property database, part of the generic simulation infrastructure offered by SimGear[6]. This dynamically maps Unlike proprietary commercial PC flight simulators, the Open a name (such as /position/latitude) into an object Source nature of the FlightGear project permits modification with getter and setter methods. If the property will be ac- and enhancement. Since the project wishes to encourage its cessed frequently, the pointer to the object can be stored so user community to embrace, extend and improve the simula- that the string lookup of the name only occurs one time. The tion, the FlightGear source offers a flexible framework. single pointer indirection is still somewhat slower than hard The FlightGear source tree is only one level deep, except linkage, but enhances the modularity of the code base. For that all the flight data models are each in their own sub- example, the user interface definitions in XML files (panels, directory located under the FDM directory. Each directory instruments, 3D animation, sound, etc) are able to refer to any contains a few header files that expose its object definitions. property offered by any subsystem. Other source files refer to the headers directly, without the The simulator state is also accessible on the network. frustrations of path globbing or multiple include paths for Adding the command line option --telnet=5555 allows the compiler. The directory names are mostly pretty self- another computer (such as the instructor console) to inter- explanatory: act with the simulator computer using a command such as AIModel, Aircraft, Airports, ATC, Autopilot, Cockpit, Con- telnet simulator 5555. This network interface al- trols (in the aircraft cockpit), Environment, FDM (only one lows any property in the database to be viewed or modified constituent is in use), GUI (menus and the like), Include (for and includes remote enumeration of all the property names. compiler configuration), Input (joysticks etc), Instrumenta- This has been used to implement a complete external operator tion, Main (initialization and command line parsing), Model GUI and for automating FAA certification tests. (3D aircraft), MultiPlayer, Navaids, Network (data sharing), Many tasks within the simulator need to only run periodi- Objects (dynamically loaded and changing scenery), Replay, cally. These are typically tasks that calculate values that don’t Scenery (static), Scripting (remote script control), Server, change significantly in 1/60th of a second, but instead change Sound, Systems and Time (in the simulated world). noticeably on the order of seconds, minutes, or hours. Run- FlightGear exposes the internal state of the simulation ning these tasks every iteration would needless degrade per- compiled. Installing and running FlightGear is relatively easy under Linux, especially compared to other operating systems with weak tool automation. 1. Install Linux normally and test Internet access. 2. Add video card support, using a maximum of 25% of memory for the 2D display, as 3D uses the remainder. 3. Enable hardware accelerated OpenGL support and test for speed, using glTron[5] for example. Figure 2: Panoramic scenery, configured by Curt Olson 4. Install[2] PLIB 1.8 or above, which is already in many distributions, and test with all the supplied examples to formance. Instead, we would like to spread these out over ensure all the API features are working. time to minimize the impact they might have on frame rates, and minimize the chance of pauses and hesitations. 5. Verify that headers for zlib and similar are present. We do this using the Event Manager and Scheduler, which 6. Download[6], compile and install SimGear. consists of two parts. The first part is simply a heap of regis- tered events along with any management information associ- 7. While that compiles, download the FlightGear source. ated with that event. The second part is a run queue. When events are triggered, they are placed in the run queue. The 8. With SimGear installed, compile and install FlightGear system executes only one pending event per iteration in or- der to balance the load. The manager also acquires statistics 9. While compiling, download FlightGear’s base package. about event execution such as the total time spent running this This contains data files that are required at runtime. event, the quickest run, the slowest run, and the total number 10. Type runfgfs and enjoy. of times run. We can output the list of events along with these statistics in order to determine if any of them are consuming Starting from a blank hard drive with no operating system, an excessive amount of time, or if there is any chance that a FlightGear can be running in less than an hour. particular event could run slow enough to be responsible for a perceived hesitation or pause in the flow of the simulation. FlightGear itself supports threads for parallel execution, Simulating the Pilot’s view which distributes tasks such as scenery management over The new FlightGear pilot will probably not want to remain many iterations, but some of the library dependencies are within the San Francisco bay area, which is the small scenery not themselves thread clean. Thus all accesses to non-thread- patch included in the Base package. The scenery server al- clean libraries (such as loading a 3D model) need to be made lows the selection and retrieval of any region of the world. by a single thread, so that other activities wishing to use the Joining other users in the sky is another possibility. same library must be delayed. These small delays can lead to Due to limited monitor size, the view that is available on a minor user-visible hesitations.