Tutorial | Jsbsim
A fundamental building block of any autopilot is the PID controller, which is built directly into JSBSim. The following example shows a simple wing-leveler autopilot in XML that uses a PID controller to maintain zero roll angle:
Finally, integrating JSBSim into a larger project requires an understanding of its standalone and library modes. In standalone mode, JSBSim can run a scripted flight plan, outputting data to a CSV file for post-flight analysis in tools like MATLAB or Excel. As a library, it can be integrated into visual simulators like FlightGear or Outerra, where it provides the movement logic while the host application handles the graphics.
Here are some tips and tricks to help you get the most out of JSBSim:
The FCS section processes user inputs (joystick, keyboard) into control surface deflections. JSBSim utilizes functional components called "components" to build control logic. Common FCS Components fcs_function : Performs custom mathematical operations. pure_gain : Multiplies an input by a static value. jsbsim tutorial
Your intended (e.g., standalone console execution, C++ code integration, FlightGear, or Python wrapper).
JSBSim supports various engine types, including piston engines, turbines, rockets, and electric motors. You can define performance curves (power vs. altitude/RPM) in the propulsion XML files. Flight Control System (FCS)
import jsbsim sim = jsbsim.FGFDMExec(None) sim.load_model('c172p') # or path to aircraft xml sim.initialise() # initialize with defaults A fundamental building block of any autopilot is
The following script initializes an aircraft simulation instance and extracts mathematical state logs programmatically:
This script creates a live control loop that reads altitude data from the simulation and immediately sends commands back into it. This is a core technique for building custom autopilots and analyzing aircraft behavior.
When creating custom components within JSBSim, double-check these common problem spots: As a library, it can be integrated into
Defines horsepower/thrust, fuel consumption, and RPM limits. Propeller File: Defines the "table of coefficients" ( ) relative to the advance ratio ( Step 4: Flight Control Systems (FCS)
Define the empty weight, Center of Gravity (CG), and moments of inertia (
<initialCondition> <altitude unit="FT"> 0 </altitude> <ground_offset unit="FT"> 0 </ground_offset> <vc unit="KTAS"> 0 </vc> </initialCondition>
Drag force aero/qbar-psf metrics/sw-sqft
fdm = jsbsim.FGFDMExec('/path/to/jsbsim/root')