Week 2- 2R Robotic Arm Challenge
clear all
close all
clc
%inputs
l1=1;
l2=0.5;
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
ct=1;
x0=0;
y0=0;
%coordinates
for i=1:length(theta1);
THETA1=theta1(i);
for j=1:length(theta2);
THETA2=theta2(j);
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( [-0.1 1.5 0 1.5])
pause(0.1)
m(ct)=getframe(gcf);
ct=ct+1;
end
%plotting
end
movie(m)
videofile = VideoWriter('forword_kinematics.avi','uncompressed AVI')
open(videofile)
writeVideo(videofile,m)
close(videofile)
here the explanation code
line one to three am used the basic commands clear all,close all,clc
line 5 to 7 am give the inputs link1=1,link2=0.5
line eight to 9 theta1and theta2 and am uing linspace command to create array gives the number 0 to 90 10 times
line 10 to 12 i give the ct command for counting the arm and xo=o,yo=0
and line 14 to 38 there are two loop functions for two arm
for 1 loop i=1 length =theta 1
for 2 loop j=1 length=theta 2
there are two links first linke is connected to two link starting
x1=1L*cosd theta1,y1=1L*sind theta
x1=length1*cosd
y1=length1*sind
x2=x1+link2*cosd(theta2),y2=linly1+link2*sind(theta2)
and ploting using for graph (x0 x1 yo y1 x1 x2 y1 y2) using of line width=3
axis -0.1 to 1.2 y axis 0 to 1.5
pause is for the display the graph gfc
ct+plus 1=101 end of the counting link
And here to using the video file=video writer using forward kinematics.avi uncompressed avi for video
command openvideo write video close for closing the video...
SCREEN SHOTS OF ERRORS:



ERROR FACED AND RECTIFIED
1.MOVIE (M) AM PUTTING CAP M
AND RECTIFIED SMALL M TO m
2.m(ct)*get frame (gef)
and rectifed get frame of gef for error
output: