Is there any way to change MPC cost

Hi,
I am using acados in python to create MPC controller for racing.
I wonder if MPC cost can be changed according to the situation

For example,

Initially, i set the mpc cost as (q_cost = [10,10,50,0, 0, 0 ]. r_cost = [10,100])

ocp.cost.W = np.diag(np.concatenate((q_cost, r_cost)))
→ ocp.cost.W = np.diag(10,10,50,0,0,0,10,100])

when some signal is activated, i want to change mpc cost as (q_cost = [50,50,0 ,0 ,0 ,0], r_cost = [10,10])

ocp.cost.W = np.diag(np.concatenate((q_cost, r_cost)))
→ ocp.cost.W = np.diag([50,50,0,0,0,0,10,10])

(Roughly thinking, it can be solved by putting some parameters in the cost and changing it according to above signal. but i don’t know how to put some parameters in mpc cost.
Is there any way to setting the MPC cost when i want to change ?? )

Similarly, is there any what to change the MPC input constraint (lbu,ubu) when i want ??

Thanks for the help

Hi,

you can change the cost matrices and bounds as demonstrated in these lines:

Cheers,
Jonathan