Week 2- 2R Robotic Arm Challenge
%program to find the robotic arm positions wrt the angle(theta)
clc
clear all
close all
% Lenght OF Arm
L1 = 1;
L2 = 0.5;
%Theta Values
theta1 = 45;
theta2 = 60;
% initial position of arms
x =0;
y = 0;
x1 = x + L1*cosd(theta1);
y1 = y + L1*sind(theta1);
x2 = x1 + L2*cosd(theta2);
y2 = y1 + L2*sind(theta2);
grid on
%Plotting
line([x x1], [y y1], 'color','r')
line([x1 x2], [y1 y2], 'color','b')
%Theta Values
theta1 = linspace(0,60,10);
theta2 = linspace(0,180,10);
ct = 1;
for i=1:length(theta1)
THETA1= theta1(i);
for j = 1:length(theta2)
THETA2=theta2(j);
x =0;
y = 0;
x1 = x + L1*cosd(THETA1);
y1 = y + L1*sind(THETA1);
x2 = x1 + L2*cosd(THETA2);
y2 = y1 + L2*sind(THETA2);
grid on
%Plotting
plot([x x1], [y y1], [x1 x2],[y1 y2],'linewidth',3)
pause(0.03)
M(ct) = getframe(gcf);
ct=ct+1;
end
end
movie(M)
videofile = VideoWriter('forward_kinematics.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
%YouTube Video Link
https://youtu.be/83x4GGuX1uU