Hi, I try to interpolated a spline throw a dataset (the record of a robot motion path). Usually it works really good, always when the robot drives without stops. But if the robot stops he moves a little bit backwards. If this happens I can’t use my “normal” method with the interpolate.UnivariateSpline-function(http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.UnivariateSpline.html), because the robot motion is not longer continuously. Does somebody has an idea which function could solve my problem? Or is there a good filter to reduce the redundant robot path. (the backwards path is only a little bit displaced relative to path without stops) Regards, Franz _______________________________________________ SciPy-User mailing list [hidden email] http://mail.scipy.org/mailman/listinfo/scipy-user |
Hello,
pchip sometimes does wonders ("wonders"=="oscillation-free") on data with piecewise continuous derivatives. Spline fits of degree 1 should also work. OTOH, sometimes pchip makes little difference from regular cubic splines, and in those cases the filtering may be your only option import scipy.interpolate from numpy import linspace xdata = ... ydata = ... f_approx = scipy.interpolate.pchip(xdata,ydata) ####Now that you have continuous function, use it many ways, ### for example: xeval = linspace(x_low, x_high, 201) #set evaluation points yeval = f_approx(xeval) Cheers, Eric On 6/22/2013 9:14 AM, Franz Engel wrote: > Hi, > > I try to interpolated a spline throw a dataset (the record of a robot > motion path). Usually it works really good, always when the robot drives > without stops. But if the robot stops he moves a little bit backwards. > If this happens I can’t use my “normal” method with the > interpolate.UnivariateSpline-function(http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.UnivariateSpline.html), > because the robot motion is not longer continuously. Does somebody has > an idea which function could solve my problem? Or is there a good filter > to reduce the redundant robot path. (the backwards path is only a little > bit displaced relative to path without stops) > > Regards, > > Franz > > > > _______________________________________________ > SciPy-User mailing list > [hidden email] > http://mail.scipy.org/mailman/listinfo/scipy-user > _______________________________________________ SciPy-User mailing list [hidden email] http://mail.scipy.org/mailman/listinfo/scipy-user |
In reply to this post by flambert
On Sat, Jun 22, 2013 at 9:14 AM, Franz Engel <[hidden email]> wrote:
Hi, I am not familiar how your function looks like, but it sounds like you should look for shape-preserving interpolation like monotone cubic Hermite interpolation.
Best, Joon _______________________________________________ SciPy-User mailing list [hidden email] http://mail.scipy.org/mailman/listinfo/scipy-user |
Yes, or use tension spline, with the W parameter. It will stop (well, not stop, but limit) the natural spline to oscillate and have the gibbs phenomena. I found that some time ago on stackoverflow.
when I want matlab-like medium tension I use W=sqrt(weights) when I want high tension, I use W=weights. #In short, to match matlab's error calculation, you need to pass "w" to splrep or UnivariateSpline, where w = np.sqrt(trapz_weights(x))
# def trapz_weights(x): dx = np.diff(x) w = np.empty(x.shape) w[1:-1] = (dx[1:] + dx[:-1])/2. w[0] = dx[0] / 2. w[-1] = dx[-1] / 2.
return w Xavier 2013/6/26 Joon Ro <[hidden email]>
« Quand le gouvernement viole les droits du peuple, l'insurrection est, pour le peuple et pour chaque portion du peuple, le plus sacré des droits et le plus indispensable des devoirs » Déclaration des droits de l'homme et du citoyen, article 35, 1793 _______________________________________________ SciPy-User mailing list [hidden email] http://mail.scipy.org/mailman/listinfo/scipy-user |
Free forum by Nabble | Edit this page |