hungpham2511 / toppra

robotic motion planning library
https://hungpham2511.github.io/toppra/index.html
MIT License
625 stars 170 forks source link

[CPP] Construct piecewise poly from boundary conditions (first derivatives at curve endpoints) #157

Open leonardoedgar opened 3 years ago

leonardoedgar commented 3 years ago

Hi. I am trying to find a way to construct a 3rd order piecewise-polynomial / cubic spline by specifying first-derivatives at the endpoints of the curve in cpp.

I found the implementation in Python here https://github.com/hungpham2511/toppra/blob/644e263269e45be8fc595bae59e959b9570edaa3/toppra/interpolator.py#L360 With the python implementation, a spline can be constructed by specifying boundary conditions such as the first-derivatives at the endpoints of the curve as documented here https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.CubicSpline.html

However, in cpp, all that I can find related to piecewise poly are here https://github.com/hungpham2511/toppra/blob/644e263269e45be8fc595bae59e959b9570edaa3/cpp/src/toppra/geometric_path/piecewise_poly_path.hpp#L23 The spline in cpp can only be constructed from these 2 scenarios:

In the scenario where the first-order derivatives at each knot are unknown, with a general form of a cubic spline in the following form (4n unknowns), Screenshot from 2021-01-08 16-28-45

a cubic spline still can be constructed by specifying the following:

However, currently, this method is not available in cpp. Are there any suggestions to go about this?

jmirabel commented 3 years ago

As far as I know, this is not implemented. However, this is easy to implement since this boils down to solving A x = b and Eigen provides everything you need for it, you only have to build A and b. A bit cumbersome but nothing hard.

leonardoedgar commented 3 years ago

Noted, thanks

hungpham2511 commented 3 years ago

@leonardoedgar If you have an implementation, feel free to open a PR!

leonardoedgar commented 3 years ago

@hungpham2511 noted

github-actions[bot] commented 2 years ago

Stale issue message