2R Arm Robotic Simulator
Writing the Python program To estimate the workspace for 2R arm simulator.
2R Arm simulator =
In Python Program ,We find the different position for Arms and Workspace for Robots and position of Robot arms. To find the that we give some inputs to program such as length of link1 and link2 and value of Theta1 and Theta2 to give Different position of arms.
Program for 2R arm simulator :
#Forward kinematics
import math
import matplotlib.pyplot as plt
#input
#length of two arms
l1 = 1
l2 = 0.5
#value of theta
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)
#Main program for Simulation
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+l1*math.cos(t2)
y2 = y1+l1*math.sin(t2)
filename = str(ct)+'.png'
ct = ct+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)
Program Explanation:
1.When Wriring the Program in python We have to installed some library to use their modules for our programming purpose.In this I installed the MATH library for mathematical operation and MATPLOTLIB library for plotting purpose.
2. THen I give some input to program such as length of link and value of theta1 and theta2 required for our operation.
3. Then I use first FOR loop for the required theta1 and theta2 value and append this value.
4.Then I Use the two FOR loops to find the coordinates of two link for simulation
5.THEN use COUNTER variable to save and show all plot of simulation in short I use COUNTER variable for iteration purpose.
6.I save all plot in .png format and then with the help of imagemagick with the support of all images we convert the in .gif format to see better resolution.
ANImation Video link:
https://drive.google.com/file/d/1wRfeX161_sDw63gADZ_A1nNSPDC7R7iR/view?usp=sharing