All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM:To simulate the forward kinematics of 2R robotic arm using python. OBJECTIVE: To write a program in python to simulate the forward kinematics of 2R robotic arm and also to create animation video of the plots obtained as an output. THEORY: Forward kinematics refers to the use of the kinematic equations of a robotā¦
Praveen kumar
updated on 30 Apr 2021
AIM:To simulate the forward kinematics of 2R robotic arm using python.
OBJECTIVE: To write a program in python to simulate the forward kinematics of 2R robotic arm and also to create animation video of the plots obtained as an output.
THEORY:
Forward kinematics refers to the use of the kinematic equations of a robot to compute the position of the end-effector from specified values for the joint parameters.
In the kinematic analysis of manipulator position, there are two separate problems to solve: direct kinemalics, and inverse kinematics. Direct kinematics involves solving the forward transformation equation to find the location of the hand in terms of the angles and displacements between the links. Inverse kinematics involves solving the inverse transformation equation to find the relationships between the links of the manipulator from the location of the hand in space.
A robot arm is known manipulator. It is composed of a set of joints seperated in space by the arm links. The joints are where the motion in the arm occurs. In basic, a robot arm consists of the parts: base, joints, links, and a grapper. The base is the basic part over the arm, It may be fix or active. The joint is flexible and joins two seperated links. The link is fix and supports the grapper. The last part is a grapper. The grapper is used to hold and move the objects.
Steps/Procedure:
1.Import the "matplotlib.pyplot library" and other required libraries.
2.Then define the function using def keyword.
3.Then create two empty arrays.
4.Now initiate the for loop to calculate the different theta values and store them in the empty array created previously using append command.
5.Now initiate two for loops to calculate the coordinates of the link 1 and link 2 as well.
6.Assign the formulas in the for loop body for the coordinates of link 1 and link 2 respectively.
7.Then plot the graphs and save the images of the graphs using savefig command.
8.At last call the function and assign the values for various variables.
9.Now make the animation video using the images of plot graphs.
PYTHON CODE:
#importing the required libraries
import math
import matplotlib.pyplot as plt
import numpy as np
#defining the variable L1 and L2
#L1 = 1
#L2 = 0.5
#defining the theta values
#theta1 = 0
#theta2 = math.pi/2
#coordinates of arm base
#x0 = 0
#y0 = 0
#coordinates of the link 1
#x1 = L1*math.cos(theta1)
#y1 = L2*math.sin(theta2)
#coordinates of the link 2
#x2 = x1+L2*math.cos(theta1+theta2)
#y2 = y1+L2*math.sin(theta1+theta2)
#function defination
def test(theta1,theta2,theta_start,theta_end,n_theta,L1,L2,x0,y0):
#creating empty arrays to store the values
t1 = []
t2 = []
#for loop to calculate n values
for i in range(0,n_theta):
tmp = theta1+(i*(theta_end-theta_start)/(n_theta-1))
#appending the values in an empty array
t1.append(tmp)
t2.append(tmp)
print(t1)
c = 1
for k in t1:
for j in t2:
#coordinates of the link 1
x1 = L1*math.cos(k)
y1 = L2*math.sin(k)
#coordinates of the link 2
x2 = x1+L2*math.cos(j)
y2 = y1+L2*math.sin(j)
filename=str(c) + '.png'
c = c+1
plt.figure()
ax=plt.axes()
ax.set_facecolor('lightgrey')
plt.plot([x0,x1],[y0,y1],color='red',linewidth=4)
plt.plot([x1,x2],[y1,y2],color='darkviolet',linewidth=4)
plt.xlim([0,2])
plt.ylim([0,2])
plt.grid(True,color='black',linestyle='dotted')
plt.savefig(filename)
plt.show()
#function call
test(0,math.pi/2,0,math.pi/2,10,1,0.5,0,0)
OUTPUT:
Animated video:
GOOGLE DRIVE LINK FOR ANIMATED VIDEO:
https://drive.google.com/file/d/1No-NktJPZSwbhnCyu-uzqyqRFQP00dc1/view?usp=sharing
RESULT:
A working visualisation of robotic arm and forward kinematics has been simulated using python program.
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...
Project 2 - Supply and Demand Gap Analysis
Aim: The aim of this analysis is to identify the supply and demand gap in the Uber network and provide recommendations to improve the efficiency of their service. Introduction: Uber is a ride-hailing platform that connects passengers with drivers through a mobile app. The company has revolutionized the transportation industryā¦
04 Apr 2023 05:08 AM IST
Project 1 - COVID-19 Vaccinations Trend Analysis
Aim The aim of this report is to analyze the vaccination data for various countries and vaccine types and provide insights and recommendations for improving vaccination efforts. Introduction Vaccination is an important tool in preventing the spread of infectious diseases and protecting public health. With the ongoing COVID-19ā¦
31 Mar 2023 08:30 AM IST
Project 2 - Create a report using PowerQuery, Macro VBA, List Functions and Data Validation functions for Data Reporting of Supply Chain Management companies
Link to the Excel File is below: https://drive.google.com/file/d/1cQHJ0eiA47Tf9xFVaur1z6_5h0RdfVki/view?usp=share_link Project Report: Analysis of Loan Applicant Data at IJS Bank Limited Introduction: The purpose of this project is to analyze the data of loan applicants at IJS Bank Limited for the currentā¦
13 Feb 2023 07:49 AM IST
Project 1 - Data Cleaning and Transformation using Pivot table and Charts for the Report on requirement of Team Hiring
PLEASE CHECK THE EXCEL FILE ATTACHED BELOW I HAVE ANSWERED ALL THE QUESTIONS. b. d.
04 Feb 2023 10:07 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
Ā© 2025 Skill-Lync Inc. All Rights Reserved.