Beginner - Run C code generated from Matlab (Windows) on ESP32

Hi :wave:

I’m beginning with this ACADOS and before starting the development of my actual project I would like to validate all the functionnalites I need.

Objective: Run an OCP solver on an ESP32
Feasibility check: This has been done in 2017 by Dang Doan [1]-cryptic website and [2]-git repo .
Performance check: The same man reports here that the solver is 30 times slower on this embeded system. Which is largely sufficient regarding my objectives.

Clearly, as a beginner in ACADOS and embeded system coding, I’m not targeting this objective in one shot. Before even implementing my optimisation problem I want to validate the whole programmation toolchain with an already available benchmark code, e.g. acados\examples\acados_matlab_octave\getting_started\minimal_example_ocp.m, and:
Step 1) Run it in matlab - To validate that the solver works
Step 2) Run the generated C code out of matlab - To validate that the C code works
Step 3) Run it on the ESP32 - To validate the flashing

Step 1)

I followed the installation guide and I’m capable of running acados\examples\acados_matlab_octave\getting_started\minimal_example_ocp.m and it creates files

  • build
  • c_generated_code

with C, mex, m codes, :ok_hand:

Step 2)

:pray: That’s where I start to need your help :pray:

Question set 1: It seems like I may have to change things in Makefile(s), CMakeLists, and possibly in the main c codes (main_pendulum.c).

Question set 2: It seems like I need to add libraries or toolboxes (pardon my non-expert vocabulary) because there is this line in the main_pendulum.c code:

#include "blasfeo/include/blasfeo_d_aux_ext_dep.h"

When I try to run this c code from VSCode it doesn’t find it.
Question 2.1: Is the ACADOS folder downloaded during the installation process such that “only” code generation is possible, while to test the generated code other tools are requiered?
Question 2.2: I guess I have to get blasfeo and add it somewhere in the “main” acados file. Probably at the higher level together with the interface, example a nd docs files. Am I correct?

However, I’m not sur it’s sufficient because when I try to run the code" main_sim_pendulum.c" I get error at the line:

// acados
#include "acados/utils/print.h"

It doesn’t find it.
Question 2.3: What should I do so that it finds it?

Question 2.4: Am I going in the wrong direction by using VSCode this way? On another forum is saw that I should use “make” in the c_generated_code folder (I tried without great success, but I had to install MinGW). Also, there, someone is implementing an acados code on a raspberry pi and is adviced to use cmake, and I wonder if using cmake to test the code is only valid on Linux or Mac. In particular, since the installation procedure I followed *Windows (for use with Matlab) * clearly states that it is for Matlab.

That’s a lot of questions but probably most of them are irrelevent. Being not an expert of embedded systems coding I don’t have a clear understanding of how the generated code works so I’m cetainly going in too many directions.

Thank you in advance for your support. I do think that having an easy to follow step by step procedure to follow to impement acaods’ solvers on ESP32 would be great since it’s “cheap” and would make a direct link between the arduino community and ours.That could open the door to small scale projects and help people (like me) to push their ideas for their computers to the real world (embedded systems).

Thanks again

Hi,

I think that ESP32 is a quite low-powered board and I am not sure if anyone already applied acados on it.

It is a good idea to divide your project into steps.
Note that the main part of the generated part is wrapped via the MEX files and used in the MATLAB OCP solver. So the C code is already tested in a way.
However, it is a good idea to try and run the generated main file.
On Windows in Matlab, the generated CMakefile is used to compile the code. You can also use it to compile the main file, doing something like:

cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_ACADOS_OCP_SOLVER_LIB=ON -DBUILD_EXAMPLE=ON -S . -B .

When installing acados, you also installed BLASFEO as a dependency. Everything should be in the folders include and lib of your main acados folder. I hope this helps to fix your include issues.

Best,
Jonathan