2R Robotic Arm Simulator in PYTHON
AIM: To simulate forward kinematic of a 2R-Robotic Arm.
GOVERNING EQUATIONS:
The robotic arm is used for multiple industrial applications, from welding, material handling, and thermal spraying, to painting and drilling.
Forward kinematics refers to the use of the kinematic equations of a robot to compute the position of the end-effector from specified values for the joint parameters.
GIVEN:
Length of link1 = 2 meters
Length of link2 = 1.5 meters
Values of θ1 = (00,100,200,300,400,500,600,700,800,900)
Values of θ2 = (00,100,200,300,400,500,600,700,800,900)
Taking the start point of the first link as a reference coordinate system than, for a given value of θ1 and θ2, we can write that, using trigonometry
X0=0 Y0=0
X1=L1*Cos(θ1) Y1=L1*Sin(θ1)
X2=X1 + L2*Cos(θ2) Y2=Y1 + L2*Sin(θ2)
OBJECTIVES OF THE PROJECT:
The main objective of the challenge is to write a PYTHON program to find the coordinates of the link1 and link2 using the equations derived through trigonometry and then plot the lines representing the position of both links at various values of θ1 and θ2. All the plots at different angles are captured and converted into an animation to simulate the robotic arm.
PROGRAM:
import numpy as np
import math
import matplotlib.pyplot as plt
#length of first link
l1=2
#length of second link
l2=1.5
#angle of first link
theta1=np.array(np.linspace(0,90,10))
#angle of second link
theta2=np.array(np.linspace(0,90,10))
#base point
x0=0
y0=0
ct=1
for i in range(0,np.size(theta1)):
for j in range(0,np.size(theta2)):
#common point
x1=l1*np.cos(math.radians((theta1[i])))
y1=l1*np.sin(math.radians((theta1[i])))
#end point
x2=x1 + l2*np.cos(math.radians((theta2[j])))
y2=y1 + l2*np.sin(math.radians((theta2[j])))
filename= str(ct)+ '.png'
#plotting
plt.figure()
plt.plot([x0,x1],[y0,y1])
plt.plot([x1,x2],[y1,y2])
plt.title('Robotic Arm Simulation')
plt.xlim([0,3.5])
plt.ylim([0,3.5])
plt.savefig(filename)
ct=ct+1
OUTPUT:
Animation Link: Robotic Arm simulation animation
STEPS:
1. Before the prosecution of the code, the coordinates of start and endpoints of both links were derived using trigonometry.
2. The length of links and the range of θ1 and θ2 were defined in the code.
3. For loop was executed to plot positions of both link at every value of θ1 and θ2.
4. Inside the second for loop, the derived equations for every point is defined.
5. Plt command was given to plot the lines representing Link1 and link2 using coordinates.
6. Using plt.savefig(filename), all plot figures were saved siquencially with proper names.
7. All figures were combined to create an animation.
ERROR FACED: No error encountered
CONCLUSION:
Using PYTHON programming, the written code simulates the position of a 2R-Robotic Arm. The results show the maximum reach of the robotic arm used to perform the different industrial applications.