All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM: Simulation of forward Kinematics of a 2R robotic arm THEORY : A robotic arm is a type of mechanical arm, usually programmable with similar functions to a 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…
Sayan Chatterjee
updated on 18 Sep 2020
AIM:
Simulation of forward Kinematics of a 2R robotic arm
THEORY :
A robotic arm is a type of mechanical arm, usually programmable with similar functions to a 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 (such as in an articulated robot) 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.
If we can figure out how the robot is going to move then we can understand its workspace .Understanding the worksapace is important for designing a robot for complex applications.
CODING EXPLANATION :
1) Defining the inputs :
length of link 1 , l1 = 1;
length of link 2 , l2 = 0.5;
theta1 = 45;
theta2 = 30;
2) defining the co-ordinates
The position of link 1 is calculated ;
co-ordinate of start = (0,0)
x0=0
y0 = 0
The co-ordinate of end of link 1 ;
x1 = l1*cosd(theta1)
y1 = l1*sind(theta1)
the co-ordinate of link 2 is calculated
x2 = l1 +l2*cosd(theta2)
y2 = l1+l2*sind(theta2)
3)Since there are three points , line command is used to visualise the links
line([x0 x1],[y0 y1],'linewidth',3,'color','b')
If the program is executed we get an plot btween link 1 nd link 2 at a certain value of theta1 and theta 2 . This is not the aim . The main objective is to get multiple values of theta1 and theta2 and for each value of theta1 and theta2 plots will be ctreated and that will be stitched to get an animation.
4)So an array of theta1 and theta2 is created using the linspace command
theta1 = linspace(0,90,20)
theta2 = linspace(0,90,20)
5) To change the value of theta1 and theta2 everytime ,a for loop is executed with an loop counter variable
for i = 1:length(theta1):
T1 = theta1(i)
What this means basically is , as the value of i changes we are taking the vaklue of theta1 from original array and assigning it to variable called T1
6)Now for each value of link1 , link 2 can take up multiple positions , depending on theta2 , so a for loop for theta2 is executed inside the for loop for theta1 with a different loop counter variable
for j=1:length(theta2):
T2=theta2(j)
7)Now the entire coordinates [ x0,y0],[x1,y1],[x2,y2] is wriiten inside this with only one chqnge of writing T1 and T2 insted of theta1 and theta2 respectively.
To visulaise it perfectly a counter is created 'ct' and it is assigned a value 1 and declared before the for loop starts
To get individual frames and save this to an array M;
M(ct) = getframe(gcf);
the counter is updated
ct = ct+1;
To generate a movie :
Movie(M)
A new avi file is to be created where all those frames will be dumped
Videofile = VideoWriter('forward_kinematics.avi','Uncompressed.AVI');
open(Videofile)
WriteVideo(Videofile,M)
close (Videofile)
The Matlab code is pasted below
% forward kinematics of a 2R robotic arm
clear all
close all
clc
%inputs
theta1 = linspace(0,90,20);
theta2 = linspace(0,90,20);
l1 = 1;
l2 = 0.5;
ct = 1;
%To change the value of theta1 and theta2 by programming
for i = 1:length(theta1)
T1 = theta1(i);
for j = 1:length(theta2)
T2 = theta2(j);
x0 = 0;
y0 = 0;
x1 = l1*cosd(T1);
y1 = l1*sind(T1);
x2 = l1+l2*cosd(T2);
y2 = l1+l2*sind(T2);
%plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',2)
axis([-0.1,3,0,3])
grid on
pause(0.1)
M(ct) = getframe(gcf);
ct = ct+1;
end
end
%To create a movie in matlab
movie(M)
videofile = VideoWriter('forward_Kinematics.avi');
open(videofile)
writeVideo(videofile,M)
close(videofile)
OUTPUT :
A smooth animation is created. By tracing the position of the manipulator , the workspace can be estimated.
the youtube link of the animation is posted below
https://youtu.be/DBWcIuONC4kAIM
A screenshot of the animation is posted :
CONCLUSION :
The lengths of the link 1 and link 2 can be varied to simulate different robotic arms.
The axes can also be changed .
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week 8 - Simulation of a backward facing step in OpenFOAM
Objective: To simulate an incompressible-laminar-viscous flow through the backward facing step geometry. To perform a transient simulation. The solver can be chosen based on the described physics of the flow. To explain the entire simulation procedure (how you set up the case). Procedure: To choose the solve To Set up…
14 Mar 2024 12:12 PM IST
Week 11- Broadband Noise modelling over Ahmed body
Introduction: The Ahmed body is a geometric shape proposed by Ahmed and ram in 1984. The shape provides a model to study geometric effect on wakes of ground vehicles. The Ahmed Body was first created by S.R. Ahmed in his research “Some Salient Features of the Time-Averaged Ground Vehicle Wake” in 1984.…
16 Aug 2021 06:54 PM IST
Week 8- Moving zones approach in Fluent
There are two types of motion encountered in fluid flow, they are rectilinear and rotary. There are two approaches to model rotary motion: Moving reference frame Moving mesh appraoch. Moving refernce frame: A Moving Reference Frame (MRF) is a relatively simple, robust, and efficient steady-state, Computational fluid…
22 Jul 2021 07:43 PM IST
Week 5 - Turbulence modelling challenge
Turbulence : Introduction: Turbulence is an irregular motion which in general makes its appearwnce in fluids, gases or liquids, when they flow past solid surfaces or even when neighbouring streams of same flow past or over one another. Turbulent fluid motion is an irregular condition of flow in which various quantities…
20 Jul 2021 09:30 PM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.