Project

Robotics Arm Forward Kinematics

This gif was created using an online tool on www.gifmaker.org

\"\"\" Importing Libraries to make use of plotting feature\"\"\"

import math
import matplotlib.pyplot as plt
#Inserting number of values between 0 and pi/2
n_theta=10
theta_start=0
theta_end=math.pi/2
#Lengths of links
l1=1
l2=0.5
x0=0
y0=0  
#Empty arrays so as to store values in the program
theta_1=[]
theta_2=[]
#Using for loop to find different values
for i in range(0,n_theta):
	  #Storing different values of theta in tmp variable
	  tmp=theta_start+i*(theta_end-theta_start)/(n_theta-1)
	  #Using append to store values of tmp in theta
	  theta_1.append(tmp)
	  theta_2.append(tmp)


#Declaring counter Varibale
counter=1
# Finding a single value of theta1 from array of theta1
for theta1 in theta_1:
	#Finding a single value of theta 2 from array of theta2
	for theta2 in theta_2:
		x1=l1*math.cos(theta1)
		y1=l1*math.sin(theta1)
		x2=x1+l2*math.cos(theta2)
		y2=y1+l2*math.sin(theta2)
		#Storing the name of png files using filename , this is done so png files can used easily to find gif
		filename=str(counter)+\'.png\'
		#Incrementing the value of counter variable in a for loop
		counter=counter+1
		
		plt.figure()
		plt.plot([x0,x1],[y0,y1])
		plt.plot([x1,x2],[y1,y2])
		#Limiting x, y coordinate axis to 2 units
		plt.xlim([0,2])
		plt.ylim([0,2])
		#Saving the figures generated in for loop
		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.