Week 3.2 - 2R Robotic Arm Challenge
OUTPUT VIDEO LINK:
https://www.youtube.com/watch?v=YMb1mLJ6AJI
MAIN PROGRAM
close all %delete all variables
clear all %delete all plots
clc %clear command window
%inputs
theta1 = linspace(0,90,20);%Generating 20 angle points between 0 and 90
theta2 = linspace(0,90,20);%Generating 20 angle points between 0 and 90
l1 = 1;%length of 1st arm
l2 = 0.5;%length of second arm
ct = 1;
for i=1:length(theta1)
for j = 1:length(theta2)
x0 = 0
y0 = 0;
x1 = l1*cosd(theta1(i));%x1 cordinate for specific value of theta1
y1 = l1*sind(theta1(i));%y1 cordinate for specific value of theta1
x2 = x1 + l2*cosd(theta2(j));%x2 cordinate for specific value of theta2
y2 = y1 + l2*sind(theta2(j));%y2 cordinate for specific value of theta2
%plotting
plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],'linewidth',1)
axis([0 1.5 0 1.5]);%x and y axis limits for plot
pause(0.005)%pause time to visualize the arm rotation
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)