Project

A PROGRAM TO SIMULATE THE FORWARD KINEMATICS OF A 2R ROBOTIC ARM

Introduction :

In this project we are going to simulate the forward kinematics of a 2R Robotic Arm.

2R Robotic arm contains 2 links and 2 rotational joints.

A representative diagram for a 2R Robotic Arm is given below,

Here we are interested in getting the final position of manipulator(end effector) where joint angles i.e`θ1`and `θ2`are given. Such a problem is called as "forward kinematics."

In forward kinematics , joint angles are the inputs and the co-ordinates of an end effector is the output.

Steps to simulate the forward kinematics of a 2R Robotic Arm are as follows ,

Step 1 : Calculate the position of link 1

Starting point(x0 , y0) : (0,0)

End point (x1 , y1) : (l1*cosθ1 , l1*sinθ1)

End point of link 1 is the starting point of link 2 .

Step 2 : Calculate the position of link 2

Starting point(x1 , y1) : (l1*cosθ1 , l1*sinθ1)

End point (x2 , y2) : (x1 + l2*cosθ2 , y1 + l2*sinθ2)

l1 = length of 1st link .

l2 = lenght of 2nd link.

Now for different values of θ1 and θ2 , we will simulate and on tracing the path of an end effector , we will get the workspace of an end effector.

End effector can be a machining tool or welding tool or anything.

We will be saving each and every frame for each and every value of θ1 and θ2 and then we will be stitching all these frames to create an animation so that we can see how a 2R Robotic Arm is moving.

Here is the program to simulate the forward kinematics of a 2R Robotic Arm ,

clear all
close all
clc
 
 % Inputs 
 
 l1 = 1.0;
 l2 = 0.5;
 
 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)
      
      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);
      
% plotting 
 
plot([x0 x1],[y0 y1],'linewidth',3,'color','r',[x1 x2],[y1 y2],'linewidth',3,'color','b',x2,y2 ,'*','color','g')
 
axis([-0.1 1.5 0 1.5])
pause(0.03)
file_text = sprintf("forward_kinematics%05d.png",ct)
saveas (gca,file_text)
 ct = ct+
end

end   

Below is a link for an animation ,

https://youtu.be/ejT5nPbBnp8

Thank you.

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.