Hi @Miri!
I have a similar issue to the one you have, however I am using the python interface to generate C code. I also get discrete points that define a trajectory. I tried implementing the solution from this topic. I think it got it working by modifying race_cars example. I modfied line 58 in this file and .
# old spline, can't update after compile
kapparef_s = interpolant("kapparef_s_old", "bspline", [s0], kapparef)
# new spline, can update after compile by setting parameters p.
model.p = MX.sym("spilne_p", len(s0), 1)
interp_path = interpolant("kapparef_s_new", "bspline", [s0])
kapparef_s = Function("interp_func", [s], [interp_path(s, p)])
# specifying the parameters later for new solution:
ocp.parameter_values = np.array(kapparef)
Here s0 is the distance along the trajectory, for example [0, 0.5, 1, … , 0.5*n]. Kapparef is the curvature of the trajectory at each point.
The problem is that it is horribly slow. When I use a hard coded spline (the spline is known at compilation) it uses 6ms with SQP RTI, however with the new method it uses 4s. I think this is because it does not interpolate once and then use the result. It does perhaps call interpolant every time I call kapparef_s?
Did you find a solution that works better? Is there perhaps a better method?
best,
Tor