Project

Kinematic Analysis of 2R Robotic Arm using MATLAB

Objective:

Use Matlab to simulate the forward kinematics of full span and limited span 2R Robotic Arm

Methodology:
Kinematics is the study of motion of the objects without reference to the force causing the motion.

Robotic arm is modelled in Matlab with

(x0,x0) as ground or fixed point and

(x1,y1) as rotational contact between LINK-1 AND LINK-2 and

(x2,y2) being the location of manipulator

Simulation is done done by calculating the position of these points in 2D coordinate system using angle between the links and horizontal axis and length of the links

Test Case:

Case-1: limited span robotic arm

Span of link-1 is 180 degree

Span of link-2 is 180 degree and the closest angle between link-1 and link-2 is 90 degree

Case-2: full span robotic arm

Span of link-1 is 180 degree

Span of link-2 is 180 degree and the closest angle between link-1 and link-2 is 90 degree

2R Robotic Arm:

Schematic diagram of 2r Robotic arm

Matlab Code:

%clearing workspace, command window and closing plots
clear all
close all
clc


%ground point
x0=0;
y0=0;

%length of arms
l1=10;
l2=5;

%span of Link-1 
angle1=linspace(0,180,10);

%axis for plots
axis([-15 15 -15 15])
hold off


%loop count
c=1 ; 


%{
Case-1:limited span 2R robot arm
assuming that the span of Link-2 is 180 degree and that it depends on
position of Link-1
%}

for i=1:1:length(angle1)
    %This loop is controlled by position of Link-1
    ref1=angle1(i);
    
    %following code decides the possible positions of Link-2 based on position of Link-1
    x1 = x0 + l1*cosd(ref1);
     y1 = y0 + l1*sind(ref1);
    s=ref1-90;%initial position link-2 w.r.t to X-axis
    e=ref1+90;%final position link-2  w.r.t to Y-axis
    angle2=linspace(s,e,30);%possible positions of Link-2
    
    for j=1:1:length(angle2)
    % this loop is controlled by position Of Link-2 
    a=angle2(j);
    %determining the position of manipulator
    x2 = x1 + l2*cosd(a);
    y2 = y1 + l2*sind(a);

%plotting link-1 and link-2
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',7);
axis([-15 15 -15 15])

%saving the plots frames in a array 
M(c)=getframe(gcf);

c=c+1 ;  %loop count
    end
end


%{
Case-2:Full span 2R robot arm
assuming that the span of Link-2 is 180 degree and that it depends on
position of Link-1
%}

%NESTED FOR LOOP IS USED in which one loop is used to find the possible
%angles of link-2 and other to find position of manipulator
for i=1:1:length(angle1)
    %This loop is controlled by position of Link-1
    ref1=angle1(i);
    
    %following code decides the possible positions of Link-2 based on position of Link-1
    x1 = x0 + l1*cosd(ref1);
     y1 = y0 + l1*sind(ref1);
     
    %following is the difference between case-1 and case-2 
    s=ref1-180;
    e=ref1+180;
    
    
    angle2=linspace(s,e,30);%possible positions of Link-2
    
    for j=1:1:length(angle2)
    % this loop is controlled by position Of Link-2 
    a=angle2(j);
    %determining the position of manipulator
    x2 = x1 + l2*cosd(a);
    y2 = y1 + l2*sind(a);

%plotting link-1 and link-2
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',5);
axis([-15 15 -15 15])

%saving the plots frames in a array 
M(c)=getframe(gcf);

c=c+1 ;  %loop count
    end
end

%playing the frames saved in array M
movie(M);

%creates a variable named 'animation' to save video file to harddisk under
%the name  '2R robot arm.avi
animation=VideoWriter('2R robot arm_span 120.avi','Uncompressed AVI');

% opens variable 'animation'to write video from M using writeVideo command
open(animation)
writeVideo(animation,M);
close(animation)%close the variable

Result:

Embedded video link shows the animated kinematic simulation results of robotic arm for both case-1 and case-2.

Conclusion:

Using MATLAB 2R robotic arm is simulated and the possible possionts are analysed and studied using the result animation.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.