petercorke / robotics-toolbox-matlab

Robotics Toolbox for MATLAB
GNU Lesser General Public License v2.1
1.26k stars 440 forks source link

Non-descriptive error while using ctraj and tpoly #31

Closed Finnepinnen closed 5 years ago

Finnepinnen commented 5 years ago

Hi,

thank you for a fantastic toolbox. It saved my Master thesis! While trying out robot trajectories I found an error which has an error message that doesn't really give any information about the source of the error.

Code example:

clear all; mdl_puma560; steps = 23; T1=SE3(0.4,0.2,0)SE3.Rx(pi);
T2=SE3(0.4,-0.2,0)
SE3.Rx(pi);
s = tpoly(0, 1, steps); Ts=ctraj(T1,T2, s);

I found that the error:

Error using SE3/interp (line 437) error in trinterp Error in SE3/ctraj (line 474) traj(i) = T0.interp(T1, s(i)); Error in untitled4 (line 13) Ts=ctraj(T1,T2, s);

Shows up as soon as steps is less than 23.

Best regards Peter Eriksson

petercorke commented 5 years ago

I see that as well, but the error message is a bit more informative for me, maybe I'm using a newer version. Seems the problem is tpoly() which outputs a value of s > 1, but not by much. Some numerical error in computing it, clip the value and all should be good.

steps = 23; s = tpoly(0, 1, steps); Ts=ctraj(T1,T2, s); Error using SE3/interp (line 443) value of S outside interval [0,1] Error in SE3/ctraj (line 497) traj(i) = T0.interp(T1, s(i));

max(s) ans = 1.0000

max(s)-1 ans = 4.4409e-16