%Forward Kinematics of 2R Robotic Arm
clear all
close all
clc
% Let us take length of arm link1 & link2 as l1&l2 respectively
l1=4;
l2=8;
Let us take Angle of theta1 and theta2
theta1=linespace(0,90,10);
theta2=linespace(0,90,10);
ct=1;
for i=1:length(theta1);
THETA1=theta1(i);
for j=1:length(theta2);
THETA2=theta2(j);
%coordinates
x0=0;
y0=0;
x1=1l*cosd(THETA1);
y1=l2*sind(THETA2);
x2=x1+l2*cosd(THETA2);
y2=y1+y2*sind(THETA2);
%let us plot
%plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
grid on
hold on
axis[(-0.1 1.5 0 1.5)];
pause(0.1);
ct-ct+1;
M(ct)=get frame(gcf);
end
end
%Creating Movie of 2R Robotic Arm
movie(m)
videofile=videowriter('forward_kinematic.avi','Uncompressed.avi');
open(videofile);
Write video(Videofile,m);
close(videofile);