Week 2- 2R Robotic Arm Challenge
AIM:
To simulate the forward kinematics of a 2R Robotic Arm using Matlab
Matlab used as progamming language
Objective:
1.Read the given data and write the program to simulate forward kinematics robotic arm position of the manipulator.
2.To make simulation video
Manual Digram & Calculation of 2R robotic arm:

step 1: Calculate the Link1 position(its fixed)
x0 = 0, y0 = 0
step 2: calculate the Link2 position( its 1st link end & 2nd link start)
x1 = l1*cos(theta1) , y1 = l1*sin(theta1)
Step 3: calculate the manipulator(end link)
x2 = x1 + l2*cos (theta2), y2 = y1 + l2*sin(theta2)
Code:
% forward kinematics 2r robotic arm manipuklator
clear all %(clear all work space data)
close all %(close all plots)
clc %(clear all aommand window)
% (input data)
l1 = 1; %(length of the link 1)
l2 = 0.5; %(length of link 2)
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
ct = 1; %( No of frames to create movie )
for i = 1:length(theta1) %(for loop used to calculate the length of link1 value)
THETA1 = theta1(i);
for j = 1:length(theta2)%(for loop used to calculate the length of link2 value)
THETA2 = theta2(j);
% coordinates [xo yo][x1y1][x2 y2]
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)%(used to create plot by(x,y))
axis([-0.1 1.5 0 1.5])%(indicates the x-limit & y-limit)
pause(0.03)%(pause 0.03sec capture of animation )
M(ct) = getframe(gcf)%(get current figure famre)
ct =ct+1;
end
end
movie(M)%(create movie using the code)
Videofile = VideoWriter('Ahd.avi','Uncompressed AVI');%(movie stored in 'avi' file)
open(Videofile)%(opening the video file)
writeVideo(Videofile,M)%(writing the video file)
close(Videofile)%(closing the video file)
output:
Errors
Error:1
problem plot : [x0 x1],[y0 y1],[x2 y2]
solve plot : [xo x1],[y0 y1],[x1 x2],[y1 y2]

Error:2
prb: forgot the end function
sln: type the end function

Error:3
pbm: link 2 length might longer(y2 =x2+l2*sind(THETA2)
sln: (Y2 = y1+l2sibd(THETA2)

Error:4
pbm: videowrite(videofile,M)
sln: writevideo(videofile,M)

Code and output explained:
Output:
simulate the Forward kinematics of 2r robotic arm manipulator is suscessfully completed and each movement of the Link1,2 (0,90,10), each 10 degree movment obtainted check it video output
code & function:
For loop = For loop is used execute the theta1,2 value it have 10 value. Then i given to link1 and respectively j given to link2.
cosd/sind = D-denoting degree-cos -means default take randiant value
Linspace = This command used to create array/ get random number between the two values (1,5,8)
Ct = This command used to creating frames
plot = used to create plot is respected to coordinates
axis = This command is used for create x-axis limit and respected to y-axis
Pause = This command pause 0.03sec capture of animation
getframe(gcf) = This command is get current figure
ct+1 = Create advance frame
movie = This command is creating movie capture of frames
Avi = create movie saved as Avi.file