To Simulate the 'Forward Kinematics' of a 2R Robotic Arm Manipulator using MATLAB
AIM: To Simulate the 'Forward Kinematics' of a 2R Robotic Arm Manipulator using MATLAB
OBJECTIVE:
Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm and Create an animation file of the plot.
THEORY:
A robotic arm manipulator is constructed using rigid links connected by joints with one fixed end and one free end to perform a given task, such as moving a box from one location to the next. The joints to this robotic manipulator are the movable components, which enables relative motion between the adjoining links. Robotic arms are often used as the Industrial Robotics and Automation . The figure shown below having two links. The length of link1 and link2 are L1 and L2 and the angle made by these two link from reference plane are Ɵ1 and Ɵ2 respectively. Our motive is to animate the movement of Robotic Arm with relative motion between the links.
INPUT DATA:
Length of 1st link attached to the base = l1
Length of 2nd link attached to the 1st link = l2
Angle made by 1st link with x-axis = theta1
Angle made by2nd link with x-axis = theta2
Starting point of 1st link =(x0, y0)
End point of 1st link / Starting point of 2nd link = (x1,y1)
End point of 2nd link = (x2,y2)
PROGRAM:
% Forward Kinematics of a 2R Robotic Arm ManiPulator
clear all
close all
clc
%Inputs
%length of arm
l1=1;
l2=0.5;
%set10 value of angle in between 0 to 90 for the movement of robotic arm
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) %for one value of THETA1 loop runs 10 times
THETA2=theta2(j);
%Starting point of first arm
x0=0;
y0=0;
% End point of first arm/starting point of second arm
x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);
% End point of second arm
x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);
% Ploting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
%Limit of x-axis and y-axis
axis([-0.5 1.5 0 1.5])
pause(0.03)
% To get figure window and save it as an array
M(ct)=getframe(gcf);
ct=ct+1
end
end
% creating Movie of all these frame
movie(M)
% To dump out all these frame and saving the movie in ".avi" format
videofile=VideoWriter('forward_kinematics.avi','uncompressed AVI')
open(videofile)
% Writing the movie in the video file
writeVideo(videofile,M)
close(videofile)
EXPLANATION OF PROGRAM:
- Initially we take input for length of robotic arms, i.e. l1and l2.
- And then set the value of theta1 and theta2 by using linspace
- For iterating the value of Ɵ for 1st link/arm we use for loop command.
- Again using for loop command change the value of Ɵ for 2nd link/arm i.e for one value of Ɵ1 , Ɵ2 change its value 10 times between 0 to 90.
- Now defining the coordinates of both the arms.
- By using plot command, plotting all coordinates value and changing appearance of the contours.
- To get figure window and save it as an array M, one at a time using ct
- And then terminate the loop.
- movie command is used to create movie/animation by combining all the figures saved in M file.
- And lastly save this animation as .avi format
ANIMATION:
The link for the animation of Forward Kinematics' of a 2R Robotic Arm Manipulator is shown below.Forward kinematics of Robotic Arm animation
CONCLUSION:
The functioning of Robotic Arm has been experinced by animating and simulating Forward Kinematics of Robotic Arm with the help of MATLAB program.