I am using the Matlab interface and am trying to implement an NMPC.
To tune this NMPC effectively, it would be helpful to be able to set the cost function weights after compilation of the MEX files.
I have tried setting them through parameters as suggested in this forum, but realized that there is a difference in the results between the model with the hard coded weights and the weights set by parameters. I use the cost type
I was able to get rid of the difference by setting the terminal cost of the version with the hard coded weights to 0.
I have reproduced this with the “pendulum_on_cart_model” from the Matlab examples of acados.
modified pendulum on cart example
The problem does not exist when using cost type
linear_ls or ‘nonlinear_ls’, but does for using
auto if it is reformulated automatically to linear LS.
I thus assume this is a bug in the implementation of the external cost module.
I can at least for now reformulate my cost to a nonlinear least squares form, but I wanted to inform you about my findings.
If you can hint me where this bug might be, I can have a look at it and see if I can fix it.