Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

interpolation #148

Open
radiodawn5 opened this issue Oct 2, 2019 · 3 comments
Open

interpolation #148

radiodawn5 opened this issue Oct 2, 2019 · 3 comments

Comments

@radiodawn5
Copy link

I presume the CasADi interpolant can already be used in OpenOCL? If yes, would it be possible to introduce an example where lookup tables are used in the definition of the dynamic system (dae or ode) and path constraints?

@jkoendev
Copy link
Member

jkoendev commented Oct 2, 2019

I think interpolant should work although i haven't tested it yet.
You need to set the option nlp_casadi_mx to true for ocl.Solver (which will be ocl.Problem in the next release) because interpolant only works with MX symbolics as far as i know.

Generally you can use all CasADi functions with OpenOCL. Sometimes it can happen that the OpenOCL type (ocl.Variable) and CasADi types do not work well with each other, then you can always use the .value() function on the ocl.Variable to get the underlying CasADi value and work with that.

I assume your lookup table is state dependent? What are you interpolating in your case?
I will try to come up with a simple example.

If polynomial interpolation is sufficient for your problem, you could avoid using interpolant by using polyfit to fit your data, and then polyval in your OpenOCL models. Would that work for you or do you need to use splines?

@radiodawn5
Copy link
Author

Yes the lookup table I would like to use is either state or control dependent. Taking your race car example, you could have a lookup table for the road center line e.g. y_center = f(x_road).

@jkoendev
Copy link
Member

jkoendev commented Oct 4, 2019

hi, i added an example racecar_interpolant here:
https://github.com/OpenOCL/OpenOCL/blob/dev_interpolant_example/%2Bocl/%2Bexamples/racecar_interpolant.m

It should show the basic usage of casadi.interpolant in OpenOCL.
Note that in line 163 i use the .value to get the casadi type. In line 164 and 165 i add the centerline (casadi expression) from the right side so that it works with the ocl.Variable type. Otherwise you could also use the .value function on the other part of the expression like:

y_max = y_center + 0.5*p.road_bound.value;
y_min = y_center - 0.5*p.road_bound.value;

The center_line_lut is passed to the gridconstraints function in line 24.

It is in a seperate branch as i haven't written any test for it yet..

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants