SIMULATION OF FORWARD KINEMATICS OF A 2R ROBOTIC ARM
AIM:
To simulate the forward kinematics of a 2 joint robotic arm
OBJECTIVE:
To demonstrate the animation of a robotic manipulator for different angles of the 2-arm robot.
INTRODUCTION:
Robotic arm is a programmable mechanical arm used to move the end effector from a given location to the required location. It consists of links connected by joints. The business end of the kinematic chain of the manipulator is called the end effector. The end effector can be a gripper or can be designed to perform any desired task. The main applications of robotic arm include Grasping and holding objects and then move them to a new location, precise surgical procedures, scanning bar codes, welding, material handling, thermal spraying, drilling, etc.
DESCRIPTION:
Let us consider a 2 joint robotic arm with the length of arms being L1 and L2 and the angles they make with the horizontal are theta1 and theta2.
Assuming that the coordinates of the starting point of the first arm are (0,0). Therefore, the coordinates of the endpoint of first arm are
`X = L1 * cos(theta1)`
`Y = L2 * sin(theta1)`
The endpoint of the first coordinate is the starting point of the second arm. Hence the coordinates of the end points of second arm are:
`X2 = L1 * cos(theta1) + L2*cos(theta2)`
`Y2 = L1 * sin(theta1) + L2*sin(theta2)`
Thus the final position of the robotic manipulator is given by (X2, Y2)
PROCESS:
The length of both the arms is given as an input.
The degree of freedom is such that the first arm can move only 180 degrees while the second arm can move 90 degrees. The linspace command is used to create an array of the theta values for both theta1 and theta2. Two for loops are used here.
The first ‘for’ loop is used to define the position (angle) for the first arm, whereas the second ‘for’ loop is used to define the position (angle) for the second arm, for a given angle on the first robotic arm. Thus for a particular orientation of the first arm, various angular positions of the second arm can be animated.
For each value of theta1 and theta2, the (X1 Y1) and (X2 Y2) coordinates are calculated. This gives the position of the end points of the first and the second arm. After calculating the coordinates, both the arms are plotted on the graph for visualization. This process is carried out for the entire range of theta1 and theta2.
Then an animation is created by capturing the image for each of the position of robotic arms and stitching them together.
CODE:
%Animation of FORWARD KINEMATICS OF ROBOTIC ARM
clc
clear all
close all
%GIVING INPUTS TO THE LENGTHS OF THE ROBOTIC ARM
L1=1
L2=.8
%DEFINING THE RANGE OF THETA VALUES
theta1=linspace(1,180,20)
theta2=linspace(1,90,10)
ct=1
%FIRST FOR LOOP FOR FIXING THE THETA1 VALUE
for i=1:length(theta1)
T1=theta1(i)
%SECOND FOR LOOP FOR FIXING THE THETA2 VALUE
for j=1:length(theta2)
T2=theta2(j)
x1=L1*cosd(T1)
y1=L1*sind(T1)
x2=x1+L2*cosd(T2)
y2=y1+L2*sind(T2)
%PLOTTING BOTH THE ARMS
plot([0,x1],[0,y1],'linewidth',5,[x1,x2],[y1,y2],'linewidth',5,x1,y1,'s','markersize',9,'MarkerFaceColor','black',x2,y2,'s','markersize',9,'MarkerFaceColor','black',0,0,'.','markersize',30,'MarkerFaceColor','k')
axis([-2 2 -1 2])
pause(0.3)
ani=sprintf("ANI%d.png",ct)
saveas(1,ani)
ct=ct+1
endfor
endfor
RESULTS:
The animation is created. A snapshot of it is attached below.
The link for the animation is : https://youtu.be/6ImWt0PYKN0
ERRORS FACED:
The ‘movie’ function is unavailable on OCTAVE. Thus the snapshot of each image was taken and an animation was made using the gifmaker.me application.