Project

2R Robotic Arm Simulator Using Python

import matplotlib.pyplot as plt 
import math

#inputs
l1=1  #length of link 1
l2=0.5 #length of link 2

num_values=10
theta_start=math.radians(0)
theta_end=math.radians(90)
dtheta=(theta_end-theta_start)/(num_values-1)
theta1=[]
theta2=[]

for i in range(0,num_values):
	theta1.append(theta_start+i*dtheta)
	theta2.append(theta_start+i*dtheta)
#base of the link 1
x0=0
y0=0
ct=1
for t1 in theta1:
	for t2 in theta2:
		x1=l1*math.cos(t1)
		y1=l1*math.sin(t1)

		x2=x1+math.cos(t2)
		y2=y1+math.sin(t2)
		
		filename=\'forward_kinematics\'+str(ct)+\'.png\'
		ct=ct+1
		

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

		



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.