Project

Forward kinematics of a 2R Robotic Arm using MATLAB

Aim:

To write a program to to simulate the forward kinematics of a 2R Robotic Arm using MATLAB.

Objective:

Write a program in Matlab to simulate forward kinematics of a 2R Robotic Arm and creating a animation from the plot obtained from the program to understand the movment of 2R Robotic Arm in 2D workspace.

Theory:

Robotic arm is a type of machanical arm which when programed function similar to human arm. the arm may be the sum total of the mechanism or may be part of a more complex robot. The links of such a manipulator are connected by joints allowing either 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.The end effector, or robotic hand, can be designed to perform any desired task such as welding, gripping, spinning etc., depending on the application.

fig: Robotic Arm

fig: 2R Robotic Arm

Input:

l1= Length of link 1.

l2= Length of link 2.

θ1= Angle made by arm 1 with horizontal.

θ2= Angle made by arm 2 with horizontal.

starring co-ordinate of link 1 = (x0,y0)

End co-ordinate of link 1 = (x1,y1)

starring co-ordinate of link 2 = (x1,y1)

End co-ordinate of link 2 =(x2,y2)=(x1+l2cosθ2,y1+l2sinθ2)

Program:

%Forward kinametic of 2R robotic arm manipulator
clear all
close all
clc
%input
%length of link in meter
l1=1;
l2=0.5;
% Angle trace by link 1 in degree
theta1= linspace(0,90,10);

% Angle trace by link 2 in degree
theta2= linspace(0,90,10);

ct=1;
for i= 1:length(theta1)
      THETA1 = theta1(i);
      
      for j =1:length(theta2)
          THETA2 = theta2 (j);

          % starting point co-ordinate of link 1
          x0 = 0;
          y0 = 0;

          %  end point co-ordinate of link 1
          x1 = l1*cosd(THETA1);
          y1 = l1*sind(THETA1);

          % end point co-ordinate of link 2
          x2 = x1 + l2*cosd(THETA2);
          y2 = y1 + l2*sind(THETA2);
          
          %plotting
          plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],'linewidth',4)
          axis([-0.1 1.5 0 1.5])
          pause(0.1)
          M(ct)= getframe(gcf);
          ct = ct+1;
      end
end

% creating movie from captured frames

 movie(M)
 videofile = VideoWriter('forward_kinematics_2R_Robotic_arm.avi','uncompressed AVI');
 open(videofile);
 writeVideo(videofile,M);
 close(videofile);

Output :

The output obtained is animated video clip of movement of Robotic arm.

click on following link to watch the output of program:

Error Faced While Programing are follow:

1. unrecorganised variable Y1 was found, as i have defined y1 in lower case.

  • Step taken to over come this error:

changed Y1(upper case) to y1 (lower case).

2. Error in line 37, used lower case in place of upper case in

"videofile = videowriter('forward_kinematics_2R_Robotic_arm.avi','uncompressed avi');".

  • Step taken to over come this error:

changed videowriter(upper case) to VideoWriter(lower case).

3. Unrecorganised variable found, as type wrong command.

  • Step taken to over come this error:

changed "writevideo"to "writeVideo".

Conlusion:

The simulation of forward kinematics of a 2R Robotic Arm is succesfuly created by using program in MATLAB.

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.