2-R link robotic arm simulator using python
\"\"\"
The program based on the 2-R animation
of the robotic arm
\"\"\"
import math as m
import matplotlib.pyplot as plt
# Setting up initial conditions
n_theta = 10
theta_start = 0
theta_end = m.pi/2
l1 = 1
l2 = 0.5
x0 = 0
y0 = 0
# Setting the angular values
theta1 = []
theta2 = []
# Creating the angles
for n in range(0,n_theta):
t = 0 + n*(theta_end - theta_start)/(n_theta-1)
theta1.append(t)
theta2.append(t)
ct = 1
for t1 in theta1:
for t2 in theta2:
x1 = x0 + l1*m.cos(t1)
y1 = y0 + l1*m.sin(t1)
x2 = x1 + l2*m.cos(t2)
y2 = y1 + l2*m.sin(t2)
# Plotting
filename = str(ct) + \'.png\'
plt.figure(ct)
plt.plot([x0,x1],[y0,y1])
plt.plot([x1,x2],[y1,y2])
plt.xlim([0,2])
plt.ylim([0,2])
plt.savefig(filename)
ct = ct + 1
The link to the gif produced is as follows