Week 2- 2R Robotic Arm Challenge
% simulate the forward kinematics of a 2R Robotic Arm
2R Robotic Arm is a kinematic chain consisting of 2 kinematic linkages with 2 rotational joints as shown below. The inter-related kinematic chain function automatically as programmed. The application of robotic is in the field of warehouse for picking goods, painting, welding, farming etc, etc. this one switch automatic process is obviously of less effort, cost-effective, time-effective etc.

Length of the kinematic links are l1 7& l2
Angle made by links with base are ѳ1 & ѳ2 respectively
The extreme co-ordinates of link1 are (x1,y1)=(0,0) & (x2,y2)=(l1cosѳ1,l1sinѳ1)
The extreme co-ordinates of link2 are (x2,y2)=(l1cosѳ1, l1sinѳ1) & (x3,y3)=(l1cosѳ1+l2cosѳ2, l1sinѳ1+l2sinѳ2 )

Program-
%simulate the forward kinematics of a 2R Robotic Arm
%program to find final position of manipulator
%inputs
%length of link 1 & link 2
l1=2;
l2=1;
%angle made by link1 & link2 with base varies from 0 to 90 degree
theta1 = linspace(0,90,15);
theta2 = linspace(0,90,15);
ct=1;
for i = 1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
THETA2 = theta2(j);
%co-ordinates
x1=0;
y1=0;
x2=l1*cosd(THETA1);
y2=l1*sind(THETA1);
x3=x2+l2*cosd(THETA2);
y3=y2+l2*sind(THETA2);
%plotting
plot([x1 x2],[y1 y2],[x2,x3],[y2,y3],'LineWidth',2)
axis([-1 3 0 4])
pause(0.0005)
M(ct)=getframe(gcf)
ct=ct+1
end
end
%To generate a movie for all those frames of array M
movie(M)
videofile = VideoWriter('2R_Robotic_Arm.avi','Uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)
Results-
>> Assignment4
M =
1×400 struct array with fields:
cdata
colormap
ct =
2
M =
1×400 struct array with fields:
cdata
colormap
ct =
3
M =
1×400 struct array with fields:
cdata
colormap
ct =
4
.
.
.
.
.
.
.
.
ct =
225
M =
1×400 struct array with fields:
cdata
colormap
ct =
226

A stepwise explanation of the code is shown in the pdf attached. As well as the result is written as per the compilation in the pdf.
The result made is made to a video & the link of the video is as below.