All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Simulation/Forward Kinematic of a 2R Robotic Arm Objective:- Development of a program in python to simulate the forward kinematics of a 2R Robotic Arm and to create an animation file of the plot. Principle:- Forward kinematics refers to the use of the kinematic equations of a robot to determine the position of the…
Saransh Dimri
updated on 24 Nov 2020
Simulation/Forward Kinematic of a 2R Robotic Arm
Objective:-
Development of a program in python to simulate the forward kinematics of a 2R Robotic Arm and to create an animation file of the plot.
Principle:-
Forward kinematics refers to the use of the kinematic equations of a robot to determine the position of the manipulator from specified values for the joint parameters. The kinematics equations of the robot are used in robotics and animation.
Solution Procedure:-
Robot kinematics refers to the analytical study of the motion of a robot manipulator, robotic arm is the most useful mechanical device which is used where accuracy and precision are needed. These things work similarly to the human arm and can be programmed as well. The traditional robotic arm will have n number of links, which are connected by joints with which links are rotated or translated. These links and joints form a Kinetic chain which has a Manipulator at the last link.
The above kinematics is made on Python
Steps Used-
Step 1 -: Calculating the position of Link 1
Start Point = (x0,y0) =(0,0)
End Point =(x1,y1) = (L1cos(theta1),L1sin(theta1)
Step 2 -: Calculating the position of Link 2
Start Point = (x1,y1) =(L1cos(theta1),L1sin(theta1))
End Point =(x2,y2) = (x1+L2cos(theta2),y1+L2sin(theta2))
Step 3 -: Calculating the Solution Set
[x0,y0],[x1,y1],[x2,y2]
Step 4 -:Plotting of a graph and its animation
We have used different values for each value of theta1 and theta2 for both links and stitch together to make an animation
_____________________________________________________________________________________________
CODE->
import math
import matplotlib.pyplot as plt
#Program for the forward kinematics of 2R robotic arm
#Inputs
l1=1
l2=0.5
n_theta= 10
theta_start =0
theta_end =math.pi/2
theta1=[]
theta2=[]
for i in range(0,n_theta):
temp= theta_start + i*(theta_end -theta_start)/(n_theta-1)
theta1.append(temp)
theta2.append(temp)
#Base of the Robot
x0= 0
y0 = 0
ct=1
for t1 in theta1:
for t2 in theta2:
#link 1 ,link 2 connector
x1 = l1*math.cos(t1)
y1 = l1* math.sin(t1)
# Coordinates of the manipulator
x2= x1+ l2*math.cos(t2)
y2= y1+ l2*math.sin(t2)
filename = 'test%05d.png' % ct
ct=ct+1
plt.figure()
plt.plot([x0,x1],[y0,y1])
plt.plot([x1,x2],[y1,y2])
plt.xlim([0,2])
plt.ylim([0,2])
plt.savefig(filename)
Explanation of the code:-
import math - to import the math class
import matplotlib.pyplot as plt - to import the plotting library to plot graph
#Program for the forward kinematics of 2R robotic arm - comments to make program user friendly
#Inputs -comment
l1=1 - initializing link 1 length as 1m
l2=0.5 - initializing link 2length as 0.5 m
n_theta= 10 -initializing with 10
theta_start =0 - initializing the start of the theta with 0
theta_end =math.pi/2 - initializing the end of the theta to 90 degree using math library
theta1=[] - intializing an theta1 array to store the values
theta2=[] - intializing an theta2array to store the values
for i in range(0,n_theta): - for loop is used to execute the given statement in the range 0 to 9
temp= theta_start + i*(theta_end -theta_start)/(n_theta-1) - initializing the temp value with 0 ,10,20,30,40,50,60,70,80,90 for different value to append in the theta1 and theta2 arrray
theta1.append(temp) - append temp value in theta 1 array
theta2.append(temp) - append temp value in theta 2array
#Base of the Robot - comment
x0= 0 - initializing link 1 coordinate as 0
y0 = 0 - initializing link 1 coordinate as 0
ct=1 - counter variable as 1
for t1 in theta1: - for loop to execute given variables
for t2 in theta2:- for loop to execute given variables
#link 1 ,link 2 connector - comments
x1 = l1*math.cos(t1) - initializing x1 coordinate
y1 = l1* math.sin(t1) -initializing y1 coordinte
# Coordinates of the manipulator - comment
x2= x1+ l2*math.cos(t2) - initializing x2coordinate
y2= y1+ l2*math.sin(t2) -initializing y2coordinte
filename = 'test%05d.png' % ct - for arranging the png images in a orderly manner.Ex test00004,test00006.
ct=ct+1 - incrementing the counter variable value by 1
plt.figure() - to plot the graph a new figure window is created
plt.plot([x0,x1],[y0,y1]) - to plot the graph
plt.plot([x1,x2],[y1,y2]) - to plot the graph
plt.xlim([0,2]) - to define limits to x axis
plt.ylim([0,2]) to define limits to the y axis
plt.savefig(filename) - to save the figure
Discussion:-
Youtube link for the Simulation:-
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 11 Project 2- MATLAB Module to calculate Forces and Displacements for a 3D Frame Structure(nonlinear analysis)
Objective: MATLAB Module to calculate Forces and Displacements for a 3D Frame Structure(nonlinear analysis) Solution procedure: 1) Develop a Matlab function to accept Node information: Node numbers, Node coordinates, and information on nodes to perform analysis on a 3D planar frame structure. 2) Based on the Matlab…
08 Aug 2022 02:32 PM IST
Week 1-Model Creation in DesignModeler Challenge
Objective: Model a butterfly valve Solution Procedure: 1 - Main Housing 2)SHAFT 3) UPPER PLATE:- 4) LOWER PLATE:- 5) BUTTERFLY VALVE ASSEMBLY IMPORT THE GEOMETRY FILE 6)BOLT AND NUT CONCLUSION AND LEARNING:- Learned about using design modeller learned about components sketch tools learned about…
18 Apr 2022 04:56 PM IST
Week 6 Project 1- MATLAB Module to calculate Forces and Displacements for a 3D Frame Structure(Linear analysis)
Objective: MATLAB Module to calculate Forces and Displacements for a 3D Frame Structure(Linear analysis) Solution procedure: 1) Develop a Matlab function to accept Node information: Node numbers, Node coordinates, and information on nodes to perform analysis on a 3D planar frame structure. 2) Based on the Matlab module…
08 Apr 2022 08:33 AM IST
Week 10 Challenge- Frame analysis and MATLAB Module for Gauss Elimination Method
OBJECTIVE:- 1) Assume a structure frame. Write down a displacement matrix with variables corresponding to pre-selected degrees of freedom and degrees of freedom to be eliminated. Mathematically, derive the process that takes the original set of equations and condense it to the form shown below Equtaion given is[k][δ]=[p]The `[delta(b)…
03 Apr 2022 08:03 AM 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.