MatthewPeterKelly / OptimTraj

A trajectory optimization library for Matlab
MIT License
598 stars 207 forks source link

Error using trapezoid/rungeKutta methods but none with chebyshev #49

Closed niksknocksu closed 2 years ago

niksknocksu commented 2 years ago

I get the following error while using trapezoid/rungeKutta methods only. My problem is of a reentry vehicle optimization with 8 states, 2 controls, and an objective to minimize time. I can use the Chebyshev method though it never converges.

image

MatthewPeterKelly commented 2 years ago

Hmmm... This looks like a problem in the user-supplied dynamics function. Is it properly vectorized? It should return an array with size of '[nState, nTime]' when passed the state and time at every collocation point.

The 'Chebyshev' method is somewhat less rigorously tested than other methods. I suggest avoiding it and using either the trapezoid or Hermite--Simpson methods instead.

niksknocksu commented 2 years ago

That was indeed the problem. I didn't realize that the function had to be vectorized.

Thank you very much!