Simulink parameter input query

Hi,

I am a beginner and am learning acados, switching from acado, for my project. I am working on MATLAB and using the Simulink interface to simulate my problem. My system has a 1 parameter ‘p’ in the model whose values are obtained from a function defined in Simulink. This parameter is taken as input to the solver block in Simulink.

  • The parameter is given as a column array with 1 value per time step of size Np+1 to the solver block.
  • When I set this parameter to zero, the solver runs fine and gives me a status 0. However, when values are provided, the solver gives a status 4.
  • The ‘partial_condensing_hpipm’ solver is used. When I change it to ‘full_condensing_hpipm’, MATLAB crashes. When I select ‘full_condensing_qpoases’, it gives the following error.
ocp_create: field qp_solver does not support full_condensing_qpoases, supported values are:
partial_condensing_hpipm, full_condensing_hpipm, full_condensing_qpoases, partial_condensing_osqp, partial_condensing_hpmpc,
partial_condensing_qpdunes
  • The same system dynamics, constraints and inputs work in acado and gives required results.

What could be the issue for the status 4?

Regards,
Nikhil

Hi Nikhil,

About the qpOASES issue: Did you compile acados with qpOASES?
In CMake this means setting the flag: -DACADOS_WITH_QPOASES=ON

I don’t know how the parameter enters your problem.
But status 4, typically means the QP solver reported infeasibility.

Best,
Jonathan

Hi Jonathan,

Thank you for the information.

I went through the installation steps and that step was mentioned for Linux users. Since I am on Windows, I think I did not set this option. However, I did redo the steps below in the build folder with the above setting.

cmake.exe -G "MinGW Makefiles" -D BLASFEO_TARGET=GENERIC -D HPIPM_TARGET=GENERIC -D ACADOS_INSTALL_DIR=.. -DBUILD_SHARED_LIBS=OFF -DACADOS_EXAMPLES=OFF -DACADOS_UNIT_TESTS=OFF .. -DACADOS_WITH_QPOASES=ON
mingw32-make.exe -j4
mingw32-make.exe install

I still get the same error. Is there something I am not doing correctly? I am not familiar with cmake and its processes.

The parameter is a road profile input to the suspension system. The road profile values are obtained from a function. These values are only input to the controller and plant in Simulink during runtime only. For each time step, the value is sent as an array of size Np+1 using repmat. I am not sure if this is the right method to input the values since in acado only 1 value was taken for each time step. However, acados requires an array of Np+1 for the parameter.

Regards,
Nikhil

Hi Nikhil,

What you tried makes sense!
Unfortunately, there is a problem with qpOASES on Windows and Matlab, which was also reported by someone else.
I will try to look into that soon.

The way you describe setting the parameters also seems correct to me and in line with acados/make_sfun.in.m at 0f69582700354dc116b24e8beec7915622b97abe · acados/acados · GitHub

Cheers,
Jonathan

Hi Jonathan,

I did a pull request and now I get the below error even when using the ‘partial_condensing_hpipm’ solver which was working fine earlier. What could be the issue?

Error using mex
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1c5):undefined reference to `QProblem_calculateMemorySize'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1fa):undefined reference to `QProblemB_calculateMemorySize'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x463):undefined reference to `QProblemB_assignMemory'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x46b):undefined reference to `QProblemB_calculateMemorySize'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x506):undefined reference to `QProblem_assignMemory'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x510):undefined reference to `QProblem_calculateMemorySize'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xa6e):undefined reference to `QProblemBCON'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xa7b):undefined reference to `QProblemB_setPrintLevel'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xa83):undefined reference to `QProblemB_printProperties'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xaee):undefined reference to `QProblemB_init'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xb0d):undefined reference to `QProblemB_getPrimalSolution'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xb18):undefined reference to `QProblemB_getDualSolution'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xe7b):undefined reference to `QProblem_hotstart'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xea4):undefined reference to `QProblem_getPrimalSolution'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xeaf):undefined reference to `QProblem_getDualSolution'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xee1):undefined reference to `QProblemCON'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xeee):undefined reference to `QProblem_setPrintLevel'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xef6):undefined reference to `QProblem_printProperties'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0xfb9):undefined reference to `QProblem_initW'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1160):undefined reference to `QProblemB_initW'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x11d6):undefined reference to `QProblemB_hotstart'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x11e6):undefined reference to `QProblemB_getPrimalSolution'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x11f1):undefined reference to `QProblemB_getDualSolution'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1273):undefined reference to `QProblem_init'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x128b):undefined reference to `Options_setToMPC'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x12d7):undefined reference to `OptionsCPY'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x12df):undefined reference to `Options_ensureConsistency'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x12f2):undefined reference to `QProblem_setPrintLevel'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x15a1):undefined reference to `Options_setToMPC'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x15ed):undefined reference to `OptionsCPY'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x15f5):undefined reference to `Options_ensureConsistency'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1608):undefined reference to `QProblemB_setPrintLevel'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x165e):undefined reference to `QProblem_initW'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x16a7):undefined reference to `QProblemBCON'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x16b4):undefined reference to `QProblemB_setPrintLevel'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x170b):undefined reference to `QProblemB_init'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1763):undefined reference to `QProblem_init'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x17a4):undefined reference to `QProblem_hotstart'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x17d2):undefined reference to `QProblemCON'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x17e4):undefined reference to `QProblem_setPrintLevel'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1865):undefined reference to `QProblem_init'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1887):undefined reference to `Options_setToMPC'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x18d3):undefined reference to `OptionsCPY'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x18db):undefined reference to `Options_ensureConsistency'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x18ee):undefined reference to `QProblem_setPrintLevel'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x193c):undefined reference to `QProblem_init'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x1954):undefined reference to `Options_setToMPC'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x19a8):undefined reference to `OptionsCPY'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x19b8):undefined reference to `Options_ensureConsistency'
Path\acados\examples\acados_matlab_octave\..\..\lib\libacados.lib(dense_qp_qpoases.c.obj):dense_qp_qpoases.c:(.text+0x19cb):undefined reference to `QProblem_setPrintLevel'
collect2.exe: error: ld returned 1 exit status

Error in ocp_set_ext_fun (line 616)
mex(mex_flags, FLAGS, LDFLAGS, ['-DSETTER=', setter{ii}],...
Error in acados_ocp (line 189)
obj.C_ocp_ext_fun = ocp_set_ext_fun(obj.C_ocp, obj.C_ocp_ext_fun,...
Error in main_MPC (line 124)
ocp = acados_ocp(ocp_model, ocp_opts);

Thank you in advance.

Regards,
Nikhil

Hi Nikhil,

This is something I was experiencing too and have been fixing on my own system. My observations (and solutions) are roughly described here: Linker problem after building acados with multiple qp solvers · Issue #651 · acados/acados · GitHub.

To solve your problem with the fresh install, I think you should just clean your CMakeCache.txt (or just remove the build folder) and then rebuild acados (with qpoases turned off option(ACADOS_WITH_QPOASES "qpOASES solver" OFF)

Hi asparc,

Thanks. I was able to solve the ‘partial_condensing_hpipm’ error with your suggestion. However, the original issue (qpoases not working) still remains unfortunately.

Hi Nikhil,

Good that you got it working without qpoases. To get it working with qpoases, compile acados with qpoases (after cleaning the CMakeCache.txt) and do the following:

In interfaces/acados_matlab_octave/ocp_compile_interface.m, link to all external libraries that acados was compiled with, in all relevant mex-commands. For instance, if acados is compiled with qpOASES and OSQP, the mex-commands become:

mex(mex_flags, FLAGS, LDFLAGS, acados_include, acados_interfaces_include, external_include, blasfeo_include, hpipm_include, ...
            acados_lib_path, '-lacados', '-lhpipm', '-lblasfeo', '-losqp', '-lqpOASES_e',  mex_files{ii}, '-outdir', opts.output_dir)

Similarly to the above, update the mex-commands in interfaces/acados_matlab_octave/ocp_set_ext_fun.m. For instance, if acados is compiled with qpOASES and OSQP, the mex-commands become:

mex(mex_flags, FLAGS, LDFLAGS, ['-DSETTER=', setter{ii}],...
    ['-DSET_FIELD=', set_fields{ii}], ['-DMEX_FIELD=', mex_fields{ii}],...
    ['-DFUN_NAME=', fun_names{ii}], ['-DPHASE=', num2str(phase{ii})],...
    ['-DN0=', num2str(phase_start{ii})], ['-DN1=', num2str(phase_end{ii})],...
    acados_include, acados_interfaces_include, external_include, blasfeo_include,...
    hpipm_include, acados_lib_path, acados_matlab_octave_lib_path, model_lib_path,...
    '-lacados', '-lhpipm', '-lblasfeo', '-losqp', '-lqpOASES_e', ['-l', model_name], mex_files{ii});

Hi asparc,

I deleted the build folder and compiled acados with qpoases on. Then, I added '-lqpOASES_e' to all the mex commands where it was not present. This was done in interfaces/acados_matlab_octave/ocp_compile_interface.m as well as interfaces/acados_matlab_octave/ocp_set_ext_fun.m. The same error as in the first post is shown again. Is my method incorrect?

Yes, that is what I did to solve the error in your first post (on windows/matlab). Is the error really identical to what you first posted? Other things I can think of:
Do you have the most recent version of all submodules (git submodule update --recursive --init)?
Did you accidentally alos activate other solvers than qpoases in the CMakeLists, e.g. OSQP?