Interpolation with interp1 to show the path of a robot
7 views (last 30 days)
Show older comments
Hi, I'm quite new to Matlab and do not have any previous knowledge of programming, this has made my uni Matlab projects quite challenging for me. So I have this lab assignment in which I am supposed to use interp1 in order to interpolate a specific path that a robot must follow in order to collect 3 objects, avoid some obstacles and return to the starting point. The size of the robot is 20x20 and I attached an image showing the map of the objects and the obstacles. The designed path is supposed to be smooth so I guess I must use 'spline' method for interp1. This is as far as I got and any help would be appreciated since I am completely lost: x=[0,30,130,110,90,50,0]; y=[0,40,0,-30,-50,-30,0]; stop=find(x==max(x));
x1=x(1:stop); x2=x(stop:end); y1=y(1:stop); y2=y(stop:end);
Thanks in advance.
1 Comment
MathWorks Student Competitions Team
on 29 Oct 2014
Hi Roberto, to implement waypoint path planning using interp1 and spline interpolation, see the following example.
% define waypoints
t = [0 1 2 3 4 5];
points = [0 0; 1 0; 1 1; 0 1; 0 2; 1 2];
x = points(:,1);
y = points(:,2);
% calculate spline for way points
tq = 0:0.1:5;
xq = interp1(t,x,tq,'spline');
yq = interp1(t,y,tq,'spline');
If we go ahead and plot xq vs. yq, we obtain the following path.
Answers (0)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!