Unwanted line in graph
이전 댓글 표시
I am doing a mobile robot simulation by solving the differential equation using ode solver and an animated line to show the movement of the robot (robot path)
%Simulation Experiment (kinematics input speed)***************
function mydglcallw6(WR,WL,n)
clf;
tspan = [0 2];initials = zeros(n,3); %start at origin
p = par();
%**************************************************************
%Creating robot path according to input speed******************
for i = 1:n
p.WL = WL(i) ;p.WR = WR(i);
sol(i)= ode23(@mydglw5, tspan, initials(i,:),[],p);
[t,s] = ode23(@mydglw5, tspan, initials(i,:),[],p);
initials(i+1,:) = deval(sol(i),2);
curve = animatedline(0,0,'Color','r','linewidth',2);
axis([-1.5 1.5 -1.5 1.5]);
xlabel('x-position [m]');ylabel('y-position [m]');
title('robot path');
grid on
for j = 1:length(s(:,1))
addpoints(curve,s(j,1),s(j,2))
drawnow
pause(0.02)
end
end
end
%*************************************************************
%Model Parameters*********************************************
function p = par();
p.L = 0.12; %length [m]
p.r = 0.1; %radius of wheel [m]
%p.WL = 2;p.WR = 2.5; %wheel velocities [th/s]
end
%*************************************************************
%Differential Equations***************************************
function dt = mydglw5(t,c,p)
x = c(1);y = c(2);th = c(3);
dx = (((p.r*p.WL)+(p.r*p.WR))/2) * cos(th);
dy = (((p.r*p.WL)+(p.r*p.WR))/2) * sin(th);
dth= ((p.r*p.WL)-(p.r*p.WR))/p.L;
dt = [dx;dy;dth];
in = [x(end);y(end);th(end)]; %compare last value with deval
end
when i use this code, i always get an unwanted line in the graph ?? how can i remove it ?
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!