JSBSim-Team / jsbsim

An open source flight dynamics & control software library
GNU Lesser General Public License v2.1
1.41k stars 460 forks source link
aerospace-engineering aircraft aircraft-control aircraft-design flight-dynamics flight-simulation jsbsim matlab python simulation unreal-engine-plugin

C/C++ build PyPI Conda (channel only) PyPI Downloads Downloads GitHub Downloads SourceForge

Introduction

JSBSim is a multi-platform, general purpose object-oriented Flight Dynamics Model (FDM) written in C++. The FDM is essentially the physics & math model that defines the movement of an aircraft, rocket, etc., under the forces and moments applied to it using the various control mechanisms and from the forces of nature. JSBSim can be run in a standalone batch mode flight simulator (no graphical displays a.k.a. console mode) for testing and study, or integrated with the Unreal engine, FlightGear and many other simulation environments.

Features include:

JSBSim also includes the following bindings:

In 2015, NASA performed some verification check cases on 7 flight dynamics software including JSBSim (the other 6 being NASA in-house software). The results showed that the 7 simulation tools "were good enough to indicate agreement between a majority of simulation tools for all cases published. Most of the remaining differences are explained and could be reduced with further effort."

Applications and Usages

JSBSim is used in a range of projects among which:

Academic and Industry Research

JSBSim is also used in academic and industry research (more than 700 citations referenced by Google Scholar as of May 2023).

In 2023 JSBSim was featured in the article "A deep reinforcement learning control approach for high-performance aircraft" , by De Marco et al. (2023), Nonlinear Dynamics, an International Journal of Nonlinear Dynamics and Chaos in Engineering Systems by Springer (doi: 10.1007/s11071-023-08725-y). The open-access article is available as a PDF here https://link.springer.com/content/pdf/10.1007/s11071-023-08725-y.pdf. The work demonstrates an application of Deep Reinforcement Learning (DRL) to flight control and guidance, leveraging the JSBSim interface to MATLAB/Simulink.

Another more advanced application within the field of Deep Reinforcement Learning is presented in the article "Hierarchical Reinforcement Learning for Air Combat at DARPA's AlphaDogfight Trials" by A. P. Pope et al. (2023), IEEE Transactions on Artificial Intelligence (doi: 10.1109/TAI.2022.3222143), featuring a hierarchical reinforcement learning approach. The trained agent was designed alongside of and competed against active fighter pilots, and ultimately defeated a graduate of the United States Air Force's F-16 Weapons Instructor Course in match play. See also the DARPA Virtual Air Combat Competition.

User Guide

Installation

Windows

A Windows installer JSBSim-1.2.1-setup.exe is available in the release section. It installs the 2 executables along with aircraft data and some example scripts:

Both executables are console line commands.

The Windows installer also contains the files needed to build the JSBSim Matlab S-Function (see our MATLAB README for more details about using JSBSim in Matlab).

Ubuntu Linux

Debian packages for Ubuntu Linux "Focal" 20.04 LTS and "Jammy" 22.04 LTS for 64 bits platforms are also available in the JSBSim project release section. There are 3 packages for each platform:

Python module

JSBSim provides binary wheel packages for its Python module on Windows, Mac OSX and Linux platforms for several Python versions (3.8, 3.9, 3.10, 3.11 and 3.12). These can be installed using either pip or conda.

Installation with pip

Binary packages a.k.a. wheel packages are available from the Python Package Index (PyPI), a repository of software for the Python programming language.

Installing jsbsim using pip can be achieved with:

> pip install jsbsim

Check the pip documentation for more details.

Note that wheel packages for Linux meet the PEP600 ManyLinux packages requirements and as such are compatible with a majority of Linux distributions.

Installation with conda

Conda is an open-source package management system and environment management system that runs on Windows, macOS, and Linux. The JSBSim conda package is available from conda-forge, a community led collection of recipes, build infrastructure and distributions for the conda package manager.

Installing jsbsim from the conda-forge channel can be achieved by adding conda-forge to your channels with:

> conda config --add channels conda-forge

Once the conda-forge channel has been enabled, jsbsim can be installed with:

> conda install jsbsim

It is possible to list all of the versions of jsbsim available on your platform with:

> conda search jsbsim --channel conda-forge

Other platforms

At the moment, JSBSim does not provide binaries for platforms other than Windows 64 bits and Ubuntu 64 bits. Alternatively, you can use JSBSim wheel packages for Windows, Linux or MacOS. Otherwise you should follow the instructions in the developer docs to build JSBSim on your platform.

Aircraft data and example scripts

JSBSim aircraft data and example scripts are automatically installed if you are using Python wheel packages. Otherwise, you can get aircraft data and example scripts by downloading either the zip package or the tar.gz package.

Quick start

Once you have downloaded (or built) the binaries and unzipped the aircraft data. Go to the root of the data package and make sure the executable is accessible from there.

You can then run an FDM simulation with the following command:

> JSBSim.exe --script=scripts/c1721.xml

More options are available if you run:

> JSBSim.exe --help

User documentation

A first place to look at for JSBSim documentation resources is https://jsbsim.sourceforge.net/documentation.html. This link points to the official JSBSim Reference Manual, a PDF which is the best source of information for users and developers.

However, due to the nature of the development of the project (JSBSim sources are updated often, sometimes even daily), several new features that are available in the software are not yet documented in the reference manual. Starting from March 2018 a new effort is underway to deliver an up-to-date documentation web site. You can browse the new JSBSim Online Reference Manual by going to: https://jsbsim-team.github.io/jsbsim-reference-manual. The online manual is under construction and as a first milestone it will incorporate all the non-outdated material contained in the original PDF Reference Manual. The online manual web site is based on the GitHub Pages technology and its sources are available here. Eventually, the PDF Reference Manual will be superseded by the online manual, which is designed to be updated collaboratively as well as in efficient and timely fashion.

Interfacing JSBSim with your application

Using the C++ API

JSBSim can be interfaced or integrated to your application via a C++ API. The following code illustrates how JSBSim can be called by a small program, with execution being controlled by a script:

#include <FGFDMExec.h>

int main(int argc, char **argv)
{
  JSBSim::FGFDMExec FDMExec;
  FDMExec.LoadScript(SGPath(argv[1]));
  FDMExec.RunIC();
  bool result = true;
  while (result) result = FDMExec.Run();
}

The API is described in more details in the C++ API documentation

Using the Python module

JSBSim can also be used as a Python module. JSBSim Python wheels are provided with the proverbial "batteries included" i.e. with some default aircraft data and example scripts.

The following code provides a simple example of how to interface with JSBSim using the Python programming language:

import jsbsim

fdm = jsbsim.FGFDMExec(None)  # Use JSBSim default aircraft data.
fdm.load_script('scripts/c1723.xml')
fdm.run_ic()

while fdm.run():
  pass

Providing jsbsim.FGFDMExec with the value None allows using the installed default aircraft data and scripts (in the example above we are using the script scripts/c1723.xml, one of the many scripts installed by default).

The default aircraft data is located in a directory which path can be retrieved with the function get_default_root_dir():

print(jsbsim.get_default_root_dir())

A more elaborate example of Python code is JSBSim.py, the Python equivalent to JSBSim.exe.

Contributing Source Code Changes

If you would like to contribute source code changes please take a look at the Contributing Source Code Changes to JSBSim Wiki page for instructions on how to go about contributing.

Contact

For more information about JSBSim, you can contact the development team on GitHub discussion or submit tickets on https://github.com/JSBSim-Team/jsbsim/issues

We are also on Facebook: https://www.facebook.com/jsbsim/

Legal Notice

The JSBSim library is open source and is licensed under the LGPL 2.1 license. The license is included in the source code file COPYING.

The Unreal Engine Reference Application for JSBSim is open source and is licensed under the MIT license. The license is included in the source code file UnrealEngine/LICENSE.txt.

The JSBSim interface with MATLAB including the S-Function is open source and is licensed under the BSD license. The license is included in the source code file matlab/LICENSE.txt.

The Python module of JSBSim is open source and is licensed under the LGPL 2.1 license. The license is included in the source code file COPYING.

No proprietary code is included. All code included within the JSBSim project has been developed on a volunteer basis using publicly available information, and is often directly linked to a particular textbook, for educational reference. In some cases, code of a generic nature has been donated back to the project.

Likewise, the aircraft models included in this project and distribution do not include any proprietary, sensitive, or classified data. All data is derived from textbooks (such as Stevens and Lewis "Aircraft Control and Simulation" and Sutton's "Rocket Propulsion Elements"), freely available technical reports (see: https://ntrs.nasa.gov and https://www.aiaa.org), or other public data (such as the FAA web site). Aircraft models included in the JSBSim distribution and with names corresponding to existing commercial or military aircraft are approximations crafted using publicly available information, and are for educational or entertainment uses only.