Constraint setting for MPC problem

Hello :wave:

I am implementing MPC using acados on the f1tenth car in python and have some questions on the setup of the problem.

I am trying to establish a simple reference tracking MPC on the car with a known reference and track bounds, but both of these values are trajectories, i.e. are not fixed w.r.t time. My question is, while creating the .json file for the solver, does the entire trajectory have to be set as well?

For example, if I have an entire track with around 29,000 reference points which describe the track center line. Does my y_ref field in the solver have to be of the shape (nx29000) where n is my number of states?

Similarly for the track bounds, I have the coordinates of my boundaries at every 20ms, which is my sampling time. Do I have to set my track bounds before building my .json file or is it maybe possible to do this on the fly?

My intuition tells me that I will have to set it but since I was not sure, I thought I would ask here.
Any help on this matter would be highly appreciated.

:pray:

It would make sense to use a receding horizon and set the data at a time instance by updating acados parameters.

Hey @FreyJo, thank you for the quick reply. And yes, that is indeed what I am trying to do. I have written a class that creates a solver object that I can then reuse for my MPC algorithm. But as far as I understood, once I build the solver object and create the .json file, I cannot make changes to it unless I rebuild it, and rebuilding it takes time, which is not desirable as I am attempting to implement MPC in real time.

ocp.constraints.lbx = np.array(pend.x_min[2:])
I previously worked on an inverted pendulum setup and the state bounds were constant, so this method worked without any hiccups. But now the system I am working on has time varying constraints and references. So I am a little confused as to how this would work.