FORWARD KINEMATICS OF A 2R ROBOTIC ARM
AIM: To simulate the forward kinematics of a 2R Robotic Arm using Python
THEORY:
In robotics, a manipulator is a device used to manipulate materials without direct physical contact by the operator. The applications were originally for dealing with radioactive or biohazardous materials, using robotic arms, or they were used in inaccessible places.
In industrial ergonomics a manipulator is a lift-assist device used to help workers lift, maneuver and place articles in process that are too heavy, too hot, too large or otherwise too difficult for a single worker to manually handle.
INPUT VALUES:
(x1, y1) = Ending point of the link 1/ Starting point of link 2
(x2, y2) = End point of the link 2
l1 = Length of the link 1
l2 = Length of the link 2
Theta1 = Angle made by the link 1 with x-axis
Theta2 = Angle made by the link 2 with x-axis
OBJECTIVE:
Write a program to simulate the forward kinematics of a 2R Robotic Arm
Create and animate movie from the plots obtained from the program
PYTHON PROGRAM:
# Program to simulate the 2R ROBOTIC ARM
import math
import matplotlib.pyplot as plt
# Inputs
l1 = 1
l2 = 0.5
n_theta = 10
theta_start = 0
theta_end = math.pi/2
theta1 = []
theta2 = []
# Creating an array of values of theta and retaining them
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
# Defining counter variable
ct = 1
for t1 in theta1:
for t2 in theta2:
# Link 1, Link 2 connector
x1 = l1*math.cos(t1)
y1 = l1*math.sin(t1)
#Coordinates of the manipulator
x2 = x1 + l2*math.cos(t2)
y2 = y1 + l2*math.sin(t2)
# Naming the figures using the counter variable and saving them in '.png' format
filename = str(ct) + '.png'
ct = ct+1
#Plotting figures and saving them with particular filename
plt.figure()
plt.plot([x0,x1], [y0,y1])
plt.plot([x1,x2], [y1,y2])
plt.title('Forward kinematics of 2R robotic arm manipulator')
plt.xlim([0,2])
plt.ylim([0,2])
plt.savefig(filename)
#plt.show()
EXPALNATION OF THE CODE:
- Initially, necessary libraries are import such as matplotlib and math.
- Length of both the links are defined.
- Then, we provide the start and end angle which is common for both link 1 and link 2 and further two empty arrays are created to store the values of range of motion of links.
- Afterthat, using for loop the iteration is created for the range of theta and the loop is append for the getting different possible combination of values of theta.
- And in last figures are plotted and saved with particular file name.
CONCLUSION:
Simulation of a 2R Robotic Arm is created and idea regarding the functioning of the robotic arm is observed.