Spatial MPC: How to change the sampling intervals in the loop?

Hi

I’m using maltab interface. I’m working on MPC for autonomous driving path tracking.

I formulated my MPC in the spatial domain i.e. each finite-horizon problem is discretized in space. This requires a spatial horizon (N in [m]) and a certain discretization (ds in [m]). However, although I’m keeping the number of nodes, N, constant, I want to vary ds in the loop.

In matlab, however, it does not allow me to change it in the loop. If I try to set time_steps in the loop, it doesn’t allow me:

ocp_set: field time_steps not supported, supported values are:
p, constr_x0, constr_lbx, constr_ubx, constr_C, constr_D, constr_lg, constr_ug, constr_lh, constr_uh, constr_lbu, constr_ubu, cost_y_ref[_e], sl, su, x, xdot, u, pi, lam, z,  cost_Vu, cost_Vx, cost_Vz, cost_W, cost_Z, cost_Zl, cost_Zu, cost_z, cost_zl, cost_zu, init_x, init_u, init_z, init_xdot, init_gnsf_phi, init_pi, nlp_solver_max_iter, qp_warm_start, warm_start_first_qp, print_level

Is there anyway I can change the shooting nodes time steps in the loop, in matlab?

Thank you

I think this is indeed not supported in Matlab for now.
It is a bit more involved, since some modules precompute things based on the assumption of a constant time step.
Although maybe this is just the GNSF integrator.
In Python this is possible.

Could it be that I define my own integrator (setting discrete dynamics function) and make the time step there as a parameter?

That can work, if it works for your model.
The only issue is that the cost of the shooting node is scaled with the time step of the following interval.
Thus, you would also have to change the cost function weights or add a parameter for that to make it consistent.

Hej.

Im sorry, but I’m not sure I understood. At the moment I’m using an external cost expression. How should I change the cost function weights, or for what reason should I add a parameter?