Week 2- 2R Robotic Arm Challenge
%forward kinematics of a 2r robotic arm manipulator
clear all
close all
clc
%inputs
l1 =1;
l2 =1;
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
%coordinates
x0 = 0;
y0 = 0;
x1 = l1*cosd(theta1);
y1 = l1*sind(theta2);
x2 = x1+l2*cosd(theta2);
y2 = y1+l2*sind(theta2);
figure(1)
videoFile = VideoWriter('kinematics.avi','Uncompressed AVI');
open(videoFile);
for i=1:length(theta1)
for j = 1:length(theta2)
%ploting
plot([x0,x1(i)],[y0,y1(i)],'linewidth',3,'color','b')
axis([0 2 0 2])
hold on
plot([x1(i),x2(j)],[y1(i),y2(j)],'linewidth',3,'color','r')
writeVideo(videoFile,getframe(gcf));
pause(0.001)
hold off
end
end
close(videoFile);