Project

Program to simulate the forward kinematics of a 2R Robotic Arm using Python

AIM-

To write a program to simulate the forward kinematics of a 2R Robotic Arm in Python.

OBJECTIVE-

1. To solve and simulate the forward kinematics of a 2R Robotic Arm.

2. Understand the movement of the manipulator.

3. To create the animation of working of a 2R Robotic Arm.

INTRODUCTION-

A robotic arm is a robot manipulator, usually programmable, with similar functions to a human arm. 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 use of industrial robots is increasing in areas such as food, consumer goods, wood, plastics, and electronics, but is still mostly concentrated in the automotive industry.

DIAGRAM-

INPUTS-

For our program, we have assumed the length of link 1 and link 2 to 0.5 m and 1.0 m.
In order to simulate the robotic arm, it is necessary to vary θ1 and θ2 to obtain the desired animation and it cannot be possible if we manually enter the respective data every time. So we have created a row vector for them.

t1=linspace(0,90,20) first arm can rotate 180 degree
t2=linspace(0,360,20) second arm can rotate full 360 degrees

Program Code-

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

def point(t1,t2,filename):
	#lengtht of base arm
	l1=1
	#length of secondary arm
	l2=.5
	#co-ordinates of base arm's end
	x1=l1*math.cos(t1)
	y1=l1*math.sin(t1)
	#co-ordinates of secondary arm's end
	x2=x1+l2*math.cos(t2)
	y2=y1+l2*math.sin(t2)
	#initial values
	x0=0
	y0=0
	#plot
	plt.figure()
	plt.plot([x0,x1],[y0,y1])
	plt.plot([x1,x2],[y1,y2])
	plt.xlim([-.5,1.5])
	plt.ylim([-.5,1.5])
	plt.savefig(filename)
	return 0;
#count
ct=0
#angles array
t1=np.linspace(0,math.pi/2,20,endpoint=True)
t2=np.linspace(0,math.pi*2,20,endpoint=True)

for a in t1:
	for b in t2:
		ct=ct+1
		f=str(ct)+'.png'
		point(a,b,f)

Output-

Saved files in the directory

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.