Project

stallone s j

AIM : To create a program in python to simulate the forward kinematics of a 2R Robotic Arm and to Create a animation file of the plot.

EXPLANATION:-

We take the base of link 1 to be fixed at origin hence its coordinates will be (0.0) and if `theta`1 is the angle of inclination of link 1 then the coordinates of end of link 1 will be (x1,y1)

where, x1=l1*cos( θ1) and x2=l2*cos(θ2) and (x1,y1) is also the coordinates of initial point of link 2 and (x2,y2) is the end point of link 2 of robotic arm ,where x2=x1+l2*cos(θ2) and y2= y1+l2*sin(θ2)

The python program is as follows

import math
import matplotlib.pyplot as plt
n_theta =10
theta_start =0
theta_end =math.pi/2
#length of link 1
l1=1
#length of link 2
l2=0.5
#coordinates of base
x0=0
y0=0
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)
ct  =1  
for t1 in theta1:
   for t2 in theta2:

  	#coordinates of connector of link 1 and link 2
      x1=l1*(math.cos(t1))
      y1=l1*math.sin(t1)
    #coordinates of manuplator
      x2=x1+l2*math.cos(t2)
      y2=y1+l2*math.sin(t2)
      stall='test%05d.png' %ct
      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(stall)

      
      


RESULT:-

After saving all the plotted images we can stitch all of them to a gif fomate with the help of image magic software .later i have uploaded to youtube by converting gif file to mp4. The youtube video link is provided below.

https://www.youtube.com/watch?v=fudYbJmqPHE&feature=youtu.be

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.