Tutorial: Jsbsim
while (fdm.Run()) { double lat = fdm.GetProperty("position/lat-deg"); double lon = fdm.GetProperty("position/lon-deg"); double roll = fdm.GetProperty("attitude/roll-rad"); // Send these to your OpenGL/Unreal engine } return 0; } JSBSim exposes a property tree via Socket or HTTP . Enable the socket server in your script:
Open a terminal and run:
Introduction: Why JSBSim? In the world of flight simulation, the "physics engine" that dictates how an aircraft responds to control inputs, wind gusts, and atmospheric conditions is known as the Flight Dynamics Model (FDM). While many simulators rely on black-box, pre-compiled DLLs or lookup tables, JSBSim stands apart as an open-source, highly modular, and mathematically rigorous FDM. jsbsim tutorial
<?xml version="1.0"?> <runscript> <use aircraft="c172" initialization="reset"/> <run start="0" end="60" dt="0.01"> <property value="20.0"> simulation/sim-time-sec </property> <!-- Start at 20 sec --> <property value="140.0"> velocities/vc-kts </property> <!-- 140 knots --> <property value="0.1"> fcs/elevator-cmd-norm </property> <!-- Pull back slightly --> <!-- Define a landing at 40 seconds --> <event name="Flaps Down" time="40"> <set value="1.0"> fcs/flaps-cmd-norm </set> </event> </run> </runscript> while (fdm
Run it:
JSBSim --script=scripts/c1721.xml You will see a cascade of text output: unit conversions, aerodynamic coefficients, and finally, time-step data every 0.01 seconds. You just ran a simulation. The aircraft took off, climbed, and flew a pattern. You didn't see it, but you simulated it. To control it manually via keyboard/joystick in real-time: While many simulators rely on black-box, pre-compiled DLLs