Project

2R ROBOTIC ARM SIMULATOR USING PYTHON

2R Robotic Arm Simulator using python

OBJECTIVES:

(1) To write a program simulate forward kinematics of a 2R Robotic Arm.

(2) create animation of images of plots saved.

There are two links in a 2R Robotic Arm Manipulator and generally link 2 is smaller than the link 1. As the links start to move from origin both the links make a particular angle with respect to x and y axis respectively at a particular position. In this project we will write a program for animation showing kinematics a 2R Robotic Arm Manipulator.

#Forward Kinematics of 2R Robotic Arm
import math	
import matplotlib.pyplot as plt 

#Length of Links
l1=2
l2=1

#Array of angles
n_theta = 10

#Starting and End Points
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)
	

#Base of the Robot
x0 = 0
y0 = 0

#counter
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 = str(ct) 
			ct =ct +1


			plt.figure()
			plt.plot([x0,x1],[y0,y1])
			plt.plot([x1,x2],[y1,y2])
			plt.xlim([0,5])
			plt.ylim([0,5])
			plt.savefig(filename)

XPLANATION OF PROGRAM

1.Importing matplotlib

2.defining lengts of link1 and link2 ,angles theta1 and theta2

with proper interval,counter.

3.for loop to get repetative values of theta1 and theta2 at differnt postions.

4.defining coordinates at origin then at end of link1 and finally at end of link2 by using codes origin points x0=0,y0=0

end point of link1 and start point of link2 x1=l1*cosd(THETA1) y1=l1*sind(THETA1)

end points of link2 x

X2=x1+l2*cosd(THETA2)

y2=y1+l2*sind(THETA2)

5.plotting curves for both the links by using corresponding value of theta1 and theta2.

6.defining axis limits.

7.providing pause for smooth operation.

8.incrementing counter.

9.creation animation using multiple image plots

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.