Week 2- 2R Robotic Arm Challenge
Simulation of forward kinematic 2R robotic arm.
clear all
close all
clc
% robotic arm linkage
% inputs
l1=2
l2=1
% cordinates
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
ct=1
for i=1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
THETA2=theta1(j);
x0=0;
y0=0;
x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);
x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);
%ploting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-0.2 3.5 0 3.5])
pause(0.03)
m(ct)=getframe(gcf);
ct=ct+1;
end
end
movie(m)
videofile=VideoWriter("exam_armlink.m",'Uncompressed AVI')
open(videofile)
writeVideo(videofile,m);
close(videofile)

google drive link
https://drive.google.com/file/d/1SIDghYnfAKWGbG4_C1rvhPlHykc59qRe/view?usp=sharing
EXPLANATION :
Here we have taken the inputs
l1=2 & l2=1
with cordinates as link one is fixed at (0,0) at one point and second point (x1 y1)
we have taken the theta between 0 to 90 with 10 difference by useing matlab function linspace as shown in insert command.
after inputing cordinates we can calculate the x1 x2 y1 y2 cordinates so then after calculating we can plot the graph.
we can plot the graph by using plot function in matlab aslo showing asis range with pause time and making it into frame.
* PROBLEM I FACED
1=understanding the function of { i=1:lenth(theta1)}
well i understand it by watching video again and again
2= making the movie(m) and video
is was showeing....... writevideo(videofile,m); ......file error
well i rectified it by using clear all, colse all, clc command and run the function again.