Skip to content

Frequently Asked Questions

Bertrand Coconnier edited this page May 7, 2022 · 1 revision

How can I interface JSBSim with FlightGear ?

Q: I would like to visualize the aircraft model in FlightGear while running the FDM with the JSBSim executable. How do I proceed ?

A: We are assuming that FlightGear is installed on your platform. If it is not, please follow the instructions on the FlightGear website.

You will need to launch separately FlightGear and JSBSim from a console. In the example below, you will execute the script ShortS23_2.xml so you might need to install the FlightGear model of the Short Empire aircraft. This is optional however as any aircraft can be used for visualization even if it does not match the aircraft of the JSBSim FDM model.

First, run FlightGear and tell it that the flight dynamics will be provided thru a socket by an external program. It is assumed that the executable of FlightGear is fgfs (see the FlightGear docs for details on the parameters of --native-fdm argument).

> fgfs --fdm=null --native-fdm=socket,in,60,,5550,udp --aircraft=Short_Empire --airport=SP01

Once FlightGear is launched, you will see the aircraft standing still.

FlightGear is launched

Now we will run JSBSim and tell it that it must send the flight dynamics data to FlightGear through a socket

> JSBSim scripts/Short_S23_2.xml data_output/flightgear.xml --realtime --nice

The parameters describing the protocol are detailed in data_output/flightgear.xml. The flag --realtime requests JSBSim to execute in real time. Otherwise JSBSim will run as fast as it can and the flight will look like it is played fast forward. The flag --nice tells JSBSim to use as few CPU power as possible. This is an optional flag but since we requested --realtime, JSBSim will spend a considerable amount of time idling, waiting for the next frame in FlightGear.

At the this stage, the two executables are interacting and FlightGear produces the visualization of the flight dynamics simulated by JSBSim.

FlightGear/JSBSim interface running