Project

Simulation of Forward Kinematics of 2R robotic arm by PYTHON programming

Aim:-

To simulate the forward kinematics of 2R robotic arm by PYTHON programming

Governing equations:-

Equations those play main role in simulation of the robot arm is given below:-

x1= l1*cosd(phi1)

y1= l1*sind(phi1)

x2= x1+l2*cosd(phi2)

y2=y1+l2*sind(phi2)

where,

(x1,y1)=coordinates of the end points

(x2,y2)= coordinates in the manipulator

l1=length of link1

l2=length of link2

phi1 and phi2 depends on theta1 and theta2

Objective:-

The main objective of this project is to write a PYTHON to simulate the 2R robotic arm by forwarding kinematics and produce an animation.

Brief Theory:-

Robotic arm:- 2R robotic arm is basically a robot arm which contains two links and a manipulator.

Manipulator:- It is used to manipulate objects or materials and connected at the end of the robot arm.

Forward kinematics:- In robotics we use the concept of kinematics equation of a robot i.e forward kinematics to calculate the position of the manipulator of the robot arm from given values range.

The concept of kinematics is taken from engineering mechanics.

Workflow:-

1) Coordinates of the starting point of the 2R robotic arm is calculated.

2) Coordinates of endpoints i.e the joint of link1 and link2 is considered. Basically the range of angle is considered.

3) Coordinates of the manipulator are considered.

4) Programming of calculating and animating to simulate the robot arm.

Brief content of this project:-

This project has been done by PYTHON programming.

The code of the program has been attached below:-

#forward kinematics simulation of a 2R Robotic Arm by python programming
#Importing of math and plot( function )

import math
import matplotlib.pyplot as plt

#links length
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):
	tmp=theta_start+i*(theta_end-theta_start)/(n_theta-1)
	theta1.append(tmp)
	theta2.append(tmp)
#co-ordinates of base
x0=0
y0=0

ct=1
for t1 in theta1:
	for t2 in theta2:
		#Link 1 and link 2 joint
		x1=l1*math.cos(t1)
		y1=l1*math.sin(t1)

		#manipulators coordinates
		x2=x1+l2*math.cos(t2)
		y2=y1+l2*math.sin(t2)
		
		filename=str(ct) + '.png' 
		ct=ct+1
		print(filename)
                #figure plot
		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)

Algorithm of the program:-

1)math and plot function is imported

2)lengths of link 1 and link 2 is put

3)Creation of different values of Theta 1 and Theta 2 is done

4)for loop is used

5)values are plotted

6)the limitation of x-axis and y-axis is done from 0 to 2

7)different figures are generated and saved

** animation is made using external software **

Animation link:-

https://youtu.be/ivkKcqvdzqw

Conclusion:-

Through this programming, the full idea of how a robotic arm is manipulated is cleared and implemented at the same time. Lastly, this is very helpful in industry work with robotics.

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.