Hi all

I am working on implementing acados in C++, and are utilizing the c generated code. To implement this, I have followed the implementation in the main_*.c file which is generated along with the ocp_solver_*.so library and the .c and .h files related. However, when implementing it, I struggle with my implementation not propogating the x-tradjectory (state trajectory) during optimization, and from this, does not give an control output. The output from the state tradjectory over the horizon can be seen in the following picture:

I have verified that the c-code in main_*.c works as intended by building and running it, where it gives the following x-tradjectory, where I know the states in the second row is correct, as they coincide with just running the OCP in python:

It should be mentioned that I use vectors to input the array pointers to the acados functions instead of arrays, which I have seen has caused problems in the following topic:

However, I have used vector::data() method instead of “&”, which returns the equivalent to an array pointer.

At the same time, the difference from the main_*.c is that I set a changing “yref” using the ocp_nlp_cost_model_set() method, and also want to alter the cost matrix online, which I do using the ocp_nlp_cost_model_set() method, with a pointer to an cost vector with NY*NY elements. I have verified that these vectors, along with the parameters are correctly updated continuously while simulating.

It is also worth mentioning, and which can be seen in the pictures added above, that I have tried setting the initial states to non-zero values, such that the x-tradjectory changes over the horizon, independently of the optimization. Despite this, the solver does not propogate the x-tradjectory over the optimization horizon.

Lastly it should be mentioned that when running the *_acados_solve() method, it also returns status “0”, indicating no error.

I hope someone have some insight into what the might be the problem.