locuslab / mpc.pytorch

A fast and differentiable model predictive control (MPC) solver for PyTorch.
https://locuslab.github.io/mpc.pytorch/
MIT License
872 stars 146 forks source link

path follow with custom cost function #30

Open nag92 opened 4 years ago

nag92 commented 4 years ago

I am trying to design a custom MPC to follow a trajectory. The cost function has the form of

(x-x_i)^T Q_i (x-x_i) + (u-u_i)^T R (u-u_i)

where the x_i is desired value at that point. Is this possible using this framework? if so how would I go about setting up such a cost function?

sichaozhang1112 commented 2 years ago

hello, you can write this cost function into the form 0.5z^TPz+q^Tz, (equation(2) in paper https://arxiv.org/pdf/1703.00443.pdf), which is a general form of quadratic programming. in this way, x_i would be some coefficient in vector q.