2R Robotic Arm
Aim:-- To Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm.
Objective:-- To find out workspace of 3R Robotic arm manipulator
Theory:--
This robotic arm contain two link one link is having legth l1 and second link is having length l2. link 2 is conncected in with link 1 and link 1 is connected at base. manupulator is connected on other end of link 2.
In above diagram 2R Robotic arm is shown.
- starting coordinates of link 1 is (x0,y0)
- end coordinates of link 1 and starting coordinates of link 2 is (x1,y1)
- end coordinates of link 2 is (x2,y2)
the link 1 and link 2 of robotic arm can able to opertate from 0 degree to 90 degree from horizontal as shown in above fighure.
Procedur:--
Codes:-
% Matlab program for forward kinematics of 2R robotic arm manipulator
clear all
close all
clc
% Inputs
l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,20); %linspace command is used to get more values og theta in given range
theta2 = linspace(0,90,20);
ct = 1
% for loop command is used because we have to run program for various theta
% value...
for i = 1:length(theta1)
THETA1 = theta1(i);
for j = 1:length(theta2)
THETA2 = theta2(j);
% coordinates
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)
grid on
axis([-0.5 2 -0.5 1.7])
pause(0.3)
M(ct) = getframe(gcf);
ct = ct + 1
end
end
movie(M)
videofile = VideoWriter('forward_kinamatics.AVI','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
- values of robotic arm's length l1 and l2 so have written in the codes and they are fixed.
- value of thheta1 and theta2 are in range from 0 degree to 90 degree so we have maintained there.
- Now for 1 value of theta1 the value of theta2 is changing in its given range so we have use for loop command
- we have used for loop command for 2 times as shown in codes because for each valuse of theta1 value of theta2 is changing so we get result no of values of theta1 multiply by number of valuse for theta2.
- After it plot command is used to plot each values.
- Used pause command to pause plot for each valuse of theta1 and theta2.
- then using getframe command captured evrery frame of plots of valuse of theta1 and theta2.
- After used movie commands to generat video file.
Output:--
In output we have get working range of robotic arm.
Output video link:--
Errors Faced:--
Error in axis command:-
Steps taken to solve this:-- again watch video of sir..and then properly written command.
Error in Movie command:-
Steps taken to solve this:-- in command window it shows so changed it as shown in window.
Conclusion:-
Determined workspace for the 2R Robotic arm.