Parametric OCP with Simulink Interface

Hello!

I am using the Matlab/Simulink Interface and run the code on a dSPACE Platform.
Until now everything worked really well.

Now my goal is to change the parameters of my model on runtime.

I implemented it and it works to the extend of compiling and running in real time, with the problem being that it gives bad behavior (which it didnt before I implemented the parametric version), e.g. solver status 1, 4 etc.
The within matlab simulation works and gives the same results as before.
For that I used the 2 additional lines of code (beside changing the modell ofc).

opt_p is the vector with my parameters and has a length of 40. I am aware that these 2 lines are somewhat redundant.

ocp_opts.set('parameter_values', opt_p);
ocp.set('p', opt_p);

Now to the Simulink interface. Here I was a bit unsure of the names of the inputs and so on. Here is my code adaption:

simulink_opts = get_acados_simulink_opts;
simulink_opts.inputs.parameter_traj = 1;

This generated an updated S-Function with a new input. The Info in the Matlab command window shows:

3) parameters - concatenated for all shooting nodes 0 to N+1, size [440]

which makes (some) sense, since N = 10, and my parameters have length 40. Shouldnt it be 12*40 if it were from 0 to N+1?

Anyways, I then connect a (for now to check the implementation) constant parameter vector of that length (440) to my s-function in Simulink, compile (which works) and run it.

I very certain that I am using the correct parameters (same as in the matlab simulation, which works) :wink:

Sadly this gives unexpected and bad behavior. It looks a little like the parameters which I give are not being actually applied in real time.

Any ideas?

Thanks in advance!
With kind regards,
Albert

Update:
I’ve just verified that also the simulink simulation is indeed working…

So this means I apparently implemented it correctly and now the question becomes what is different in real time. Because if I didn’t make a stupid mistake in the real-time implementation, then there should be no reason why it runs less robust now, should there?

It works now. I only compiled again. There must have been something wrong on friday with the compilation or something in the workspace was messed up…

Good to hear thanks for the update!

This typo was fixed a few months ago. It is 0 to N.

1 Like