Reputation: 443
I am currently trying to create a 3D trajectory for a robot end-effector in Octave.
The end-effector is supposed to visit a set of 3D points X = [x_1 ,..., x_n]
, where x_i = [xcoord_i; ycoord_i; zcoord_i]
. Simple linear interpolation would lead to non-smooth robot movements. Hence I want to generate a 3D-spline curve that generates N 3D points between my reference points. There exists an Matlab implementation for this kind of task (documentation). Can you give me a hint on how to approach this kind of problem in Octave?
Upvotes: 1
Views: 1416
Reputation: 971
You can just do three one-dimensional spline interpolation on X(1,:)
, X(2,:)
and X(3,:)
using interp1
, see
https://www.gnu.org/software/octave/doc/interpreter/One_002ddimensional-Interpolation.html
This should work:
t = 1:n;
ti = 0:0.01:n;
xi = interp1(t, X(1,:), ti, "spline");
yi = interp1(t, X(2,:), ti, "spline");
zi = interp1(t, X(3,:), ti, "spline");
Xi = [xi; yi; zi];
Of course, you should adapt t
and ti
to your needs.
Upvotes: 2