David Culp - 2015-02-26

QtJSBSim

QtJSBSim is a FlightSim/GUI front end for the JSBSim flight dynamics model. It was inspired by, and includes a widget from the QFlightInstruments project. Joystick handling comes from the SDL project. For the "out-the-window" view you can send data to FlightGear.

 
License

GPLv3 https://gnu.org/licenses/gpl.txt

 
History

JSBSim is an open source flight dynamics library, designed to simulate the real time dynamics of an aerial vehicle. There are three ways to use JSBSim as part of a larger simulation project.

  1. You can use JSBSim source to build JSBSim within your app. Note that your app will have to operate a timing mechanism to call JSBSim's run() method at some high rate. Your timing mechanism will need enough resolution to cycle at about 120 Hz or faster, probably in a separate thread. One benefit of this method is that it gives you access to more of JSBSim's internal variables.

  2. Your app can spin off a JSBSim's "standalone" app as a separate process. JSBSim standalone is a command line wrapper app for JSBSim that includes a high-res timer and other functionality, like executing scripted runs. Communication with the process will be through sockets. One limitation of this method is that you only have access to internal JSBSim variables that are exposed via the property system.

  3. Similar to #2, you can launch JSBSim standalone from a console, then your app can establish socket communication with it later.

QtJSBSim uses method 2.

 

QtJSBSim project files

This project was developed using QtCreator, which is The Qt Company's IDE. It contains project definition files and UI support files needed by QtCreator. QtCreator makes UI development fast and easy, and the Qt library is full of useful high-level objects. However you don't need to use QtCreator. The project can be built using cmake.

You can download and build a QtJSBSim executable as described at [Downloading and Building].

 
Joystick support

Joystick support comes from SDL (Simple DirectMedia Layer). For those of you who don't have a joystick, note that I have not yet included a secondary method of getting flight control inputs into QtJSBSim. QtJSBSim is tested with linux only at the moment, but I'm working on building in Windows 10. Be advised that building in another OS may require re-numbering the joystick axes. This can be done in the qtjsbsim.ini file.

 
Primary Flight Display (PFD)

The PFD widget comes from Marek Cel's QFlightInstruments project. Note that magnetic variation is not yet built in to JSBSim, so I've made variation a setting in qtjsbsim.ini that applies throughout your simulator session.

 
The 737

Included in the download is a revised 737 configuration file that includes (at the bottom) a new XML block that specifies what data is to be sent and received to/from JSBSim:

 <input port="5139" type="UDPSOCKET" rate="20">
  <property> fcs/aileron-cmd-norm </property> 
  <property> fcs/elevator-cmd-norm </property> 
  <property> fcs/rudder-cmd-norm </property> 
  <property> fcs/throttle-cmd-norm[0] </property> 
  <property> fcs/throttle-cmd-norm[1] </property>
  ... etc ...
  <property> simulation/terminate </property> 
 </input>  

There is also a reset00.xml file that contains a new initialization tag that enables ground trimming.

 
The qtjsbsim.ini file

The initialization file for QtJSBSim is included in the QtJSBSim project directory at qtjsbsim-code/src/qtjsbsim.ini. Before running the app please edit the entry which defines the path to the JSBSim executable. For instance, on my linux system the JSBSim executable is located at /home/dave/JSBSim/build/src/JSBSim.

 

Quick start:

  1. Launch QtJSBSim.

  2. Start JSBSim by clicking the Start button.

 
If JSBSim launches and initializes properly you'll get this console message:

 
3. Click the Connect button in the QtJSBSim GUI :

 
This starts the exchange of data to/from JSBSim. By default datagrams are sent to JSBSim at 10 hz and are read at 20 hz. JSBSim sends datagrams to QtJSBSim at 10 hz and they are read at 100 hz (the default main loop rate setting, although your app may run slower.

The two apps are now exchanging information over UDP sockets. QtJSBSim is sending control information to JSBSim, and JSBSim is sending back state data of the 737 model.

To display an OTW (Out The Window) view you can send data to an instance of FlightGear by clicking the "-> FG" button.

To terminate the JSBSim instance click on the Stop button or hit the "t" key on your keyboard. Note that you have to do this while the socket connections are active, otherwise JSBSim will not get the signal.

 
What next?

In the near term I'd like to:

  1. Increase the amount of data flow to see if any limits are reached, or if performance is impacted. At present I have 51 data points coming from JSBSim and 17 going to JSBSim.

  2. Make the app more cross-platform and robust. So far I've only run it on linux. The code base should be cross-platform, but I haven't got the build system set up to successfully build in another OS yet.

 

Related

Wiki: Downloading and Building


Last edit: David Culp 2022-02-11