NOTE: This repo is archived now, as this functionality has been merged to JSBSim - see https://github.com/JSBSim-Team/jsbsim/tree/master/matlab
Matlab integration of JSBSim based on work of EliaTarasov
Compiled and tested on for Linux (Ubuntu).
- Type
git submodule init
andgit 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
JSBSim
directoryand make sure you are onmatlab_integration
branch - 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.m
ortest_c172_cruise_8K.m
or 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 -lJSBSim
It 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
tout
andxout
variables -xout
has 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] andtout
is simulation time. NOTE: this is what I have so far - the output is still zero, looks like the simulation is not being stepped through