13.5. Speedgoat QNX¶
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.
13.5.1. High-level interface¶
13.5.1.1. Instructions¶
The steps to deploy and simulate a FORCESPRO controller on a Speedgoat QNX platform are detailed below.
(Figure 13.87) Set the code generation options:
codeoptions.platform = 'Speedgoat-QNX'; % to specify the platform
codeoptions.printlevel = 0; % on some platforms printing is not supported
codeoptions.cleanup = 0; % to keep necessary files for target compile
and then generate the code for your solver (henceforth referred to as “FORCESNLPsolver”, placed in the folder “BasicExample”) using the high-level interface.
(Figure 13.88) Create a new Simulink model using the blank model template.
(Figure 13.89) Populate the Simulink model with the system you want to control.
(Figure 13.90) Make sure the
FORCESNLPsolver_simulinkBlock.mexw64
file (created during code generation) is on the MATLAB path.(Figure 13.91) Open the
FORCESNLPsolver_lib.mdl
Simulink model file, contained in theinterface
folder of theFORCESNLPsolver
folder created during code generation.(Figure 13.92) Copy-paste the FORCESPRO Simulink block into your simulation model and connect its inputs and outputs appropriately.
(Figure 13.93) Access the Simulink Model’s Settings.
(Figure 13.94) In the “Solver” tab, set the options:
Simulation start/stop time: Depending on the simulation wanted.
Solver type: Discrete or fixed-step.
Fixed-step size: Needs to be higher than the execution time of the solver.
(Figure 13.95) In the “Code Generation” tab, set the options:
System target file:
slrealtime.tlc
Generate makefile: Off
(Figure 13.96) In the “Code Generation/Custom Code” tab, include the directories:
BasicExample
BasicExample\FORCESNLPsolver\interface
BasicExample\FORCESNLPsolver\lib_target
(Figure 13.97) In the “Code Generation/Custom Code” tab, add the source files:
FORCESNLPsolver_simulinkBlock.c
FORCESNLPsolver_adtool2forces.c
FORCESNLPsolver_casadi.c
(Figure 13.98) In the “Code Generation/Custom Code” tab, add the library file:
libFORCESNLPsolver.a
(Figure 13.99) Access the FORCESPRO block’s parameters.
(Figure 13.100) Remove “FORCESNLPsolver” and “FORCESNLPsolver_simulinkBlock” from the S-function module.
(Figure 13.101) Compile the code of the Simulink model. This will also automatically load the model to the connected Speedgoat platform.
Deployment is complete and simulations can now be run on the Speedgoat platform.
13.5.1.2. Figures¶
![../../_images/speedgoat_qnx_highlevel_1.png](../../_images/speedgoat_qnx_highlevel_1.png)
Figure 13.87 Set the appropriate code generation options.¶
![../../_images/speedgoat_qnx_highlevel_2.png](../../_images/speedgoat_qnx_highlevel_2.png)
Figure 13.88 Create a Simulink model.¶
![../../_images/speedgoat_qnx_highlevel_3.png](../../_images/speedgoat_qnx_highlevel_3.png)
Figure 13.89 Populate the Simulink model.¶
![../../_images/speedgoat_qnx_highlevel_4.png](../../_images/speedgoat_qnx_highlevel_4.png)
Figure 13.90 Add the folder containing the .mexw64
solver file to the MATLAB path.¶
![../../_images/speedgoat_qnx_highlevel_5.png](../../_images/speedgoat_qnx_highlevel_5.png)
Figure 13.91 Open the generated Simulink solver model.¶
![../../_images/speedgoat_qnx_highlevel_6.png](../../_images/speedgoat_qnx_highlevel_6.png)
Figure 13.92 Copy-paste and connect the FORCESPRO block.¶
![../../_images/speedgoat_qnx_highlevel_7.png](../../_images/speedgoat_qnx_highlevel_7.png)
Figure 13.93 Open the Simulink Model Settings.¶
![../../_images/speedgoat_qnx_highlevel_8.png](../../_images/speedgoat_qnx_highlevel_8.png)
Figure 13.94 Set the Simulink solver options.¶
![../../_images/speedgoat_qnx_highlevel_9.png](../../_images/speedgoat_qnx_highlevel_9.png)
Figure 13.95 Set the Simulink code generation options.¶
![../../_images/speedgoat_qnx_highlevel_10.png](../../_images/speedgoat_qnx_highlevel_10.png)
Figure 13.96 Add the directories included for the code generation.¶
![../../_images/speedgoat_qnx_highlevel_11.png](../../_images/speedgoat_qnx_highlevel_11.png)
Figure 13.97 Add the source files used for the code generation.¶
![../../_images/speedgoat_qnx_highlevel_12.png](../../_images/speedgoat_qnx_highlevel_12.png)
Figure 13.98 Add the libraries used for the code generation.¶
![../../_images/speedgoat_qnx_highlevel_13.png](../../_images/speedgoat_qnx_highlevel_13.png)
Figure 13.99 Open the FORCESPRO block’s parameters.¶
![../../_images/speedgoat_qnx_highlevel_14.png](../../_images/speedgoat_qnx_highlevel_14.png)
Figure 13.100 Remove the default data from the S-function module.¶
![../../_images/speedgoat_qnx_highlevel_15.png](../../_images/speedgoat_qnx_highlevel_15.png)
Figure 13.101 Compile the code of the Simulink model.¶
13.5.2. Y2F interface¶
13.5.2.1. Instructions¶
The steps to deploy and simulate a FORCESPRO controller on a Speedgoat QNX platform are detailed below.
(Figure 13.102) Set the code generation options:
codeoptions.platform = 'Speedgoat-QNX'; % to specify the platform
codeoptions.printlevel = 0; % 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.
(Figure 13.103) Create a new Simulink model using the blank model template.
(Figure 13.104) Populate the Simulink model with the system you want to control.
(Figure 13.105) Make sure the
simplempc_solver_simulinkBlock.mexw64
file (created during code generation) is on the MATLAB path.(Figure 13.106) Copy-paste the FORCESPRO Simulink block, contained in the created
y2f_simulink_lib.slx
Simulink model file, into your simulation model and connect its inputs and outputs appropriately.(Figure 13.107) Access the Simulink Model’s Settings.
(Figure 13.108) In the “Solver” tab, set the options:
Simulation start/stop time: Depending on the simulation wanted.
Solver type: Discrete or fixed-step.
Fixed-step size: Needs to be higher than the execution time of the solver.
(Figure 13.109) In the “Code Generation/RTI general build options” tab, set the options:
System target file:
slrealtime.tlc
Generate makefile: Off
(Figure 13.110) In the “Code Generation/Custom Code” tab, include the directories:
Y2F
Y2F\simplempc_solver\interface
Y2F\simplempc_solver\lib_target
(Figure 13.111) In the “Code Generation/Custom Code” tab, add the source files:
simplempc_solver_simulinkBlock.c
simplempc_solver.c
(Figure 13.112) In the “Code Generation/Custom Code” tab, add the library file:
libinternal_simplempc_solver_1.a
(Figure 13.113) Compile the code of the Simulink model. This will also automatically load the model to the connected Speedgoat platform.
Deployment is complete and simulations can now be run on the Speedgoat platform.
13.5.2.2. Figures¶
![../../_images/speedgoat_qnx_y2f_1.png](../../_images/speedgoat_qnx_y2f_1.png)
Figure 13.102 Set the appropriate code generation options.¶
![../../_images/speedgoat_qnx_y2f_2.png](../../_images/speedgoat_qnx_y2f_2.png)
Figure 13.103 Create a Simulink model.¶
![../../_images/speedgoat_qnx_y2f_3.png](../../_images/speedgoat_qnx_y2f_3.png)
Figure 13.104 Populate the Simulink model.¶
![../../_images/speedgoat_qnx_y2f_4.png](../../_images/speedgoat_qnx_y2f_4.png)
Figure 13.105 Add the folder containing the .mexw64
solver file to the MATLAB path.¶
![../../_images/speedgoat_qnx_y2f_5.png](../../_images/speedgoat_qnx_y2f_5.png)
Figure 13.106 Copy-paste and connect the FORCESPRO block.¶
![../../_images/speedgoat_qnx_y2f_6.png](../../_images/speedgoat_qnx_y2f_6.png)
Figure 13.107 Open the Simulink Model Settings.¶
![../../_images/speedgoat_qnx_y2f_7.png](../../_images/speedgoat_qnx_y2f_7.png)
Figure 13.108 Set the Simulink solver options.¶
![../../_images/speedgoat_qnx_y2f_8.png](../../_images/speedgoat_qnx_y2f_8.png)
Figure 13.109 Set the Simulink code generation options.¶
![../../_images/speedgoat_qnx_y2f_9.png](../../_images/speedgoat_qnx_y2f_9.png)
Figure 13.110 Add the directories included for the code generation.¶
![../../_images/speedgoat_qnx_y2f_10.png](../../_images/speedgoat_qnx_y2f_10.png)
Figure 13.111 Add the source files used for the code generation.¶
![../../_images/speedgoat_qnx_y2f_11.png](../../_images/speedgoat_qnx_y2f_11.png)
Figure 13.112 Add the libraries used for the code generation.¶
![../../_images/speedgoat_qnx_y2f_12.png](../../_images/speedgoat_qnx_y2f_12.png)
Figure 13.113 Compile the code of the Simulink model.¶