Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

ASSIGNMENT 1 (ME766)

HIMANSHU VERMA 170303 vermahi@iitk.ac.in

1> WORKVOLUME GENERATION FOR A 2 DOF 2D ROBOTIC ARM

L1 = 10;
L2 = 5;

H01=zeros(4,4);
H12=zeros(4,4);

theta1=0;
theta2 = 0;
alpha1 = 0;
alpha2 = 0;
d1 =0;
d2=0;
r1 = L1;
r2 = L2;

plot(0,0, '-s')
xlim([-(L1+10) L1+10]);
ylim([-(L1+10) L1+10]);
xlabel('X');
ylabel('Y');
hold;
for i = 1:360
theta1 = theta1+1
for j = 1:360
theta2 = theta2+1;
H01 = [cosd(theta1) -sind(theta1)*cosd(alpha1)
sind(theta1)*sind(alpha1) r1*cosd(theta1); sind(theta1)
cosd(theta1)*cosd(alpha1) -cosd(theta1)*sind(alpha1) r1*sind(theta1); 0
sind(alpha1) cosd(alpha1) d1; 0 0 0 1;];
H12 = [cosd(theta2) -sind(theta2)*cosd(alpha2)
sind(theta2)*sind(alpha2) r2*cosd(theta2); sind(theta2)
cosd(theta2)*cosd(alpha2) -cosd(theta2)*sind(alpha2) r2*sind(theta2); 0
sind(alpha2) cosd(alpha2) d2; 0 0 0 1;];
H02 = H01*H12;

X = H02(1,4);
Y= H02(2,4);
plot(X,Y ,'*')

end
theta2 =0;
end
2>CREATING AND PLOTTING VARIOUS OBSTACLES IN THE WORKVOLUME OF THE ROBOTIC ARM
pgon = polyshape([10 10 15 14 14], [8 7 8 11 13]);
plot(pgon)
hold
pgon1 = polyshape([-10 -10 -14 -14], [8 12 12 8]);
plot(pgon1)
n = 1000;
r=3
t = linspace(0,2*pi,n);
c = [5 -5];
x = c(1) + r*sin(t);
y = c(2) + r*cos(t);
pgon2 = polyshape(x,y);
plot(pgon2)

L1 = 10;
L2=5;
theta1 = 45;
theta2 = 30;

line([0 L1*cosd(theta1) L1*cosd(theta1)+L2*cosd(theta1+theta2)],[0


L1*sind(theta1) L1*sind(theta1)+L2*sind(theta1+theta2)],
'Color','red','LineWidth',3)
3>CREATING CONFIGURATION SPACE FOR THE ABOVE GENERATED OBSTACLES AND PLOTTING
THETA1 VS THETA2

polygon = polyshape([10 10 15 14 14], [8 7 8 11 13]);


square = polyshape([-10 -10 -14 -14], [8 12 12 8]);
n = 1000;
r=3
t = linspace(0,2*pi,n);
c = [5 -5];
x = c(1) + r*sin(t);
y = c(2) + r*cos(t);
circle = polyshape(x,y);
L1 = 10;
L2=5;

theta1=0;
theta2 = 0;
alpha1 = 0;
alpha2 = 0;
d1 =0;
d2=0;
r1 = L1;
r2 = L2;
plot(0,0, '-s')
xlim([0 360]);
ylim([0 360]);
xlabel('theta1');
ylabel('theta2');
hold
for i = 1:360
theta1 = theta1+1
for j = 1:360
theta2 = theta2+1;
H01 = [cosd(theta1) -sind(theta1)*cosd(alpha1)
sind(theta1)*sind(alpha1) r1*cosd(theta1); sind(theta1)
cosd(theta1)*cosd(alpha1) -cosd(theta1)*sind(alpha1) r1*sind(theta1); 0
sind(alpha1) cosd(alpha1) d1; 0 0 0 1;];
H12 = [cosd(theta2) -sind(theta2)*cosd(alpha2)
sind(theta2)*sind(alpha2) r2*cosd(theta2); sind(theta2)
cosd(theta2)*cosd(alpha2) -cosd(theta2)*sind(alpha2) r2*sind(theta2); 0
sind(alpha2) cosd(alpha2) d2; 0 0 0 1;];
H02 = H01*H12;

X1=H01(1,4);
Y1=H01(2,4);
X2 = H02(1,4);
Y2= H02(2,4);
arm1 = [0,0; X1,Y1];
arm2 = [X1,Y1;X2,Y2];
[a1,b1] = intersect(polygon, arm1);
[a2,b2] = intersect(polygon, arm2);
if (isempty(a1)==0) || (isempty(a2)==0)
plot(theta1,theta2, '+')
end
[a1,b1] = intersect(square, arm1);
[a2,b2] = intersect(square, arm2);
if (isempty(a1)==0) || (isempty(a2)==0)
plot(theta1,theta2, 'o')
end
[a1,b1] = intersect(circle, arm1);
[a2,b2] = intersect(circle, arm2);
if (isempty(a1)==0) || (isempty(a2)==0)
plot(theta1,theta2, 'x')
end

end
theta2 =0;
end

You might also like