14.1. Main Targets¶
The most portable way of deploying a solver to any supported hardware platform is to write a C interface to the generated solver, and to compile it for the target platform. The C interface is described in section Calling a solver from C or C++, as well as the process to compile it and to link it against the solver library. This section describes aspects which are relevant for deployment.
The supported targets include:
x86 platforms
x86_64 platforms
32bit ARM-Cortex-A platforms
32bit ARM-Cortex-M platforms (no shared libraries)
64bit ARM-Cortex-A platforms (AARCH64 toolchain)
64bit ARM-Cortex-A platforms (Integrity toolchain)
NVIDIA platforms with ARM-Cortex-A processors
PowerPC platforms with GCC compiler
National Instruments compactRIO platforms with NILRT GCC compiler (Linux RTOS)
You can check here to find the correct naming option for each platform.
14.1.1. Deployment from Low-level or High-level Interface¶
The below steps hold generally for solver deployment but are exemplified for the examples Basic low-level example and Basic high-level example.
1. Set the code generation options in the Matlab or Python solver formulation as:
codeoptions.platform = '<platform_name>'; % to specify the platform
codeoptions.printlevel = 0; % optional, on some platforms printing is not supported
codeoptions.cleanup = 0; % to keep auxiliary source files (not needed for low-level interface)
codeoptions.platform = '<platform_name>' # to specify the platform
codeoptions.printlevel = 0 # optional, on some platforms printing is not supported
codeoptions.cleanup = 0 # to keep auxiliary source files (not needed for low-level interface)
and then generate the code for your solver (henceforth referred to as myFORCESsolver, placed in the folder BasicExample).
2. For most target platforms you will receive the following compiled files with your generated solver:
For MinGW/Linux/MacOS:
a static library file
libmyFORCESsolver.ainside the folderlib_targeta shared library file
libmyFORCESsolver.soinside the folderlib_target
For Windows:
a static library file
myFORCESsolver_static.libinside the folderlib_targeta dynamic library file
myFORCESsolver.dllwith its definition file for compilationmyFORCESsolver.libinside the folderlib_target
You need only one of those to build the solver.
Important
The shared library and the dynamic library if used for building need to be present during runtime as well.
3. Create an interface to call the solver (as described in C interface ) and perform a simulation/test.
You can find a standalone C code for this example here:
4. Copy to the target platform:
The
myFORCESsolverfolderThe interface from step 3
Any additional source files for external functions (does not apply to this example)
5. Compile the solver as described in Compiling solver executable .
Important
When deploying to a target hardware platform, the library included in the lib_target directory of the generated solver should be used instead of the library in the lib directory.
14.1.2. Deployment from Y2F interface¶
The steps to deploy and simulate a FORCESPRO controller on most targets are detailed below.
1. In the Y2F interface example mpc_basic_example.m set the code generation options:
codeoptions.platform = '<platform_name>'; % to specify the platform
codeoptions.printlevel = 0; % optional, on some platforms printing is not supported
and then generate the code for your solver (henceforth referred to as simpleMPC_solver, placed in the folder Y2F) using the Y2F interface.
2. The Y2F solver is composed of a main solver which calls multiple internal solvers. The file describing the main solver is:
simpleMPC_solver.cinside the folderinterface
3. The internal solvers are provided as compiled files. For most target platforms you will receive the following compiled files:
For MinGW/Linux/MacOS:
a static library file
libi_simpleMPC_solver_1.ainside the folderlib_targeta shared library file
libi_simpleMPC_solver_1.soinside the folderlib_target
For Windows:
a static library file
i_simpleMPC_solver_1_static.libinside the folderlib_targeta dynamic library file
i_simpleMPC_solver_1.dllwith its definition file for compilationi_simpleMPC_solver_1.libinside the folderlib_target
You need only one of those to build the solver.
Important
The shared library and the dynamic library if used for building need to be present during runtime as well.
4. Create an interface to call the solver and perform a simulation/test.
You can find a C interface for this example here.
5. Copy in the target platform:
The
simpleMPC_solverfolderThe interface from step 4
6. Compile the solver. The compilation command would be (supposing you are in the directory which contains the simpleMPC_solver folder):
<Compiler> Y2F_mpc_basic_example.c simpleMPC_solver/interface/simpleMPC_solver.c <solver library> <additional libraries>
Where the placeholders <Compiler>, <solver library> and <additional libraries>
are documented in Compiling solver executable.