Using ACADOS generated S-Function for Simulink Desktop Real-Time and Simulink Real-Time (via Speedgoat))

Hi all :smiley:!

Thanks for this awesome toolkit! I really like acados!

Recently, I am having some trouble using the acados generated S_Function with Simulink desktop-realtime and Simulink real-time (via Speedgoat). There’s a similar post (post one) (by theshadow) asking how to use acados generated S-Function for Simulink Desktop Realtime, since no one replied to that post, I am starting a new one here with more details.

Environment Setup:

  • The computer I’m using have Windows 10 64bits installed, with AMD Ryzen 7 2700X CPU
  • Visual Studios 2017 Professional and 2019 Community are installed properly
  • I followed the tutorial on the docs and built the acados for Window using minGW. I then tested the examples shown in “acados\examples\acados_matlab_octave\getting_started”, all of them worked perfectly with no issues. The Simulink file was also executed correctly with no warning and error (In this case, Matlab is using minGW 64).

Bug:

  • Once I tested that I installed the acados correctly and tutorial files run with no trouble, I started implementing the Simulink file “simulink_model_closed_loop.slx” under Simulink Desktop Realtime mode. To do so, I did the following: In Simulink click “Model Settings”->Code Generation->System Target File->Change the target file to “Simulink Desktop Realtime” (sldrt.tlc)
  • After the previous step, I ran the model and received the following error:
=== Simulation (Elapsed: 9 sec) ===
    ### Generating code and artifacts to 'Model specific' folder structure
    ### Generating code into build folder: G:\Dropbox\TriplePendulumDesign\Simulink\RealTimeTargetMachine\DoublePendulum\7_acados\acados\examples\acados_matlab_octave\getting_started\c_generated_code\simulink_model_closed_loop_sldrt_win64
    ### Invoking Target Language Compiler on simulink_model_closed_loop.rtw
    ### Using System Target File: C:\Program Files\MATLAB\R2021a\toolbox\sldrt\rtw\sldrt.tlc
    ### Loading TLC function libraries
    ......
    ### Initial pass through model to cache user defined code
    ..
    ### Caching model source code
    ............................
        ### Writing source file simulink_model_closed_loop_tgtconn.c
    ......................................
        ### Writing header file simulink_model_closed_loop_types.h
        ### Writing header file simulink_model_closed_loop.h
        ### Writing source file simulink_model_closed_loop.c
        ### Writing header file rtwtypes.h
        ### Writing header file multiword_types.h
    .
        ### Writing header file zero_crossing_types.h
        ### Writing header file simulink_model_closed_loop_private.h
        ### Writing header file rtmodel.h
        ### Writing source file simulink_model_closed_loop_data.c
        ### Writing header file rt_nonfinite.h
        ### Writing source file rt_nonfinite.c
    .
        ### Writing header file rt_defines.h
        ### Writing header file rtGetInf.h
        ### Writing source file rtGetInf.c
        ### Writing header file rtGetNaN.h
        ### Writing source file rtGetNaN.c
      ### TLC code generation complete.
    ### Generating TLC interface API.
    ................
    ### Creating data type transition file simulink_model_closed_loop_dt.h
    .
    ### Processing Template Makefile: C:\Program Files\MATLAB\R2021a\toolbox\sldrt\rtw\sldrt.tmf
    ### Created makefile G:\Dropbox\TriplePendulumDesign\Simulink\RealTimeTargetMachine\DoublePendulum\7_acados\acados\examples\acados_matlab_octave\getting_started\c_generated_code\simulink_model_closed_loop_sldrt_win64\simulink_model_closed_loop.mk
    ### Building simulink_model_closed_loop: .\simulink_model_closed_loop.bat
    . 
    G:\Dropbox\TriplePendulumDesign\Simulink\RealTimeTargetMachine\DoublePendulum\7_acados\acados\examples\acados_matlab_octave\getting_started\c_generated_code\simulink_model_closed_loop_sldrt_win64>set MATLAB=C:\Program Files\MATLAB\R2021a  
     
    G:\Dropbox\TriplePendulumDesign\Simulink\RealTimeTargetMachine\DoublePendulum\7_acados\acados\examples\acados_matlab_octave\getting_started\c_generated_code\simulink_model_closed_loop_sldrt_win64>"C:\Program Files\MATLAB\R2021a\bin\win64\gmake" -f simulink_model_closed_loop.mk  EXTMODE_STATIC_ALLOC=0 EXTMODE_STATIC_ALLOC_SIZE=1000000 TMW_EXTMODE_TESTING=0 COMBINE_OUTPUT_UPDATE_FCNS=0 INCLUDE_MDL_TERMINATE_FCN=1 MULTI_INSTANCE_CODE=0 OPTS="-DTGTCONN -DEXT_MODE -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0"  
    ### Compiling simulink_model_closed_loop.c 
    C:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/clang/win64/clang -emit-llvm -c -m64 -O4 -DINT64_T="long long" -DUINT64_T="unsigned long long" -fno-ms-compatibility -U_MSC_VER -U__STDC_HOSTED__ -Wno-switch-enum -Wno-empty-body -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/lib/include  -I. -I.. -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common  -IC:/PROGRA~1/MATLAB/R2021a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/src  -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code/simulink_model_closed_loop_sldrt_win64 -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2021a/toolbox/coder/rtiostream/src  -DTGTCONN -DEXT_MODE -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0 -DEXT_MODE  -DUSE_RTMODEL -DMODEL=simulink_model_closed_loop -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0  -DHAVESTDIO -o "simulink_model_closed_loop.obj" "simulink_model_closed_loop.c" 
    ### Compiling C:/PROGRA~1/MATLAB/R2021a/rtw/c/src/rt_matrx.c 
    C:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/clang/win64/clang -emit-llvm -c -m64 -O4 -DINT64_T="long long" -DUINT64_T="unsigned long long" -fno-ms-compatibility -U_MSC_VER -U__STDC_HOSTED__ -Wno-switch-enum -Wno-empty-body -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/lib/include  -I. -I.. -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common  -IC:/PROGRA~1/MATLAB/R2021a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/src  -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code/simulink_model_closed_loop_sldrt_win64 -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2021a/toolbox/coder/rtiostream/src  -DTGTCONN -DEXT_MODE -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0 -DEXT_MODE  -DUSE_RTMODEL -DMODEL=simulink_model_closed_loop -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0  -DHAVESTDIO -o "rt_matrx.obj" "C:/PROGRA~1/MATLAB/R2021a/rtw/c/src/rt_matrx.c" 
    ### Compiling C:/PROGRA~1/MATLAB/R2021a/rtw/c/src/rt_printf.c 
    C:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/clang/win64/clang -emit-llvm -c -m64 -O4 -DINT64_T="long long" -DUINT64_T="unsigned long long" -fno-ms-compatibility -U_MSC_VER -U__STDC_HOSTED__ -Wno-switch-enum -Wno-empty-body -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/lib/include  -I. -I.. -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common  -IC:/PROGRA~1/MATLAB/R2021a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/src  -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code/simulink_model_closed_loop_sldrt_win64 -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2021a/toolbox/coder/rtiostream/src  -DTGTCONN -DEXT_MODE -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0 -DEXT_MODE  -DUSE_RTMODEL -DMODEL=simulink_model_closed_loop -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0  -DHAVESTDIO -o "rt_printf.obj" "C:/PROGRA~1/MATLAB/R2021a/rtw/c/src/rt_printf.c" 
    ### Compiling rtGetInf.c 
    C:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/clang/win64/clang -emit-llvm -c -m64 -O4 -DINT64_T="long long" -DUINT64_T="unsigned long long" -fno-ms-compatibility -U_MSC_VER -U__STDC_HOSTED__ -Wno-switch-enum -Wno-empty-body -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/lib/include  -I. -I.. -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common  -IC:/PROGRA~1/MATLAB/R2021a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/src  -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code/simulink_model_closed_loop_sldrt_win64 -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2021a/toolbox/coder/rtiostream/src  -DTGTCONN -DEXT_MODE -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0 -DEXT_MODE  -DUSE_RTMODEL -DMODEL=simulink_model_closed_loop -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0  -DHAVESTDIO -o "rtGetInf.obj" "rtGetInf.c" 
    ### Compiling rtGetNaN.c 
    C:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/clang/win64/clang -emit-llvm -c -m64 -O4 -DINT64_T="long long" -DUINT64_T="unsigned long long" -fno-ms-compatibility -U_MSC_VER -U__STDC_HOSTED__ -Wno-switch-enum -Wno-empty-body -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/lib/include  -I. -I.. -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common  -IC:/PROGRA~1/MATLAB/R2021a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/src  -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code/simulink_model_closed_loop_sldrt_win64 -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2021a/toolbox/coder/rtiostream/src  -DTGTCONN -DEXT_MODE -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0 -DEXT_MODE  -DUSE_RTMODEL -DMODEL=simulink_model_closed_loop -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0  -DHAVESTDIO -o "rtGetNaN.obj" "rtGetNaN.c" 
    ### Compiling rt_nonfinite.c 
    C:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/clang/win64/clang -emit-llvm -c -m64 -O4 -DINT64_T="long long" -DUINT64_T="unsigned long long" -fno-ms-compatibility -U_MSC_VER -U__STDC_HOSTED__ -Wno-switch-enum -Wno-empty-body -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/lib/include  -I. -I.. -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common  -IC:/PROGRA~1/MATLAB/R2021a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/src  -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code/simulink_model_closed_loop_sldrt_win64 -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2021a/toolbox/coder/rtiostream/src  -DTGTCONN -DEXT_MODE -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0 -DEXT_MODE  -DUSE_RTMODEL -DMODEL=simulink_model_closed_loop -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0  -DHAVESTDIO -o "rt_nonfinite.obj" "rt_nonfinite.c" 
    ### Compiling simulink_model_closed_loop_data.c 
    C:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/clang/win64/clang -emit-llvm -c -m64 -O4 -DINT64_T="long long" -DUINT64_T="unsigned long long" -fno-ms-compatibility -U_MSC_VER -U__STDC_HOSTED__ -Wno-switch-enum -Wno-empty-body -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/lib/include  -I. -I.. -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common  -IC:/PROGRA~1/MATLAB/R2021a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/src  -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code/simulink_model_closed_loop_sldrt_win64 -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2021a/toolbox/coder/rtiostream/src  -DTGTCONN -DEXT_MODE -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0 -DEXT_MODE  -DUSE_RTMODEL -DMODEL=simulink_model_closed_loop -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0  -DHAVESTDIO -o "simulink_model_closed_loop_data.obj" "simulink_model_closed_loop_data.c" 
    ### Compiling simulink_model_closed_loop_tgtconn.c 
    C:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/clang/win64/clang -emit-llvm -c -m64 -O4 -DINT64_T="long long" -DUINT64_T="unsigned long long" -fno-ms-compatibility -U_MSC_VER -U__STDC_HOSTED__ -Wno-switch-enum -Wno-empty-body -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/lib/include  -I. -I.. -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common  -IC:/PROGRA~1/MATLAB/R2021a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/src  -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code/simulink_model_closed_loop_sldrt_win64 -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2021a/toolbox/coder/rtiostream/src  -DTGTCONN -DEXT_MODE -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0 -DEXT_MODE  -DUSE_RTMODEL -DMODEL=simulink_model_closed_loop -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0  -DHAVESTDIO -o "simulink_model_closed_loop_tgtconn.obj" "simulink_model_closed_loop_tgtconn.c" 
    ### Compiling ../acados_sim_solver_sfunction_pendulum.c 
    C:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/clang/win64/clang -emit-llvm -c -m64 -O4 -DINT64_T="long long" -DUINT64_T="unsigned long long" -fno-ms-compatibility -U_MSC_VER -U__STDC_HOSTED__ -Wno-switch-enum -Wno-empty-body -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/lib/include  -I. -I.. -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common  -IC:/PROGRA~1/MATLAB/R2021a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/src  -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code/simulink_model_closed_loop_sldrt_win64 -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2021a/toolbox/coder/rtiostream/src  -DTGTCONN -DEXT_MODE -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0 -DEXT_MODE  -DUSE_RTMODEL -DMODEL=simulink_model_closed_loop -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0  -DHAVESTDIO -o "acados_sim_solver_sfunction_pendulum.obj" "../acados_sim_solver_sfunction_pendulum.c" 
    ../acados_sim_solver_sfunction_pendulum.c:40:10: fatal error: 'acados/utils/print.h' file not found
    #include "acados/utils/print.h"
             ^
    1 error generated.
    gmake: *** [acados_sim_solver_sfunction_pendulum.obj] Error 1
    Top model targets built:
    
    Model                       Action  Rebuild Reason                                    
    ======================================================================================
    simulink_model_closed_loop  Failed  Code generation information file does not exist.  
    
    0 of 1 models built (0 models already up to date)
    Build duration: 0h 0m 9.1430e+00s
    Error:Error(s) encountered while building "simulink_model_closed_loop"

This same error also occurred when I implement this Simulink file on the Speedgoat machine by setting the target file to “Simulink Realtime (slrealtime.tlc)”

What I tried to fix this problem:

  • According to these two posts (post two, post three) (by awischnewski, by Freddy), it seems like that we need to use Visual Studio 2017 to build the acados in order to make it run on Speedgoat and Simulink Desktop Real-time. So I followed post three and correctly built the acados using VS 2017 (acados is built using the following command):
cmake.exe -G "Visual Studio 15 2017 Win64" -D BLASFEO_TARGET=GENERIC -D HPIPM_TARGET=GENERIC -DACADOS_INSTALL_DIR="$ACADOS_INSTALL_DIR" -DBUILD_SHARED_LIBS=OFF -DACADOS_WITH_OSQP=ON ..
msbuild INSTALL.vcxpro
  • The build process is successful with no errors (warnings only). To further test out whether acados is built correctly, I tried out all the examples in the “acados\examples\acados_matlab_octave\getting_started” folders, and all of them executed correctly, including the “simulink_model_closed_loop.slx” file (This time the Matlab MEX setup is configured to use VS 2017).
  • Next, I followed the same process, and changed the target file to “sldrt.tlc” in order to run the code in Simulink Desktop Real-time mode, and changed the target file into “slrealtime.tlc” to run it on the Speedgoat machine. However, even with building acados using VS 2017, I still got the same error shown before, suggesting the header file “print.h” can’t be found.

What I did next:

  • I tried manually adding the “print.h” file into the code generation process using following approach: Simulink->Model Settings->Code Generation->Custom Code->Header File, and it looks like the following.

  • After I ran the Simulink with manually adding the header file, I got the following error which I do not know how to fix:

=== Simulation (Elapsed: 5 sec) ===
    ### Generating code and artifacts to 'Model specific' folder structure
    ### Generating code into build folder: G:\Dropbox\TriplePendulumDesign\Simulink\RealTimeTargetMachine\DoublePendulum\7_acados\acados\examples\acados_matlab_octave\getting_started\c_generated_code\simulink_model_closed_loop_sldrt_win64
    ### Invoking Target Language Compiler on simulink_model_closed_loop.rtw
    ### Using System Target File: C:\Program Files\MATLAB\R2021a\toolbox\sldrt\rtw\sldrt.tlc
    ### Loading TLC function libraries
    ......
    ### Initial pass through model to cache user defined code
    ..
    ### Caching model source code
    ............................
        ### Writing source file simulink_model_closed_loop_tgtconn.c
    ......................................
        ### Writing header file simulink_model_closed_loop_types.h
        ### Writing header file simulink_model_closed_loop.h
        ### Writing source file simulink_model_closed_loop.c
        ### Writing header file rtwtypes.h
        ### Writing header file multiword_types.h
    .
        ### Writing header file zero_crossing_types.h
        ### Writing header file simulink_model_closed_loop_private.h
        ### Writing header file rtmodel.h
        ### Writing source file simulink_model_closed_loop_data.c
        ### Writing header file rt_nonfinite.h
        ### Writing source file rt_nonfinite.c
    .
        ### Writing header file rt_defines.h
        ### Writing header file rtGetInf.h
        ### Writing source file rtGetInf.c
        ### Writing header file rtGetNaN.h
        ### Writing source file rtGetNaN.c
      ### TLC code generation complete.
    ### Generating TLC interface API.
    ................
    ### Creating data type transition file simulink_model_closed_loop_dt.h
    .
    ### Processing Template Makefile: C:\Program Files\MATLAB\R2021a\toolbox\sldrt\rtw\sldrt.tmf
    ### Created makefile G:\Dropbox\TriplePendulumDesign\Simulink\RealTimeTargetMachine\DoublePendulum\7_acados\acados\examples\acados_matlab_octave\getting_started\c_generated_code\simulink_model_closed_loop_sldrt_win64\simulink_model_closed_loop.mk
    ### Building simulink_model_closed_loop: .\simulink_model_closed_loop.bat
    . 
    G:\Dropbox\TriplePendulumDesign\Simulink\RealTimeTargetMachine\DoublePendulum\7_acados\acados\examples\acados_matlab_octave\getting_started\c_generated_code\simulink_model_closed_loop_sldrt_win64>set MATLAB=C:\Program Files\MATLAB\R2021a  
     
    G:\Dropbox\TriplePendulumDesign\Simulink\RealTimeTargetMachine\DoublePendulum\7_acados\acados\examples\acados_matlab_octave\getting_started\c_generated_code\simulink_model_closed_loop_sldrt_win64>"C:\Program Files\MATLAB\R2021a\bin\win64\gmake" -f simulink_model_closed_loop.mk  EXTMODE_STATIC_ALLOC=0 EXTMODE_STATIC_ALLOC_SIZE=1000000 TMW_EXTMODE_TESTING=0 COMBINE_OUTPUT_UPDATE_FCNS=0 INCLUDE_MDL_TERMINATE_FCN=1 MULTI_INSTANCE_CODE=0 OPTS="-DTGTCONN -DEXT_MODE -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0"  
    ### Compiling simulink_model_closed_loop.c 
    C:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/clang/win64/clang -emit-llvm -c -m64 -O4 -DINT64_T="long long" -DUINT64_T="unsigned long long" -fno-ms-compatibility -U_MSC_VER -U__STDC_HOSTED__ -Wno-switch-enum -Wno-empty-body -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/lib/include  -I. -I.. -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common  -IC:/PROGRA~1/MATLAB/R2021a/toolbox/shared/can/src/scanutil -IC:/PROGRA~1/MATLAB/R2021a/toolbox/sldrt/src  -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code -IG:/Dropbox/TriplePendulumDesign/Simulink/RealTimeTargetMachine/DoublePendulum/7_acados/acados/examples/acados_matlab_octave/getting_started/c_generated_code/simulink_model_closed_loop_sldrt_win64 -IC:/PROGRA~1/MATLAB/R2021a/extern/include -IC:/PROGRA~1/MATLAB/R2021a/simulink/include -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2021a/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2021a/toolbox/coder/rtiostream/src  -DTGTCONN -DEXT_MODE -DON_TARGET_WAIT_FOR_START=1 -DTID01EQ=0 -DEXT_MODE  -DUSE_RTMODEL -DMODEL=simulink_model_closed_loop -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DMT=0  -DHAVESTDIO -o "simulink_model_closed_loop.obj" "simulink_model_closed_loop.c" 
    In file included from simulink_model_closed_loop.c:21:
    ./simulink_model_closed_loop.h:855:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
    G:
    ^
    ./simulink_model_closed_loop.h:855:2: error: expected ';' after top level declarator
    G:
     ^
     ;
    ./simulink_model_closed_loop.h:857:1: error: expected identifier or '('
    \Dropbox\TriplePendulumDesign\Simulink\RealTimeTargetMachine\DoublePendulum\7
    ^
    ./simulink_model_closed_loop.h:874:3: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
    } B_simulink_model_closed_loop_T;
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ./simulink_model_closed_loop.h:1094:8: error: unknown type name 'B_simulink_model_closed_loop_T'; did you mean 'P_simulink_model_closed_loop_T'?
    extern B_simulink_model_closed_loop_T simulink_model_closed_loop_B;
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           P_simulink_model_closed_loop_T
    ./simulink_model_closed_loop_types.h:30:48: note: 'P_simulink_model_closed_loop_T' declared here
    typedef struct P_simulink_model_closed_loop_T_ P_simulink_model_closed_loop_T;
                                                   ^
    In file included from simulink_model_closed_loop.c:23:
    ./simulink_model_closed_loop_dt.h:61:46: error: no member named 'x' in 'struct P_simulink_model_closed_loop_T_'
      { (char_T *)(&simulink_model_closed_loop_B.x[0]), 0, 0, 161 }
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:32:1: error: unknown type name 'B_simulink_model_closed_loop_T'; did you mean 'P_simulink_model_closed_loop_T'?
    B_simulink_model_closed_loop_T simulink_model_closed_loop_B;
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    P_simulink_model_closed_loop_T
    ./simulink_model_closed_loop_types.h:30:48: note: 'P_simulink_model_closed_loop_T' declared here
    typedef struct P_simulink_model_closed_loop_T_ P_simulink_model_closed_loop_T;
                                                   ^
    simulink_model_closed_loop.c:48:32: error: no member named 'x' in 'struct P_simulink_model_closed_loop_T_'
      simulink_model_closed_loop_B.x[0] =
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:50:32: error: no member named 'x' in 'struct P_simulink_model_closed_loop_T_'
      simulink_model_closed_loop_B.x[1] =
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:52:32: error: no member named 'x' in 'struct P_simulink_model_closed_loop_T_'
      simulink_model_closed_loop_B.x[2] =
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:54:32: error: no member named 'x' in 'struct P_simulink_model_closed_loop_T_'
      simulink_model_closed_loop_B.x[3] =
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:58:34: error: no member named 'y_ref_0' in 'struct P_simulink_model_closed_loop_T_'
        simulink_model_closed_loop_B.y_ref_0[i] =
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:63:40: error: no member named 'y_ref0' in 'struct P_simulink_model_closed_loop_T_'
      memcpy(&simulink_model_closed_loop_B.y_ref0[0],
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:67:32: error: no member named 'y_ref_e0' in 'struct P_simulink_model_closed_loop_T_'
      simulink_model_closed_loop_B.y_ref_e0[0] =
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:69:32: error: no member named 'y_ref_e0' in 'struct P_simulink_model_closed_loop_T_'
      simulink_model_closed_loop_B.y_ref_e0[1] =
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:71:32: error: no member named 'y_ref_e0' in 'struct P_simulink_model_closed_loop_T_'
      simulink_model_closed_loop_B.y_ref_e0[2] =
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:73:32: error: no member named 'y_ref_e0' in 'struct P_simulink_model_closed_loop_T_'
      simulink_model_closed_loop_B.y_ref_e0[3] =
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:77:34: error: no member named 'lbu' in 'struct P_simulink_model_closed_loop_T_'
        simulink_model_closed_loop_B.lbu[i] = -simulink_model_closed_loop_P.U_max;
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:80:34: error: no member named 'ubu' in 'struct P_simulink_model_closed_loop_T_'
        simulink_model_closed_loop_B.ubu[i] = simulink_model_closed_loop_P.U_max;
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:95:59: error: no member named 'u' in 'struct P_simulink_model_closed_loop_T_'
          void *pData = (void *)&simulink_model_closed_loop_B.u;
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    simulink_model_closed_loop.c:115:34: error: no member named 'x_g' in 'struct P_simulink_model_closed_loop_T_'
        simulink_model_closed_loop_B.x_g[0];
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    2 warnings and 20 errors generated.
    gmake: *** [simulink_model_closed_loop.obj] Error 1
    Top model targets built:
    
    Model                       Action  Rebuild Reason                                    
    ======================================================================================
    simulink_model_closed_loop  Failed  Code generation information file does not exist.  
    
    0 of 1 models built (0 models already up to date)
    Build duration: 0h 0m 4.9350e+00s
    Error:Error(s) encountered while building "simulink_model_closed_loop"

Related Error in the Forum:

  • The problem of being unable to identify “print.h” is also mentioned in post four (by AaronKLR) but I did not find out “usr.mk” file, and I’m only able to find out “simulink_model_closed_loop.mk” file. Moreover, in the later file I did not find out “USER_SRCS_DIR” and “USER_INCLUDES_PATH” variables.
  • In post five (by AlexWin), also had a similar problem, and giaf suggested modifying the “Makefile.rule” by setting “EXT_DEP = 0”. My question regarding this is should we change the EXT_DEP to zero then rebuild acados again in order to avoid the unidentified header error?

Questions:

  • May I know what am I doing wrong here?
  • May I know why the header file can not be identified and how to fix it?
  • May I know if there are more detailed tutorials for how to use acados on Simulink Real-time (via Speedgoat) and Simulink Desktop Real-time? (This should be possible since @awischnewski mentioned it in his/her post)

Any help is appreciated and it would be awesome if we can implement acados in Simulink Real-time (via Speedgoat) and Simulink Desktop Real-time! Thanks! :grinning:

Since I’m new user, I can not include more than two links and @ more than two users in the post, so all the links of post one to five are summarized here (please include “discourse.acados.org/t/” before the link):
post one: simulink-desktop-real-time/543
post two: build-issues-with-visual-studio-for-latest-releases-of-acados/208
post three: visual-c-support-in-matlab-simulink/134
post four: nmpc-in-simulink-on-dspace-error-cant-open-random-source-files-h/315
post five: s-function-fails-simulink-compile-check/181/8

1 Like

Hi,

thanks for your post!

That is unfortunate. I would appreciate if all people would search for related issues that well :slight_smile:

For completeness, the post list with links:
post one: Simulink Desktop Real Time - User Questions - acados forum
post two: Build issues with visual studio for latest releases of acados - User Questions - acados forum
post three: Visual C support in Matlab/Simulink - Feature Requests - acados forum
post four: NMPC in Simulink / on dSpace Error: Can't open random_source_files.h - User Questions - acados forum
post five: S-Function fails Simulink Compile Check - #8 by AlexWin - User Questions - acados forum

Good that you fixed the include error for now.
I think actually, this file shouldn’t be included in the Sfuncitons anyway, and I will remove it from there soon.
The other includes should not require you to add this path.

For the second error:
I unfortunately don’t know what kind of file this is, but it is not generated by acados.
I hope someone else can help you with that!

Best,
Jonathan

Hi Jonathan,

Thanks for your reply! I really appreciate that you inserted the link for me, thank you!

I’ll do the following and see whether it will help:

  • I’ll manually exclude the “print.h” file from “acados_sim_solver_sfunction_pendulum.c” and see whether it will help since it is not required by S-Function

I’ll post an update after I tried it out.

Meanwhile, I hope @awischnewski @Freddy can see this post since they already tested acados on Speedgoat machines, it would be great to hear back from them.

I’m also trying to compile the model into speedgoat, but in the process it appears that the acads.lib is not recognized, I tried to use AlexWin’s method but it didn’t go well, what’s your progress now?

1 Like