2R Robotic Arm Simulator
AIM:
forward kinematics of the 2R robotic arm using python and creating the animation of the output plots
OBJECTIVE:
1.Write a program for the forward kinematics of the 2R robotic arm using python.
2.Create an Animation from the plots obtained.
PROBLEM STATEMENT:
A robotic arm is a type of mechanical arm that is similar to the human arm. It has various segments which closely resemble the shoulder, an elbow, and a wrist. A robotic arm is programmable and can be directed to perform a variety of functions just like the human arm can.
Using the python we are going to generate the code
PROGRAM:
The code used
#Program to make 2R Robotic Arm Manipulator
import math
import matplotlib.pyplot as plt
n_theta = 10
theta_start = 0
theta_end = math.pi/2
#inputs
l1 = 1
l2 =0.5
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)
#Base of the robot
x0 = 0
y0 = 0
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)
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)
SOLUTION/CODE EXPLANATION:
First we save the sublime code with extesion .py and we intially add the math and library,After that we define the ntheta,Starting theta and ending theta along with that inputs that we have given is l1 amd l2 as 1 and 0.5.After that we creat ethe arrays for theta1 and theta2.The 'FOR LOOP' is used to create the values of theta1 and theta2 and using append command we add value to the array.Using another 2 'FOR LOOPS' we will find the values of the [x1,y1],[x2,y2].Using the plt command we will plot the images of the output and atlast using cmd we generate gif file.
RESULT:
By running the abouve code we will generate 100 images of output and using the cmd we will create a gif file of that outputs
OUTPUT:
The output obtained can find in the given link
https://youtu.be/mAHVKQRl9fg