Hi
I am using acados python interface to build a NMPC problem.
I want to build a complex model that takes x[0] and u[0] (symbolics) at N = 0 as paramaters βpβ, and pass it to the model at N = 1. For example in casadi, I build this:
self.x = ca.MX.sym("x", self.nx, 1)
self.u = ca.MX.sym("u", self.nu, 1)
self.p = ca.MX.sym("p", 1, self.feature_size)
self.x_dot = ca.vertcat(
ca.cos(self.x[2]) * self.x[3],
ca.sin(self.x[2]) * self.x[3],
self.x[4],
self.u[0] + f1(p), # some function
self.u[1] + f2(p) # some function
)
And in a mpc problem:
self.X = ca.MX.sym('X', nx, self.N+1) # State trajectory
self.U = ca.MX.sym('U', nu, self.N) # Control inputs
self.X0 = ca.MX.sym('X0', nx) # Initial state
for k in range(N):
if k != 0:
dynamic = self.model.create_discrete_nlp_model()
inputs = ca.horzcat(self.X[:, k-1].T, self.U[:, k-1].T)
x_next = dynamic(self.X[:, k], self.U[:, k], inputs ) # here we pass the inputs of k - 1 to the model at k
This create_discrete_nlp_model is a casadi Function takes x, u and p as params.
In this way, model at k = 1 will take x and u at k = 0 as params.
However, in acados, I donβt know how to achieve the same thing. As each u and x are seperated between shooting nodes.