2R Robotic Arm Simulator
Objective:
Write a Program to simulate forward kinematics of a 2R Robotic Arm.
Introduction:
A robotic arm is a type of mechanicaal arm usually programmable with similar functions to a human arm, the arm may be the sum total of the mechanism or may be part of a more complex robot. The links of such a manipulator are connected by joints allowing either rotational motion or translational (linear) displacement. The links of the manipulator can be considered to form a kinematic chan. The terminus of the kinematic chain of the manipulator is called the end effecter and it is analogous to the human hand.The end effector, or robotic hand, can be designed to perform any desired task such as welding, gripping, spinning etc. depending on the application.
Code:
# 2R Robotic Arm
import math
import matplotlib.pyplot as plt
n_theta=10
theta_start=0
theta_end=math.pi/2
#Length of link
l1=1 #length of link 1
l2=0.5 #length of link 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
y0=0
ct=1
for THETA1 in theta1:
for THETA2 in theta2:
x1=l1*math.cos(THETA1)
y1=l1*math.sin(THETA1)
x2=x1+l2*math.cos(THETA2)
y2=y1+l2*math.sin(THETA2)
filename='Forward_kinematics%05d.png'%ct
ct=ct+1
plt.figure()
plt.plot([x0,x1],[y0,y1])
plt.plot([x1,x2],[y1,y2])
plt.xlim([0,4])
plt.ylim([0,4])
plt.savefig(filename)
plt.show()
Explanation of code:
1.'import math' this liabrary helps to perform trigonometric operation.
2.'import matplotlib.pyplot as plt' helps to plot cuves.
3.Define starting angle as 'theta_start=0' and ending angle as 'theta_end=math.pi/2'.
4.Define base of link 1 as 'x=0,y=0' and end of link 1 as 'x1=l1*math.cos(THETA1)','y1=l1*math.sin(THETA1)' and end of link 2 as 'x2=x1+l2*math.cos(THETA2),y2=y1+l2*math.sin(THETA2)'.
5.Make null matrix of theta1 and theta2 and store the different angle in those matrix using command 'append'.
6.Extract the values of THETA1 nad THETA2 USINF for loop
'for THETA1 in theta1:
for THETA2 in theta2:'
7.Save the figures under 'filename='Forward_kinematics%05d.png'%ct'.
Result:
2R Robotic Arm Simulator
youtube link: https://youtu.be/HOuzSqrd0Lg
Reffernces:
1.Robotic arm [https://www.searchnewworld.com/search/search2.html?partid=imnsknsch&p=how+to+share+youtube+video+on+page&subid=62212345]