Project

2-R robot Arm Simulator- with python

import math
import matplotlib.pyplot as plt 

l1= 1              ## length of the link-1
l2=0.5             ## length of the link-2


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)

x0=0			   ## x- coordinate of the base   
y0=0			   ## y- coordinate of the base
ctr=1

for t1 in theta1:
	for t2 in theta2:
		x1=l1*math.cos(t1)   ## x- coordinate of the link-1
		y1=l1*math.sin(t1)   ## y- coordinate of the link-1

		x2=l1+l2*math.cos(t2)   ## x- coordinate of the link-1
		y2=l1+l2*math.sin(t2)   ## y- coordinate of the link-1
		
		filename=str(ctr) + ".png"

		ctr+=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:

There are 2 Link l1 and l2 of a robo arm. whose values are 1m and 0.5m respetively.

We have plotted the plot for 10 values (angles ) of theta .

theta 1 is the angle made by arm-1

and theta 2 is the angle made by arm-2.

later the base of the robo is consodered as zero.

Two empty arrays were created to store the values of theta and values were appended in those using append function

Path of the arm was traced according to the mathematical formula and graph was then plotted.

These graphs were then converted to gif file through the help of image magix.

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.