Skip to content

Commit

Permalink
Check the S-Function build with GitHub Actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoconni committed Jun 19, 2021
1 parent f50e2e2 commit d0cf1e2
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 10 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/cpp-python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,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)
6 changes: 6 additions & 0 deletions matlab/TestJSBSim.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
disp('Run 737 example');
fprintf('Current directory: %s', pwd)
sim('ex737cruise');
clear functions;
clear all;
disp('JSBSim S-Function Reset');
20 changes: 10 additions & 10 deletions matlab/readme.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Short instruction to how to use the S-function to integrate JSBSim with Simulink
Short instruction to how to use the S-function to integrate JSBSim with Simulink

1. Build and install JSBSim.
2. Open Matlab and navigate to the JSBSim folder.
3. Open JSBSimSimulinkCompile and uncomment either the Linux or Windows mex row.
4. Run JSBSimSimulinkCompile in the Matlab command window. Note that the compiler needed is gcc8.
5. Open the Simulink example ex737cruise.slx and press run.
6. Once the simulation is completed, run the clearSF.m file before running the Simulink program again.
1. Build and install JSBSim.
2. Open Matlab and navigate to the JSBSim folder.
3. Open JSBSimSimulinkCompile and uncomment either the Linux or Windows mex row.
4. Run JSBSimSimulinkCompile in the Matlab command window. Note that the compiler needed is gcc8.
5. Open the Simulink example ex737cruise.slx and press run.
6. Once the simulation is completed, run the clearSF.m file before running the Simulink program again.



NOTE:
* clearSF.m needs to be run after each Simulation.
NOTE:
* clearSF.m needs to be run after each Simulation.
* The simulation can either be run from a script or from input from Simulink.

0 comments on commit d0cf1e2

Please sign in to comment.