Week 3.2 - 2R Robotic Arm Challenge
% inputs
l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,40);
theta2 = linspace(0,90,40);
ct=1;
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);
%plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-0.1 1.5 0 1.5])
pause(0.03)
M(ct) = getframe(gcf);
ct=ct+1;
end
end
movie(M)
videofile = videowriter('forward_kinematics.avi','uncompressedv AVI');
open(videofile)
writevideo(videofile,M)
close(videofile)
EXPLNATION:
1.L1=Linki one value is 1 assumed
2.L2=Link two value is 0.5 assumed
3. theta1 and theta2 values are assumed and used linspce comment the values of 0,90,40.
4.for loop and nested for loop concept also included for i and j vlues of theta1 and theta2.
5.x0 and y0 are the fixed points of robotic arm so its values are 0 assumed.
6.the multiplecation of x1 y1 x2 y2 including.
7.ploting is also included them.
8.to input line width value 3.
9.pause value 0.03 inputed.
10.to wrote a code for get video file
11.after the end comment to wrote movie comment
12.video file name input forward_kinematics. to get an AVI format so input .AVI comment
13.close the vide comment.
i'm also paste link for the output of the video clip.....
https://drive.google.com/file/d/1tUdSnfvOqf16IjuHetJXScIChsq4uYGt/view?usp=share_link