qnzhou / nanospline

A nano spline library in modern C++.
Mozilla Public License 2.0
111 stars 23 forks source link

Constraint on velocity and acceleration on the bspline curve #54

Closed pockerbot closed 1 year ago

pockerbot commented 1 year ago

Hi. This library is really good. I was wondering how i can add constraints on the velocity and acceleration to all the control points to the bspline curve.

qnzhou commented 1 year ago

Can you elaborate a bit? Velocity and acceleration are mathematical properties of the curve/surfaces, are you trying to optimize the shape with respect to some constraints?

pockerbot commented 1 year ago

Hi. Thanks for your quick reply. My problem statement is that I have a list of waypoints which a robot should follow. I am trying to fit those waypoints(path) and generate a trajectory (with velocity information). I find that using C2 continuity curve like cubic spline will give both velocity and acceleration continuity to the curve and hence it will be a smooth trajectory for the robot. I wanted features like arc length parameterization, query point, maximum curvature constraint which your library is providing. I was wondering if i could also incorporate a maximum velocity and acceleration constraint (i don't have desired velocity at every control points to use cubic hermite spline) as i know the maximum limit of the robot. I could use this trajectory as a reference for a controller like model predictive control for reference trajectory tracking.

qnzhou commented 1 year ago

I see, for C2 interpolating splines, I would recommend the following papers:

[1] Yan, Zhipei, et al. "K-curves: Interpolation at local maximum curvature." ACM Transactions on Graphics (TOG) 36.4 (2017): 1-7.

[2] Yuksel, Cem. "A class of C 2 interpolating splines." ACM Transactions on Graphics (TOG) 39.5 (2020): 1-14.

The first work is nearly G2 everywhere, and it is polynomial. The second work is C2 everywhere, but non-polynomial. Unfortunately, nanospline does not have implementation of these works yet.

pockerbot commented 1 year ago

Thanks for the references. I decided to split trajectory from spline and implement differently. I liked the interface for getting arc_length and approximate_inverse_evaluate() feature in your library (i hope it is computationally faster) and hence will be using your library.