Hi
I’m using acados to solve a nonlinear MPC with the Python interface. The dynamics are given by external C functions, explicitly implementing the disc_dyn_fun
and disc_dyn_fun_jac
functions. I’ve already implemented the MPC solver and it works.
However, now I’d like to add a forward sweep after the SQP-RTI solution is obtained to make sure that the solution adheres the dynamics even if the SQP is not converged. For this, I’d simulate the system from the given initial state applying the optimized input sequence.
As far as I understand, I should be able to use AcadosSimSolver for this, but it doesn’t work. I tried 2 ways of implementing it:
1) Directly generating from the ocp:
Code snippet:
ocp = AcadosOcp()
ocp.model.dyn_ext_fun_type = 'generic'
ocp.model.dyn_disc_fun = 'disc_dyn_fun'
ocp.model.dyn_disc_fun_jac = 'disc_dyn_fun_jac'
ocp.solver_options.integrator_type = 'DISCRETE'
ocp_solver = AcadosOcpSolver(ocp)
sim_solver = AcadosSimSolver(ocp)
Error:
make: *** No rule to make target 'sim_shared_lib'. Stop.
acados was compiled without OpenMP.
Traceback (most recent call last):
File "mpc.py", line 151, in __init__
sim_solver = AcadosSimSolver(ocp)
File "acados/interfaces/acados_template/acados_template/acados_sim_solver.py", line 285, in __init__
self.shared_lib = get_shared_lib(self.shared_lib_name, winmode=self.winmode)
File "acados/interfaces/acados_template/acados_template/utils.py", line 130, in get_shared_lib
shared_lib = DllLoader(shared_lib_name)
File "/usr/lib/python3.10/ctypes/__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: c_generated_code/libacados_sim_solver_generic_robot.so: cannot open shared object file: No such file or directory
2) Using the same model but defining a separate sim object:
Code snippet:
ocp = AcadosOcp()
ocp.model.dyn_ext_fun_type = 'generic'
ocp.model.dyn_disc_fun = 'disc_dyn_fun'
ocp.model.dyn_disc_fun_jac = 'disc_dyn_fun_jac'
ocp.solver_options.integrator_type = 'DISCRETE'
ocp_solver = AcadosOcpSolver(ocp)
sim = AcadosSim()
sim.solver_options.T = self.dt
sim.solver_options.integrator_type = 'DISCRETE'
sim.model = ocp.model
sim_solver = AcadosSimSolver(ocp)
Error:
Exception: Invalid integrator_type value. Possible values are:
ERK,
IRK,
GNSF.
You have: DISCRETE.
Could you help to solve this issue?
Best,
Peter