Project

A program in python to simulate the forward kinematics of a 2R Robotic Arm.

A program in python to simulate the forward kinematics of a 2R Robotic Arm.

Various images wilol be created in the folder.

Combine them to create a gif animated file.

The images will be created as follows.

Create a gif animation file for all the 100 plots by using imgflip.com as shown in the outputs.

A program in python to simulate the forward kinematics of a 2R Robotic Arm is as shown below:-

import math
import matplotlib.pyplot as plt

# total number of theta
tot_theta=10

# starting and ending of theta
theta_start=0
theta_end=math.pi/2                     #use math library for using pi

# lengths of two robotic arm
l1=1
l2=0.5

# calculating theta1 and theta2
theta1=[]
theta2=[]

for i in range(0,tot_theta):
	temp=theta_start + i*(theta_end-theta_start)/(tot_theta-1)
	theta1.append(temp)
	theta2.append(temp)

# origin
x0=0
y0=0

count=1

for t1 in theta1:
	for t2 in theta2:
		# link 1
		x1=l1*math.cos(t1)
		y1=l1*math.sin(t1)

        # link 2
		x2=x1+l2*math.cos(t2)
		y2=y1+l2*math.sin(t2)

		
		filename=str(count)+'.png'          # creating file for saving plots
		count=count+1

		# plotting 
		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)
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.