Week 2- 2R Robotic Arm Challenge
- %Stepwise explanation of program
close all
clear all
clc
% inputs parameters for linkages
l1 = 1;%length of link 1
l2 = 0.5;%length of link 2
theta1 = linspace(10,65,2);%Creates column matrix to store anguler motion of link 1 from
10 to 65with 2 values
theta2 = linspace(30,60,10);%Creates column matrix to store the anguler motion of link 2
from 30 to 60 with 10 values.
ct=1;%Stores the value of count
for i=1:length(theta1)
THETA1 = theta1(i);%Creates and stores the values of temperory variable THETA 1 in
theta1
for j=1:length(theta2)
THETA2=theta2(j);%Creates and stores the temperory variable THETA 2 in theta 1
x0 = 0;% x coordinate Start point of link 1
y0 = 0;% y cordinate start point of link 2
x1 = l1*cosd(THETA1);%End point x cordinate of link 1
y1 = l2*sind(THETA1);%End point Y cordinate of link
x2 =x1 + l2*cosd(THETA2);%End point X cordinate of link 2
y2 =y1 + l2*sind(THETA2);% End point y cordiante of link 2
% plotting the mechanism
figure(1)
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);plot command is used to plot
links1&2 with line width os 3
axis([-0.1 1.5 0 2]);% Creates the refrence axis
pause(1.03)
M(ct)=getframe(gcf);
ct=ct+1;
end
end
movie(M)
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI');% Creates and store the video
file in Avi format
open(videofile)
writeVideo(videofile,M)
close(videofile);

%Error faced dureing codeing
this error was faced dureing the programming where i have used smicollen in place of collen , due to which only single plot was executed and the above error was occured.
this was corrected by adding collen.
No2 - The video Avi file was not getting saved due to the error in programing.
i had used a wrong command 'writevideo(videofile,M) instead of 'writeVideo(videofile,M)https://studio.youtube.com/video/tIYQ_3OdfaM/edit