Week 2- 2R Robotic Arm Challenge
https://www.youtube.com/watch?v=MFpULBj9uE0
lear all
close all
clc
l1=2 % length of first arm in m
l2=0.5 % length of second arm in m
theta1= linspace(0,360,10); % range of value theta1
theta2= linspace(0,360,10);% range of value theta2
ct=1 %iterations
for i= 1: length(theta1)
THETA1=theta1(i)
for j= 1: length(theta2)
THETA2=theta2(j)
x0=0
y0=0
x1=l1*cosd(THETA1)
y1=l1*sind(THETA1)
x2=x1+l2*cosd(THETA2)
y2=y1+l2*sind(THETA2)
plot([x0 x1], [y0 y1],[x1 x2], [y1 y2], 'linewidth', 3)
axis([-2.5 3.5 -2.5 3.5])
M(ct)= getframe(gcf)%capturing frames for each iteration
ct=ct+1 % iteration steps
end
end
movie(M)%motion didplay of arms
videofile= VideoWriter('forward_kinematic.avi');%saving videos
open(videofile)
writeVideo(videofile,M)
close(videofile)