AcadosSim results different from AcadosOcp


I’m using AcadosOcpSolver to solve a non-linear MPC problem and after the ocp is solved I gain a optimal trajectory of future states and inputs. But when I use current state and the optimal input to integrate with AcadosSimSolver, the integrator outputs a different result from the optimal trajectory produced by AcadosOcpSolver.

Both solvers use ‘ERK’, and the optimal inputs that AcadosOcpSolver produces seem to make sense. But the system dynamic is a little complex so it’s hard to examine if the optimal states make sense.

Can anyone tell me if this is because I generated a wrong model? Or there are some extra tricks when using AcadosSimSolver?

Thanks in advance for your support!

indeed the results should be the same.
However, in multiple shooting there are shooting node gaps, which correspond to the tolerance (tol_eq more specifically) on the dynamics (i.e. the res_eq in the solver statistics).
If those gaps are not fully closed, the trajectory in simulation and the one within the solver are expected to differ increasingly in time.


I see!

I forgot to set solver_options.sim_method_num_stages the same value in both solver. They really produce the same result now!

Thank you so much!