Porting race car example to SIMULINK

Hi :wave:

I am new to using acados, currently attempting to port the race car example to SIMULINK.
I have been able to convert the race car example m-files to s-function. Please see the image below.

My objective is:
Online Change reference y_ref and y_ref_e for the race car example in SIMULINK.

I reviewed the discussion on this forum https://discourse.acados.org/t/using-s-function-in-matlab-simulink/252, however the implementation for reference tracking use case is not clear.

Thanks,
Yash

These hints should help other people to help you :handshake:
Thanks for using acados :pray:

Hi Yash,

Basically, you want to translate these lines of code into Simulink blocks.
As you can see there, y_ref is changed for all shooting nodes in each simulation step.

Note that in that .m file, there is no closed loop simulation. The initial state should be obtained from an integrator instead of the ocp solver for that.

Also note that the Simulink examples have been improved a bit last week:

The block y_ref contains the y_{\mathrm{ref}} values for the shooting nodes 1 to N-1 concatenated. To set this up correctly, the x_init part in the updated advanced Simulink example is a good reference.

Cheers,
Jonathan

Hi Jonathan,

Thanks for your help. Based on your suggestions I had chance to update x_init part of the race car SIMULINK model. However, ended up using m-function to concatenate y_ref values for shooting node 1 to N-1.

The end results is the OCP status stays at 0 (couple time goes to 4), looks like the model is working.
Thanks a lot for your help.
Could you or other community members provide some additional pointers or things I should consider to improve the results?

Thanks & Regards,
Yash
Screenshot from 2021-05-02 22-51-39

Hi Yash,

I also had the experience that this OCP solver does run into convergence issues or infeasibilities frequently for challenging problems within a closed loop simulation.
It might be a tuning issue and infeasibility might come from the hard constraints within this OCP formulation.