alexliniger / MPCC

Model Predictive Contouring Controller (MPCC) for Autonomous Racing
Apache License 2.0
1.29k stars 364 forks source link

Possible indexation problem #85

Open KarasevPavel opened 1 year ago

KarasevPavel commented 1 year ago

https://github.com/alexliniger/MPCC/blob/302e12a0546221963dc2430477e54a279532c52d/C%2B%2B/MPC/mpc.cpp#L48

I think, there is an indexation problem here in the fullsize branch, when we want to get initial_guess_[i+1] and i == N, because initial_guess_ array has only "N+1" elements in it

alexliniger commented 1 year ago

Thanks for pointing this out, I will have a look. The only place "N+2" element is used is to generate the dynamics of the N+1 step, which is not used in the MPC formulation. But if the code is really stepping over the index length this is still bad, and I will add a fix as soon as I have time.

alexliniger commented 1 year ago

There is a very simple solution to this problem, just use initial_guess_[std::min(i+1, N)] as done in the dev/docker-cppad brunch. I will add the fix as soon as possible to the other brunches.