Matlab integration of JSBSim based on work of EliaTarasov
Compiled and tested on for Linux (Ubuntu).
- Type
git submodule initandgit submodule update- that will pull JSBSim submodule (note: consider updating to the latest JSBSIM from https://sourceforge.net/p/jsbsim/code/ci/master/tree/ ?) - Go to
JSBSimdirectoryand make sure you are onmatlab_integrationbranch - Configure JSBSim for shared libraries:
./autogen.sh --enable-libraries --disable-static --enable-shared - Make JSBSim with shared libraries:
make(it will take a moment) - Start Matlab (tested so far with 2014b) and navigate to the root directory of
JSBSim-Matlab - In Matlab command line type:
mex ./JSBSimMatlab/MexJSBSim.cpp ./JSBSimMatlab/JSBSimInterface.cpp -I./JSBSim/src -L./JSBSim/src/.libs -lJSBSim - Now you can run for example
test1.mortest_c172_cruise_8K.mor simply call set/get handles in your own script
- Do steps 1-5 as in the previous case
- In Matlab command line type:
mex -v ./JSBSimMatlab/JSBSim_SFunction.cpp ./JSBSimMatlab/JSBSimInterface.cpp -I./JSBSim/src -L./JSBSim/src/.libs -lJSBSimIt will compile and output (on 64buit machines) JSBSim_SFunction.mexa64 - Now start
JSBSim_GUI.m- it will open a GUI that you need to use - In the GUI first click on Load Model (it will load the Simulink model with JSBSim S-function block). You have to do this even if your Simulink model is already loaded
- In the GUI type into the aircraft model name
c172x - In the GUI click on Initialize Model It should output something like
JSBSim Flight Dynamics Model v1.0 Sep 6 2016 17:16:47[JSBSim-ML v2.0]JSBSim startup beginning ... - Now you can go to Simulink and run the simulation. You should get output like
JSBSim S-Function is initializing...then lots of text and then'c172x' Aircraft File has been successfully loaded! Simulation completed.That means that the model was loaded properly into JSBSim engine. - you can examine
toutandxoutvariables -xouthas 12 states ([u-fps v-fps w-fps p-radsec q-radsec r-radsec h-sl-ft long-gc-deg lat-gc-deg phi-rad theta-rad psi-rad] andtoutis simulation time. NOTE: this is what I have so far - the output is still zero, looks like the simulation is not being stepped through