Forward Kinematics simulation of a 2R Robotic arm using MATLAB
AIM:
Writing a program in Matlab to simulate the forward kinematics of a 2R robotic arm.
THEORY:
A robotic arm is a type of mechanical arm, usually programmable, with similar functions to a human arm; the arm may be the sum of the mechanism or may be part of a more complex robot. The links of such a manipulator are connected by joints allowing either revolutionary, rotational motion or translational (linear) displacement. The links of the manipulator can be considered to form a kinematic chain. The terminus of the kinematic chain of the manipulator is called the end effector and it is analogous to the human hand.
It consists of a base, two rigid links with one end of the link being fixed and the other end is attached to link two. The end of a link-2 is attached with an end effector and it functions as a gripper or robotic hand. The type of joints being used here are revolutionary joints and since there are two such joints, we term this as 2R robotic arm. Forward kinematics deals with the position of the end effector with respect to the base, link 1 and 2. Based on the angles link 1 and 2 are making with the base we can easily determine the position of the end effector.
FORMULA:
- x1=L1*cosd(THETA1);
- y1=L1*sind(THETA1);
- x2=x1+L2*cosd(THETA2);
- y2=y1+L2*sind(THETA2);
All the above-mentioned formulae are used for writing a code in Matlab.
MATLAB PROGRAMME:
L1=1;
L2=0.5;
theta1=linspace(0,90,15);
theta2=linspace(0,90,15);
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);
plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],'linewidth',3);
axis([-1,1.5,0,2]);
pause=0.25;
M(ct)=getframe(gcf);
ct=ct+1;
end
end
movie(M);
videofile=VideoWriter('fk.avi','uncompressed AVI');
open(videofile);
writeVideo(videofile,M);
close(videofile);
The above code is used to run a simulation on forward kinematics of a 2R robotic arm.
RESULTS:
The animation of the simulation can be found here: https://www.youtube.com/watch?v=c6jxAg9DsHs
DISCUSSION OF RESULTS/CONCLUSION:
It is seen that with respect to changes in the values of theta the position of end effector is also changing, and it can be found out at any point easily using the above programme. By using such techniques, we can see how far the robot can reach and what exactly is its workspace. Thus, by using the above code the forward kinematics simulation of a 2R robotic arm is achieved.
ERRORS:
In the above picture multiplication command wasn’t used and hence we got an error.
Uncompressed.AVI was used where uncompressed AVI should be used. Apart from this no other errors were faced during the entire project.