On this page, we provide documentation of workflows to deploy
acados on different embedded systems.
Here, the workflow for the deployment of
acados on a dSPACE RCP Platform is described.
This has been successfully tested for the DS1202 MicroLabBox.
Other dSPACE platforms will probably require some adaptions of the workflow stated here.
you were able to install
acadosand dSPACE on your system
you were able to generate S-Functions with acados, which also work in your Simulink simulation
'Simulation_Model_Name'.slx. Thus, you have a folder
c_generated_codewith your S-Functions, a
make_sfun.mMatlab script (and a
make_sfun_sim.mscript, if needed) and the corresponding C files.
you have prepared a Simulink model with the name
'dSPACE_Model_Name'.slx, which does not contain the S-Functions yet and you were able to compile it for your dSPACE DS1202 (MicroLabBox) Platform. During the compilation process, the dSPACE Makefile
Step 1: Adapt the existing CMake toolchain file for your system¶
The CMake toolchain file, needed to cross-compile
acados for the dSPACE DS1202 Platform contains paths to compilers, provided in the dSPACE installation.
As the dSPACE installation varies from system to system, this toolchain file first has to be adapted.
The Toolchain files are located in
'acados_root_folder'/cmake. The toolchain file for the MicroLabBox is called
Toolchain-dSpaceDS1202.cmakeand can be edited with any editor.
The lines that contain the path to the host and target compiler have to be adapted to fit your system. Specifically, the folder name which consists of a long number (here: 1184D92C-D928-4591-A1E9-B54339797C20) varies. On your system in
C:/ProgramData/dSPACE/, find the folder which contains the directories
/Compiler/QNX650_520/target/qnx6/, and update the two paths in the toolchain file.
Define an environment variable (type
envin the windows search bar and open
Edit the windows environment variables. There, click
Environment Variables...and create a new entry for your user) with the name
QNX_HOSTand as the value, enter the path you set before in the toolchain file.
Define an environment variable with the name
QNX_TARGETand as the value, enter the path you set before in the toolchain file.
Step 2: Cross-compile
acados for your dSPACE platform¶
In order to compile
acados for your dSPACE platform, you need the
acados libraries and header files in the correct format.
These files can be created by cross-compiling the
acados source code for the correponding dSPACE platform.
Using a toolchain CMake file, the following steps are needed in order to create the necessary files:
Similar to the
acadosinstallation process, create a new folder
In your terminal, navigate to this folder and then run:
cmake -D CMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-dSPACEDS1202.cmake -G "Unix Makefiles" -S ../ -B ./
In order to cross-compile acados, run:
cmake --build ./
In order to install the cross-compiled
cmake --install ./If all these steps worked, you will find the two folders
buildDS1202/install. These are the folders you need to deploy
acadoson your dSPACE Platform.
Step 4: Adapt the dSPACE Makefile¶
Adapt the dSPACE Makefile in order to include the
acados headers, libraries and additional C code source files.
acadosS-Function(s) are based on C code source files. These files are listed as
SOURCESin the Matlab script
make_sfun_sim.mif the simulation S-Function is used too). Open the dSPACE Makefile
'dSPACE_Model_Name'_usr.mkand list all source files needed for the S-Functions, except for the ones which have the same name as the S-Functions.
If the sources listed in
make_sfun.m(solver S-Function name: acados_solver_sfunction_OCPModelName) read as:
SOURCES = [ ... 'OCPModelName_model/OCPModelName_expl_ode_fun.c ', ... 'OCPModelName_model/OCPModelName_expl_vde_forw.c ',... 'acados_solver_sfunction_OCPModelName.c ', ... 'acados_solver_OCPModelName.c ' ];
and the Sources listed in
make_sfun_sim.m(sim S-Function name: acados_sim_solver_sfunction_OCPModelName) are:
SOURCES = [ 'acados_sim_solver_sfunction_OCPModelName.c ', ... 'acados_sim_solver_OCPModelName.c ', ... 'OCPModelName_model/OCPModelName_expl_ode_fun.c ', ... 'OCPModelName_model/OCPModelName_expl_vde_forw.c ',... ];
The entry in the dSPACE Makefile should read as:
# Additional C source files to be compiled (file name extension .c). USER_SRCS = \ OCPModelName_expl_ode_fun.c \ OCPModelName_expl_vde_forw.c \ acados_solver_OCPModelName.c \ acados_sim_solver_OCPModelName.c
Define the (relative) paths to the S-Functions and the C code source files in the dSPACE Makefile. These are the folder
c_generated_codeand any subfolder which contains C code source files, which were identified in the previous step. For the example in the previous step the entry in the dSPACE Makefile would look like this:
# Directories where S-Function C source files are stored. SFCN_DIR = \ "\c_generated_code" \ "\c_generated_code\OCPModelName_model"
Define the (relative) paths to the
acadosheader files in the dSPACE Makefile. With hpipm as a solver, this looks as follows:
# Path names for user include files. USER_INCLUDES_PATH = \ "include" \ "include\blasfeo\include" \ "include\hpipm\include"
Define the libraries needed to compile the S-Functions. With hpipm as a solver, this looks as follows:
# Additional user libraries to be linked. USER_LIBS = \ lib\libblasfeo.a \ lib\libhpipm.a \ lib\libacados.a
Save the dSPACE Makefile.