%Forward kinematics of 2R robotic arm manipulator-Animation
%Clear screen command
clear all;
close all
clc
%Inputs
%let length of arm 1 be 10 units and arm 2 be 5 units
l1=10;
l2=5;
%let theta varies from 0 to 90 degrees in division of 10
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
%Using for loop concept for dividing theta to different values
ct = 1;
for i=1:length(theta1)
THETA1=theta1(i);
for j= 1:length(theta2)
THETA2=theta2(j);
%let x1 & y1 be starting point be fixed first point of l1
x1=0;
y1=0;
%let x2 & y2 be second ending point of l1 and starting point for line l2
x2=l1*cosd(THETA1);
y2=l1*sind(THETA1);
%let x3 & y3 be ending point for l2
x3=x2+l2*cosd(THETA2);
y3=y2+l2*sind(THETA2);
plot([x1 x2],[y1 y2],[x2 x3],[y2 y3],'linewidth',5)
axis([-1 16 0 16 ]);
pause(0.003);
M (ct) = getframe ;
%incrementing frame by one
ct=ct+1;
end
end
close all
%saving animation file
movie(M);
video=VideoWriter('forword_kinematics.avi','MPEG-4');
open(video)
writeVideo(video,M)
close(video)