Project

2R Robotic Arm Simulation

2R ROBOTIC ARM SIMULATION USING FORWARD KINEMATIC CONCEPTS

-- > Concept of Forward kinematics

  • Use of the kinematic equations of a robot to compute the position of the end-effector from specified values for the joint parameters.
  • Positions of particular parts of the model at a specified time are calculated from the position and orientation of the object, together with any information on the joints of an articulated model.
  • Kinematic chain is a number of rigid links connected together such that it gives a constrained or the desired motion.

--> Code

# Program to simulate the motion of a robo arm
# by namit

import math
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import matplotlib.animation as animation


plt.rcParams.update({'figure.max_open_warning': 0})

# length of the links (mm)
l1 = 1
l2 = 0.6

# number of theta in a range
n_theta = 10
theta1_start = math.pi/6
theta1_end = math.pi/2
theta2_start = -math.pi/4
theta2_end = math.pi/3

# Angle of rotation of links
theta1 = []
theta2 = []

# origin point or the fixed point of the link 1
x0 = 0
y0 = 0

filename = range(0, 100)

#counter_variables
i = 0
y = 1

for i in range (0, n_theta):
    tmp1 = theta1_start + i*(theta1_end - theta1_start) / (n_theta - 1)
    tmp2 = theta2_start + i*(theta2_end - theta2_start) / (n_theta - 1)
    i = i + 1
    theta1.append(tmp1)
    theta2.append(tmp2)

for t1 in theta1:
    for t2 in theta2:
        x1 = l1 * math.cos(t1)
        y1 = l1 * math.sin(t1)
        x2 = x1 + l2 * math.cos(t2)
        y2 = y1 + l2 * math.sin(t2)
        filename = str(y) + '.png'
        y =+ 1

        #plot the co-ordinates
        fig = plt.figure()
        plt.plot([x0, x1], [y0, y1],color = "green", marker = 'o', linewidth = 7.0, markersize = 10)
        plt.plot([x1, x2], [y1, y2],color = "blue", marker = 'o', linewidth = 7.0, markersize = 10)
        plt.plot(x1, y1, marker='o',color = "black", linewidth=7.0, markersize=10)

        #Plot Legends
        green_patch = mpatches.Patch(color='green', label='Link 1')
        blue_patch = mpatches.Patch(color='blue', label='Link 2')
        black_patch = mpatches.Patch(color='black', label='Link Connector')
        plt.legend(handles=[green_patch, blue_patch, black_patch,])

        #Plot Labelling
        plt.xlabel('X co-ordinates')
        plt.ylabel('Y co-ordinates')

        #Plot Title
        plt.suptitle('2R Robotic Arm Simulation')
        plt.title('Forward Kinematics')

        plt.xlim([0, 2])
        plt.ylim([0, 2])
        plt.savefig(filename)
#End
  • In this program I have considered a pair of links as kinematic chain connected at a point called joint.
  • So, to simulate the robotic arm we need to calculate the all possible co-ordinates for all possible floating points in the model.

Image 1

  • According to Image 1 of the kinematic chain total of 3 points are collected as joints.

Point A: origin or the fixed point. Link 1 starts from point A.

Point B: connecting point or joint. Link 1 and Link 2 connects at this point.

Point C: Manipulating point or end point. Link 2 ends at this point.

  • Since point A is fixed its co-ordinates remains fixed as (x0, y0). Also point B and C are floating so they have dynamic values of co-ordinates.
  • Suppose (x1, y1) and (x2, y2) for B and C respectively. Using the rule of Forward kinematics, the values of these co-ordinates is calculated:

(x0, y0) = (0, 0)

(x1, y1) = (l1cosθ1, l1sinθ1)

(x2, y2) = (x1 + l2cosθ2, y1 + l2sinθ2)

Where,

l1 and l2 are length of the link 1 and link 2 respectively.

θ1 and θ2 are the angle formed by the link 1 and link 2 with the horizontal respectively.

Values of θ vary for different positions of point B and C.

--> Output

  • The above animation shows the motion of manipulator using the concept of forward kinematics.
  • The kinematic chain formed has 4 degree of freedom (DOF)i.e. 2 translation motion (along X and Y) and 2 rotary motion (clockwise and counter clockwise)

Link 1: Since point A is fixed it has only 2 DOF i.e. 2 rotational

Link 2: Since both the points (B and C) are floating it has 4 DOF i.e. 2 translation and 2 rotational

  • The motion of the kinematic chain is achieved by calculating different co-ordinates of floating points i.e. B and C and plotting it in the graph.

Image 2

Image 3

  • It can be seen from the image 2 that the locus of the co-ordinates for point B is constrained to form a circle with radius equal to length of link 1 and centre as point A. but from image 3 locus of point C may or may not be a circle depending upon the position of the point B.For Fixed point B, C has circular locusFor floating point B, point C has a relative velocity and hence a spiral type shape formed when locus is plotted.

Youtube Link of Output: https://youtu.be/nZ31ezlP350

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.