Project

2R ROBOTIC ARM IN PYTHON

OBJECTIVE

  • To write a program in python to simulate the forward kinematics of a 2R Robotic Arm.
  • To create an animation file of the plot.

THEORY

A robotic arm (not robotic hand) is a type of mechanical arm, usually programmable, with similar functions to a human arm; the arm may be the sum total of the mechanism or may be part of a more complex robot. The links of such a manipulator are connected by joints allowing either rotational motion (such as in an articulated robot) or translational (linear) displacement. The links of the manipulator can be considered to form a kinematic chain. The terminus of the kinematic chain of the manipulator is called the end effector and it is analogous to the human hand.

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.

The kinematics equations of the robot are used in robotics, computer games, and animation. The reverse process that computes the joint parameters that achieve a specified position of the end-effector is known as inverse kinematics.

Consider the start and end co-ordinate of the link 1 is [x0, y0] and [x1, y1] and the co-ordinate of the link 2 is [x1, y1] and [x2, y2].

Where,

x0=0 , y0=0

x1=l1*cos(theta1), y1=l1*sin(theta1)

x2=x1+l2*cos(theta2), y2=y1+l2*sin(theta2)

PROCEDURE

  • initially we are going to import the 'matplotlib.pyplot' and 'math' libraries to calculate the maths and plot the graphs.
  • after that input the values of length of link1 and link2.
  • creating the different values of theta1 and theta2 using the loop command.
  • input the co-odinates of the link1 and link2 for the different theta1 and theta2 values.
  • using the counter and string command we'll provide the different names for each plots.
  • plot the graph within the limit of 0 to 2.
  • using the save command we'll save all the plots and make that plots to the animation.

PROGRAM

#program 2R Robotic arm
#by sallavoddin

import math
import matplotlib.pyplot as plt
import numpy as  np 

#inputs
l1=1         #link 1
l2=0.5       #link 2

n_theta=10

theta_start=0
theta_end=math.pi/2

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 co-ordinates
x0=0
y0=0

ct=1
for t1 in theta1:
	for t2 in theta2:

		#Link1 and Link2 connection

		x1=l1*math.cos(t1)
		y1=l1*math.sin(t1)

		#co-ordinates of the maniplators
		x2=x1+l2*math.cos(t2)
		y2=y1+l2*math.sin(t2)

		filename=str(ct)+'.png'
		ct=ct+1
		print(filename)
		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)

ANIMATION

CONCLUSION

  • we can see that the animation of the robotic arm is working properly

REFFERENCES

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.