Week 2- 2R Robotic Arm Challenge
clc
clear all
close all
l1=1%length of link1
l2=0.5%length of link2
theta1=linspace(0,90,10);%A point1 has total 10 different no of angles of rotation(action)
theta2=linspace(0,90,10);%A point has total 10 different no of angle of rotation
ct=1
for i=1:length(theta1)%repeating the same action for different angles for angle of rotation
THETA1=theta1(i);%disp repeating action
for J=1:length(theta2)
THETA2=theta2(J);
x=0 % co-ordinates of point1 in the xy plane
y=0
x1=l1*cosd(THETA1)% co-ordinates of point2 in the given xyplane.
y1=l1*sind(THETA1)
x2=x1+l2*cosd(THETA2)%co-ordinates of point3 in the xy plane
y2=y1+l2*sind(THETA2)
figure(1)%display as fig(1)
plot([x,x1],[y,y1],'linewidth',3)% plotting graph b/w point1 & point 2 co-ordinates.
hold on %do not overwrite previous&display present +previousfig
plot([x1,x2],[y1,y2],'linewidth',3)% plotting graph b/w point2 & point3 co-ordinates.
hold off
axis([0 2 0 2])
M(ct)=getframe(gcf);
ct=ct+1;
end
end
movie(M)
videofile=VideoWriter('2rforward_kinematics.avi')
open(videofile)
writeVideo(videofile,M)
close(videofile)

A plane (xyz) contains no of points ,each point has an angle of rotation of 360 degrees.Here in the problem the robotic arm rotates to certain no angles by using for loop, it repeats the action of different angles.