Forward kinematics of 2R Robotic Arm
%forward kinematics of a robotic arm
clear all
close all
clc
%inputs
%lengths of the link
l1=8;
l2=3;
%angles made by the respective link with ground
theta1=linspace(0,90,5);
theta2=linspace(0,90,5);
ct=1;
for i=1:length(theta1)
T1=theta1(i);
for j=1:length(theta2)
T2=theta2(j);
%assigning the position of the links w.r.t. link angles
x0=0;
y0=0;
x1=l1*cosd(T1);
y1=l1*sind(T1);
x2=x1+l2*cosd(T2);
y2=y1+l2*sind(T2);
%plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'LineWidth',5)
axis([-1 15 -1 15])
pause(0.1)
M(ct)=getframe(gcf);
ct=ct+1;
end
end
%creating a video file
movie(M)
videofile=VideoWriter('roboticarm.avi','Uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)
link for the video of animation:
https://drive.google.com/file/d/1DhvDcfuPeiiu2EPTDeZn1W5FkF2r_4tN/view?usp=sharing