Project

Simulation of Forward Kinematics of 2R robotic arm by MATLAB programming

Aim:-

To simulate the forward kinematics of 2R robotic arm in MATLAB programming

Governing equations:-

Equations those play main role in simulation of the robot arm is given below:-

x1= l1*cosd(phi1)

y1= l1*sind(phi1)

x2= x1+l2*cosd(phi2)

y2=y1+l2*sind(phi2)

where,

(x1,y1)=coordinates of the end points

(x2,y2)= coordinates in the manipulator

l1=length of link1

l2=length of link2

phi1 and phi2 depends on theta1 and theta2

Robot arm figure

Objective:-

The main objective of this project is to write a MATLAB program to simulate the 2R robotic arm by forward kinematics and produce an animation.

Brief Theory:-

Robotic arm:- 2R robotic arm is basically a robot arm which contains two links and a manipulator.

Manipulator:- It is used to manipulate objects or materials and connected at the end of the robot arm.

Forward kinematics:- In robotics we use the concept of kinematics equation of a robot i.e forward kinematics to calculate the position of manipulator of the robot arm from given values range.

The concept of kinematics is taken from engineering mechanics.

Workflow:-

1) Coordinates of starting point of the 2R robotic arm is calculated.

2) Coordinates of end points i.e the joint of link1 and link2 is considered. Basically the range of angle is considered.

3) Coordinates of manipulator is considered.

4) Programming of calculating and animating to simulate the robot arm.

Brief content of this project:-

This project has been done by MATLAB programming.

The code of the program has been attached below:-

%Manipulation of 2R robotic arm by Forward Kinematics
clear all
close all
clc
% taking inputs
l1=1;
l2=0.5;
theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
ct=1;
for i=1: length (theta1)
    phi1=theta1(i);
    for j=1: length (theta2)
        phi2=theta2(j);
 %starting point
     x0=0;
     y0=0;
 %link 1 
 x1=l1*cosd(phi1);
 y1=l1*sind(phi1);
 %link 2
 x2=x1+l2*cosd(phi2);
 y2=y1+l2*sind(phi2);
 %plotting figures
 hold on
 plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
 axis([0  0.5 1 1.5])
 pause(0.03)
 M(ct)=getframe(gcf)
 ct=ct+1;
    end 
end
%animation
movie(M)
videofile=VideoWriter('robotarm.avi','Uncompressed Avi');
open(videofile)
writeVideo(videofile,M)
close(videofile)

Algorithm of the program:-

1) Firstly,the inputs are taken

2) Secondly,theta1 and theta2 are produced. Basically it is an array so we can use linspace command starting from 0 to 90 degree and incrementing it by 10 values i.e total 100 times it will generate.

3) Counter value ct is considered as 1.

4)For loop is used here. Two loops are created by I and j.

5) Governing equations are written.

6) Animation is plotting now. Steps are:-

1) Output plotting linewidth is 3

2) Axis are taken

3) Pausing 0.03 second

4) 'getframe' command is used to create individual frames.

5)Movie command is used to create movie for every frame.

6)Avi command is used to create avi file to store every frame.

7) Animation is opened,then it is written by writevideo command and closed.

Errors:-

Without 'hold on' command the last plot i.e second link is produced and printed. After using 'hold on' command the error was corrected and two links were visible.

Animation:-

Below the YouTube link for animated movie:-

https://youtu.be/D7-_bsuOu2M

Conclusion:-

Through this programming,the full idea how a robotic arm is manipulated is cleared and implemented at the same time. Lastly, this is very helpful in industry work with robotics.

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.