Problem with constraints in simulink


I’m implementing MPC using Simulink for tracking mpc similar with your race car example.
But there are some problem with setting the state and control input constraints.

I set the input constraints like these.

nu = 3;
nbu = 3;
Jbu = eye(nbu, nu);
ocp_model.set(‘constr_Jbu’, Jbu);
ocp_model.set(‘constr_lbu’, [vehicle.ddelta_min, vehicle.dgas_min, vehicle.dbrake_min]);
ocp_model.set(‘constr_ubu’, [vehicle.ddelta_max, vehicle.dgas_max, vehicle.dbrake_max]);

Here, vehicle.ddelta_min is set to -20, vehicle.dgas_min to -10, vehicle.dbrake_min to -10,
vehicle.ddelta_max to 20, vehicle.dgas_max to 10, vehicle.dbrake_min to 10,

but in the results of Simulink, it was confirmed that both dgas and dbrake had the same constraints as ddelta.

The constant value in the figure:
reshape(repmat(ocp.model_struct.constr_ubu, ocp.opts_struct.param_scheme_N,1),[],1)

Is the code to set the constraints wrong, or is the lbu or ubu of simulink set as in the figure wrong?


it seems like you put in the bounds in the wrong order in Simulink.
The bounds should be concatenated stage by stage into a vector.