Docsity

MATLAB Script for Simulating Robot Motion, Exercises of Introduction to Robotics

Toggle sidebar
bg1
Part‐1a
vr=0.5;
vl=1;
wr=vr/0.2;
wl=vl/0.2;
s=1e-6;
t=zeros(1,10000000);
x=zeros(1,10000000);
y=zeros(1,10000000);
Sl=0;
Sr=0;
for i=2:10000000
ULi=vl*s;
Sl=Sl+ULi;
URi=vr*s;
Sr=Sr+URi;
Ui=(ULi+URi)/2;
dti=(ULi-URi)/0.3;
t(i)=dti+t(i-1);
x(i)=x(i-1)+Ui*cos(t(i));
y(i)=y(i-1)+Ui*sin(t(i));
end
El=Sl/(2.5*10^-4)
Er=Sr/(2.5*10^-4)
plot(x,y)
Part‐1b
vr=0.1;
-0.5 -0.4 -0.3 -0.2 -0.1 00.1 0.2 0.3 0.4 0.5
-0.1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
docsity.com
pf3
pf4

Partial preview of the text

Download MATLAB Script for Simulating Robot Motion and more Exercises Introduction to Robotics in PDF only on Docsity!

Part‐1a

vr=0.5; vl=1; wr=vr/0.2; wl=vl/0.2; s=1e-6; t=zeros(1,10000000); x=zeros(1,10000000); y=zeros(1,10000000); Sl=0; Sr=0; for i=2: ULi=vls; Sl=Sl+ULi; URi=vrs; Sr=Sr+URi; Ui=(ULi+URi)/2; dti=(ULi-URi)/0.3; t(i)=dti+t(i-1); x(i)=x(i-1)+Uicos(t(i)); y(i)=y(i-1)+Uisin(t(i)); end El=Sl/(2.510^-4) Er=Sr/(2.510^-4) plot(x,y)

Part‐1b

vr=0.1;

vl=1; wr=vr/0.2; wl=vl/0.2; %sampling time=10ms s=1e-2; t=zeros(1,1000); x=zeros(1,1000); y=zeros(1,1000); Sl=0; Sr=0; for i=2: ULi=vls; Sl=Sl+ULi; URi=vrs; Sr=Sr+URi; Ui=(ULi+URi)/2; dti=(ULi-URi)/0.3; t(i)=dti+t(i-1); x(i)=x(i-1)+Uicos(t(i)); y(i)=y(i-1)+Uisin(t(i)); end El=Sl/(2.510^-4) Er=Sr/(2.510^-4) plot(x,y)

Part‐ 2

s=1e-1; ox=0; oy=0; %two dots are drawn

set(h1,'YData',y(i)); set(h2,'XData',x(i)+0.5cos(t(i))); set(h2,'YData',y(i)+0.5sin(t(i))); drawnow; i=i+1; end end plot(x,y)

Graph

Initially robot is at origin. Then robots follows a path.