2R Robotic Arm Simulator using PYTHON
Aim:
To write a code and simulation of forward kinematics of 2R robotic arm
Introduction:
l1=length of link 1
l2=length of link 2
θ1=inclination angle of link 1
θ2=inclination angle of link 2
x0,y0 origin points
(x0,x1),(y0,y1) coordinate of link 1
(x1,x2),(y1,y2) coordinate of link 2
x1=l1*cosɵ1
y1=l1*sinɵ1
x2=x1+(l2*cosɵ2)
y2=y1+(l2*sinɵ2)
x2,y2 are length coordinate of link 2 from the origin
Code for forward kinematics
import matplotlib.pyplot as plt
import math
import numpy as np
angle1=math.pi/8
l1=1;
l2=0.5
x0=0
y0=0
ang1=np.linspace(angle1,math.pi/2,10)
ang2=np.linspace(angle1,math.pi/2,10)
ct=1
for a1 in ang1:
for a2 in ang2:
x1=l1*math.cos(a1);
y1=l1*math.sin(a1);
x2=x1+l2*math.cos(a2);
y2=y1+l2*math.sin(a2);
file='test%05d.png'%ct
plt.figure()
plt.plot([x0,x1],[y0,y1]);
plt.plot([x1,x2],[y1,y2])
plt.xlim([0,2])
plt.ylim([0,2])
plt.savefig(file)
ct=ct+1
In 2R robotic arm means 2 rotational joints in robot.Both arm have different angle of rotation.Based on the angle,the arm rotates.Initially the angle values are obtained by using the linspace command.For the first position of link 1,all the possible position of link 2 is obtained and it saved in separate file.Similar to the first position all position of link 1 is setuped and corresponding link 2 position are identified.All image data are stored in separate files.All images changed into animation using image magick software
Thank You