Parameter P update at each stage in matlab interface

@FreyJo,sorry.
I add a new topic.

NOW, my question is:
I want to update the parameter P in simulink.
Or, I need to transmit external real-time variables into the model, and support code generation.

for example, I want change P like change y_ref_e .

Maybe,can see:


but I don’t know how to set up in my model.m or ocp.m.

Looking forward to your reply.

Best,
Gaofei

Hi @Gaofei,

indeed there should be an input for p on the Simulink block.

If there is not, your model probably does not contain parameters, because this if you pointed to seems to be skipped.
{%- if dims.np > 0 %}

From the screenshot it also seems like you are using the pendulum model, which has no parameters.

Best,
Jonathan

@FreyJo
YES,you are right. I am using the pendulum model.
but I changed the model.
when I compiled the simulink_example.m

error message:
> \acados_solver_pendulum.obj:acados_solver_pendulum.c:(.rdata$.refptr.pendulum_cost_ext_cost_e_fun_jac_work[.refptr.pendulum_cost_ext_cost_e_fun_jac_work]+0x0):

                undefined reference to `pendulum_cost_ext_cost_e_fun_jac_work' 
               undefined reference to `pendulum_cost_ext_cost_e_fun_jac'
              undefined reference to `pendulum_cost_ext_cost_fun_jac_sparsity_out'
            ...
           error: make_sfun (line 63)
            eval( [ 'mex -v -output  acados_solver_sfunction_pendulum '

so, How should I set it up?

Looking forward to your reply.

Best,
Gaofei

This is obviously not enough information to reproduce what you are reporting.
In general, if you change the model and are rebuilding the S function, make sure you delete the folders c_generated_code and build and rerun the whole generation process.

I hope that helps.

Best,
Jonathan

@FreyJo
In general, if you change the model and are rebuilding the S function, make sure you delete the folders c_generated_code and build and rerun the whole generation process.

I have tried,but not work.

mex error:


Best,
Gaofei

Great that you fixed your previous issue with code generation and parameters!
Just for completeness: Most likely setting sym_p at the acados ocp model was not done properly.

What you posted now is again completely different issue.
Code generation with external cost functions works fine for me.

Please open a new topic and try to explain your issue such that it can be reproduced.

Best,
Jonathan