2R Robotic Arm Challenge
AIM : To write a Matlab program to simulate the forward kinematics of a 2R Robotic arm and to create a animation file.
( Using Octave 4.0.0 GUI )
ABOUT 2R ROBOTIC ARM :
A robotic arm is a machine which is capable of doing the work as instructed to it. Robotics arm finds a lot of application in the manufacturing industry as well as in the assembly line. It consist of the link , joints end effector ( manipulator ) and control unit. The end effector motion ( manipulator ) is defined by the movement of the subsequent links. First the motion is given to the first link and according to that link 2 and end effector motion is obtained.
Let,
l1 = Length of link 1.
l2 = Length of link 2.
Theta1 = Angle of the link 1 with horizontal.
Theta2 = Angle of the link 2 with horizontal.
(X0, Y0) = Inital position of link 1.
(X1, Y1) = Final positon of link 1. Also the intial position of link 2 ( Because both link 1&2 are connected at same point.
(X2, Y2) = FInal position of link 2.
If,
(X0, YO) = (0,0) is the initial coordinate of link 1 then its final coordinate is :
(X1 , Y1) = (l1 *cosd(theta1), l1 *sind(theta1)) . Also the initial coordinates of link 2.
Accordingly, final coordinate of link 2 is given by :
(X2, Y2) =( { X1+ l2 *cosd(theta2) } , { Y1+ l2*sind(theta2)} )
( cosd(theta) is taken because it will give answer in "degrees" otherwise only cos(theta) will give answer in "radians".)
OBJECTIVE OF THE PROJECT:
Our main objective is to see how the end effector ( manipulator) varies with the different values of theta for both the link so that we could get the required work space of the manipulator and to make animation of the 2R robotic arm.
%Forward Kinematics of 2R Robotic Arm
%Iinputs
L1=1;
L2=0.3;
theta1=linspace(0,90,13);
theta2=linspace(0,50,10);
ct=1;
for i=1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
THETA2=theta2(j);
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',1)
grid on;
axis([-0.1 2 0 1.5])
pause(0.000003);
hold off
## q(ct)=getframe(gcf);
Text=sprintf("2R%d.png",ct);
saveas(1,Text)
ct=ct+1;
end
end
%movie(q)
%videofile = Videowriter('2R.avi','Uncompressed avi');
%Open(videofile)
%writeVideo(videofile,q)
%close(videofle)
ANIMATION OF 2R ROBOTIC ARM:
CONCLUSION :
- From this program we have created the animation of the 2R Robotic Arm successfully .
- We see that by the movement of links we can determine the motion of the manipulator and get the required work space.
- Error occurred while making in animation file in octave as getframe command doesn’t get executed and it is required to get the animation file in gnuplot.
Wrong file figure: