Skip to content

Commit

Permalink
Simulink integration (#445)
Browse files Browse the repository at this point in the history
Including interface files and S-function files to be able to run JSBSim from Simulink.
The setup files JSBSimSImulinkCompile and clearSF are also included.
A short readme files includes instructions on how to run it in Simulink.


Co-authored-by: Agostino De Marco <[email protected]>
Co-authored-by: Elia Tarasov <[email protected]>
Co-authored-by: Michal Podhradsky <[email protected]>
  • Loading branch information
4 people authored Jul 17, 2021
1 parent 889aab8 commit d5a7a71
Show file tree
Hide file tree
Showing 12 changed files with 1,618 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .github/workflows/cpp-python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,47 @@ jobs:
name: ManyLinux-Wheels.binaries
path: build/python/dist/*-manylinux*.whl

Matlab-SFunction-Linux:
name: Matlab S-Function (Linux)
needs: Linux
runs-on: ubuntu-latest
steps:
- name: Checkout JSBSim
uses: actions/checkout@v2
- name: Set up Matlab
uses: matlab-actions/setup-matlab@v1
with:
release: R2020b
- name: Configure JSBSim
run: |
mkdir build && cd build
cmake -DCMAKE_C_FLAGS_DEBUG="-g -Wall" -DCMAKE_CXX_FLAGS_DEBUG="-g -Wall" -DCMAKE_BUILD_TYPE=Debug -DBUILD_MATLAB_SFUNCTION=ON ..
- name: Build JSBSim S-Function
working-directory: build
run: cmake --build . --target JSBSim_SFunction -- -j2
- name: Prepare Tests
working-directory: matlab
# The script will be run from the directory 'matlab' so we need to link
# the folders that will be used by JSBSim
run: |
ln -s ../aircraft aircraft
ln -s ../engine engine
ln -s ../systems systems
ln -s ../scripts scripts
- name: Run Tests
uses: matlab-actions/run-command@v1
env:
# Force Matlab using the system libstdc++ rather than its own.
# See https://stackoverflow.com/questions/37921139/error-version-glibcxx-3-4-21-not-found
LD_PRELOAD: /lib/x86_64-linux-gnu/libstdc++.so.6
with:
command: addpath('build/matlab'), run('matlab/TestJSBSim.m')
- name: Upload Files for Release
uses: actions/upload-artifact@v2
with:
name: Matlab-SFunction.binaries
path: build/matlab/JSBSim_SFunction.mex*

Windows-MinGW32:
if: ${{ !startsWith(github.event.head_commit.message, '[skip ci]') || github.event_name == 'pull_request' }}
name: C/C++ build (MinGW32)
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ if(BUILD_JULIA_PACKAGE)
add_subdirectory(julia)
endif(BUILD_JULIA_PACKAGE)

################################################################################
# Build the Matlab S-Function #
################################################################################

option(BUILD_MATLAB_SFUNCTION "Set to ON to build the Matlab S-Function for JSBSim" OFF)

if(BUILD_MATLAB_SFUNCTION)
add_subdirectory(matlab)
endif(BUILD_MATLAB_SFUNCTION)

################################################################################
# Build the unit tests (needs CxxTest) #
################################################################################
Expand Down
8 changes: 8 additions & 0 deletions matlab/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
find_package(Matlab)

if(Matlab_FOUND)
matlab_add_mex(NAME JSBSim_SFunction SRC JSBSim_SFunction.cpp JSBSimInterface.cpp
LINK_TO libJSBSim)
target_include_directories(JSBSim_SFunction PUBLIC ${CMAKE_SOURCE_DIR}/src
${Matlab_ROOT_DIR}/simulink/include)
endif(Matlab_FOUND)
Loading

0 comments on commit d5a7a71

Please sign in to comment.