Challenge

The Foward Kinematics of a 2R Robotic Arm

Aim :

To write a program and simulate the forward kinematics of a 2R Robotic arm

Objective :

To create an animation file and simulate the motion of a 2R robotic arm

Theory:

Robotic arms are machines that are programmed to execute specific task or job quickly,efficiently and accurately.

It is a mechanical arm that functions similar to human arm. A typical industrial robot arm includes a series of joints,

articulations and manipulators that work together.

some of the types of robotic arms are:

  • Cartesian Robots
  • Cylindrical Robots
  • SCARA Robots
  • Collaborative Robots

In this 2R robotic arm there are 2 links forming a kinematic chain which allows for both rotational and transitional motion.

Input Parameters:

L1=Length of link 1

L2=Length of link 2

Theta1=angle made by the link 1 with x-axis

Theta2=angle made by the link 2 with x-axis

(x0,y0)=starting point of link1

(x1,y1)=ending point of link 1 and starting point of link 2

(x2,y2)=ending point of link 2

Explanation of code :

  • Length of link1 is assumed to be 1m
  • Length of link2 is assumed to be 0.5m
  • Theta1 and Theta2 varies from 0 to 90 degrees in 4 partitions
  • The value of counter is set to 1 which is increased by 1 for every iteration of loop
  • Double for loops are used for iteration of the robotic arm position
  • First for loop is for link1 and second for loop is for link2
  • The positions of link1 and link2 are iterated and plotted in a graph
  • ImageMagick is used to create the animation in gif file

Code :

Programming language used :- MATLAB

Software used :- MATLAB

% To simulate the forward kinematics of 2R robotic arm
clear all
close all
clc
%length of first link in metre
l1=1;
%length of second link in metre
l2=0.5;
%angle made by the first link with x-axis
theta1=linspace(0,90,10);
%angle made by the second link with x-axis
theta2=linspace(0,90,10);
%counter pointer
ct=1;
%for creating animation of a 2R robotic arm
for i=1:length(theta1)
THETA1=theta1(i);
for j=1:length(theta2)
THETA2=theta2(j);
%starting coordinates of link1
x0=0;
y0=0;
%ending coordinates of link1 and starting coordinates of link2
x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);
%ending coordinates of link2
x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);
%plotting
plot([x0,x1],[y0,y1],[x1,x2],[y1,y2],'linewidth',3)
axis([0 1.5 0 1.5])
pause(0.1)
M(ct)=getframe(gcf);
ct=ct+1;
end
end
movie(M)
videofile=VideoWriter('forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Output
The animation file of robotic arm can be viewed by this link :
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.