Embedded Workflow#

On this page, we provide documentation of workflows to deploy acados on different embedded systems, as well as methods for adapting Simulink models for deployment.

We want to encourage you to contribute a description of the workflow to deploy acados on an embedded system that is not yet mentioned on this page by creating a pull request.

Additional information for some platforms not listed here can be found on the acados forum.

dSPACE platforms#

Here we present the workflow for cross-compilation of acados for several dSPACE platforms:

  • DS1202 (MicroLabBox I)

  • DS1401 (MicroAutoBox II)

  • DS1403 (MicroAutoBox III)

NOTE: In the following DSXXXX should be replaced with the ID for your specific platform (see above).

Prerequisites#

  • You were able to install acados and 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_code with your S-Functions, a make_sfun.m MATLAB script (and a make_sfun_sim.m script, 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 acados S-Functions yet, and you were able to compile it for your dSPACE Platform.

  • Your dSPACE installation, and your project folder, do not contain spaces in their paths (all the paths you will use in the next steps should not contain any spaces). It is usually sufficient to copy-paste the compiler folder to a new one without spaces in it, without re-installing the whole dSPACE software suite.

Cross-compiling acados#

Step 1: Adapt the existing CMake toolchain file for your system#

The CMake toolchain file, needed to cross-compile acados for the dSPACE 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. They are named Toolchain-dSPACE*.cmake (according to the platform IDs) and can be modified using any text editor. The lines that contain the paths to the compilers have to be adapted to fit your system.

DS1202#

The folder name which consists of a long number (e.g., 1184D92C-D928-4591-A1E9-B54339797C20) varies. On your system in C:/ProgramData/dSPACE/, find the folder which contains the directories /Compiler/QNX650_520/host/win32/x86/ and /Compiler/QNX650_520/target/qnx6/, and update the two paths in the toolchain file.

DS1401, DS1403#

The lines that contain the paths to the compilers (lines 1 - 17) have to be adapted to fit your system. It is possible to locate the correct compiler path from the Simulink dSPACE build output (e.g. building <dSPACE_Model_Name>.slx without acados S-Functions in it):

../_images/simulink_dspace_build_compiler_path.png

Depending on the compiler installed and used on your system, you may need to modify some options in the toolchain files (around line 55):

set(CMAKE_INCLUDE_FLAG_C "-J")   # for legacy compilers
set(CMAKE_INCLUDE_FLAG_CXX "-J")

For example, if using MinGW (gcc), change the option from -J to -I in the following:

set(CMAKE_INCLUDE_FLAG_C "-I")   # for gcc
set(CMAKE_INCLUDE_FLAG_CXX "-I")

Step 2: Define environment variables (required only for DS1202)#

  1. Define an environment variable (type env in 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_HOST and as the value, enter the path you set in the toolchain file earlier.

  2. Define an environment variable with the name QNX_TARGET and as the value, enter the path you set in the toolchain file earlier.

Step 3: 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 corresponding dSPACE platform. Using a toolchain CMake file, the following steps are needed in order to create the necessary files:

  1. Similar to the acados installation process, create a new folder buildDSXXXX in the acados root folder.

  2. In your PowerShell, navigate to this folder and then run (make sure to replace Toolchain-dSPACEDSXXXX with your platforms toolchain name): cmake -D CMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-dSPACEDSXXXX.cmake -G "Unix Makefiles" -D CMAKE_POLICY_VERSION_MINIMUM=3.5 -S ../ -B ./

  3. In order to cross-compile acados, run: cmake --build ./

  4. In order to install the cross-compiled acados version, run: cmake --install ./

If all these steps worked, you will find the two folders, lib and include, in buildDSXXXX/install. These are the folders you need to deploy acados on your dSPACE platform.

STM32 microcontrollers#

A workflow for prototyping and deploying an acados-based NMPC controller on an STM32 board is showcased in the acados-STM32-NUCLEO-H745ZI repository.

This workflow generates the problem specific code from MATLAB, which could similarly be done from Python. To deploy the controller a project is created using the STM32CubeIDE. Therein a list of required .c and .h files of the acados, BLASEO and HPIPM source code are defined to be compiled for the target. The workflow is tested using an STM32 NUCLEO H745ZIQ board. The workflow is expected to work with minimal adaptations for similar boards.