Implementing VNAV support in FlightGear: Difference between revisions

Jump to navigation Jump to search
m
m (Hooray moved page Performance Database via FDM to Implementing VNAV support in FlightGear: make this a little less specific for now)
Line 179: Line 179:
[[JSBSim]] is an open source [[Flight Dynamics Model]] (FDM) software library that models the flight dynamics of an aerospace vehicle. The library has been incorporated into [[FlightGear]] and [http://www.openeaagles.org/ OpenEaagles]. It can also be called from a small standalone program to create a scripted batch simulation tool. JSBSim has been in development and use since 1996, and has been built on all of the most popular platforms in use today including those running Linux, Macintosh, and Microsoft Windows operating systems. JSBSim is written in C++ and uses [[File Formats#|XML]] configuration files. To date, JSBSim is the most mature FDM engine supported by FlightGear, being independently developed and maintained. JSBSim includes extensive support for systems modeling and several building blocks to simulate complex systems, including autoflight/autopilot systems.  
[[JSBSim]] is an open source [[Flight Dynamics Model]] (FDM) software library that models the flight dynamics of an aerospace vehicle. The library has been incorporated into [[FlightGear]] and [http://www.openeaagles.org/ OpenEaagles]. It can also be called from a small standalone program to create a scripted batch simulation tool. JSBSim has been in development and use since 1996, and has been built on all of the most popular platforms in use today including those running Linux, Macintosh, and Microsoft Windows operating systems. JSBSim is written in C++ and uses [[File Formats#|XML]] configuration files. To date, JSBSim is the most mature FDM engine supported by FlightGear, being independently developed and maintained. JSBSim includes extensive support for systems modeling and several building blocks to simulate complex systems, including autoflight/autopilot systems.  


In comparison with the YASim section below, the section on JSBSim has become pretty detailed already (within just 2 days actually) - and unlike YASim, JSBSim is pretty straightforward to extend, in fact it is designed to be easily extensible via various infrastructure hooks, despite a lack of any detailed documentation, and it's also easy to build from source, as well as being actively maintained by a sizable community of developers (vs. YASim development being de-facto stalled, and patches next to imposible to get reviewed/committed).  
In comparison with the YASim section below, the section on JSBSim has quickly become pretty detailed already (within just 2-3 days actually) - and it seems that unlike YASim, JSBSim is pretty straightforward to extend.


While JSBSim itself deals with very sophisticated concepts, its code base is surprisingly straightforward in many places, despite being written in C++ - there's very little use of modern C++ concepts actually. In fact, one could say that JSBSim code looks a lot like "C with classes", so the barrier to entry is really low, even for people who really only have working C knowledge, even the FlightGear code base is making use of more modern C++ concepts. JSBSim also contains many useful building blocks for creating sophisticated systems simulations, which will surely come in handy.
In fact, JSBSim is designed to be easily extensible via various infrastructure hooks obviously, despite a lack of any detailed documentation on extending JSBSim, and it's also easy to build from source (completely self-contained, no external dependencies), as well as being actively maintained by a sizable community of developers (vs. YASim development being de-facto stalled, and patches next to imposible to get reviewed/committed).  


Last but not least, JSBSim provides a capability to easily run and test things in a standalone mode, without having to build FlightGear from source, and without requiring any external dependencies, it also already contains various aircraft, engine models, tests and scripted scenarios that only take seconds to get working.
While JSBSim itself deals obviously with very sophisticated concepts, its code base is surprisingly straightforward actually in many places, despite being written in C++ - there's very little use of modern C++ concepts actually.  


In summary, without having had any previous JSBSim/FDM coding experience, I've been able to make working modifications within just 10-15 minutes of playing with the code (including cloning and building from source), and by looking at the reference manual every now and then. This speaks for itself and for JSBSim and as a viable testbed, which can be also seen in the amount of useful information that's been gathered here meanwhile.
Indeed, one could say that JSBSim code looks a lot like "C with classes", so the barrier to entry is really low, even for people who really only have working C knowledge, even the legacy FlightGear code base is making use of more modern C++ concepts. JSBSim also contains many useful building blocks for creating sophisticated systems simulations, which will surely come in handy when playing with VNAV support.


For these reasons, current VNAV-related experiments are being conducted with a focus on JSBSim for the time being, even though it is understood that we will eventually need to identify common building blocks in order to also support YASim at some point. But so far, my impression is that extending JSBSim with the required building blocks is pretty straightforward, so that's what I'm going to use/focus on.
Last but not least, JSBSim provides a capability to easily run and test things in a standalone mode, without having to build FlightGear from source, and without requiring any external dependencies, it also already contains various aircraft, engine models, autopilots, tests and scripted scenarios that only take seconds to get working, even for people with zero prior JSBSim/FDM exposure.
 
In summary, without having had any previous JSBSim/FDM experience, I've been able to make working modifications within just 10-15 minutes of playing with the code (including cloning and building from source), and by looking at the reference manual every now and then. This speaks for itself and for JSBSim and as a viable testbed, which can be also seen in the amount of useful information that's been gathered here meanwhile (some of which should probably be contributed back to the JSBSim reference manual).
 
For these reasons, current VNAV-related experiments are being conducted with a focus on JSBSim for the time being, even though it is understood that we will eventually need to identify common building blocks in order to also support YASim at some point. But so far, it seems that extending JSBSim with the required building blocks is pretty straightforward, so that's what we're going to use/focus on.


=== Getting started ===
=== Getting started ===
Line 254: Line 258:


Typically, you'll however want to use FGScript to create a completely scripted JSBSim run, which allows you to easily test new FDM features (and simulated systems) non-interactively.
Typically, you'll however want to use FGScript to create a completely scripted JSBSim run, which allows you to easily test new FDM features (and simulated systems) non-interactively.
=== FGScript ===
JSBSim is entirely built around the [[Property Tree]] concept (actually an outdated version of it - because JSBSim doesn't depend on SimGear, the old property tree code is still used in the source tree), scripting in JSBSim is also implemented on top of the property tree, it isn't really "scripting" per se, it's properties + XML, and some JSBSim specific building blocks to support events, conditions, notifications and some custom expressions. Surprisingly, this rather simple mechanism is pretty powerful, and fully deterministic.
To learn more about FGScript itself, you will want to check out the [http://www.holycows.net/JSBSim_Script_Tutorial.pdf JSBSim Scripting Tutorial].
The scripting engine in JSBSim is to be found in src/input_output/FGScript.cpp - scripts are basically just XML files that are evaluated once during initialization, to  set up several data structures, namely:
* initialization stuff (aircraft, initialization file (position, altitude, etc)
* input and output settings
* startup parameters (start time/end time and update rate of the simulation)
* an arbitrary number of '''<event/>''' blocks
Scripting examples are to be found in the scripts/ directory.
Scripts are loaded via '''bool FGScript::LoadScript()'''


=== Adding new Functions ===
=== Adding new Functions ===

Navigation menu