Forward Kinematic Stimulation of a 2R Robotic Arm Using MATLAB
Aim:
To write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm.
Objective:
To execute a program for simulation and workspace of forward kinematics of a 2R Robotic Arm.
Theory:
Kinematics:
Kinematics describes the motion of bodies without reference to the forces which either cause the motion or are generated as a result of motion.
Robotic Arm:
A robotic arm is a type of mechanical arm, usually programmable with a similar function as the movement of human arm. A serial robot arm can be described as a chain of links that are moved by joints which are actuated by motors. The links of a robot are connected by joints allowing either rotational motion or translational displacement. The links of a robot can be considered to form a kinematic chain.
Robotic arm forms a key part of the industrial manufacturing process. With tools mounted on the robotic arm performs a wide range of jobs such as welding, brazing, painting, soldering, etc. There are several other types of robotic arms employed in industries and they are namely cartesian, cylindrical, polar and articulated robotic arms
An articulated robotic arm is the most popular type and has a higher DOF (Degree of Freedom) and wide operation range.
These robotic technologies also provide a human-like situation in most of the cases and they can also be used in the servicing of nuclear power stations, repairing pipelines on the oceans floor or cleaning of the hazardous wastes or radioactive, etc
Workspace of Robot
The workspace of the robot manipulator is defined as the set of points that can be reached by its end effector or the space in which the mechanism is working.
Data required for Robotic Arm Stimulation:
A 2R robotic arm consists of 2 links and a manipulator/robotic arm (attached at the end of link 2). The links are connected via rotational joints
The 2R robotic arm consists of 2 links and they are as follows:
Link 1: Can be rotated by theta 1 with respect to x-axis and length l1
Link 2: Can be rotated by theta 2 with respect to x-axis and length l2
Here we need to determine the coordinates of 3 points with respect to x and y axis
Orgin point : Starting point of link 1 (x0,y0)
Intermediate point : End point of link 1 or the starting point of Link 2 (x1,y1)
End point : end point of link 2 (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)
The concepts and data required for the kinematic simulation of a 2R Robotic Arm is listed above
Program Concept
%PROGRAM USED FOR STIMULATION OF FORWARD KINEMATIC 2R ROBOTIC ARM
clear all
close all
clc
% Inputs data of links
l1 = 1.0; %length of link 1
l2 = 0.8; %length of link 2
theta1 = linspace(0,90,10); %angle made by link 1 with x axis
theta2 = linspace(0,90,10); %angle made by link 2 with x axis
ct=1;
for i=1:length(theta1) %calling number of values in theta1
THETA1 = theta1(i); %assigning theta1 values one by one in THETA1
for j=1:length(theta2) %calling number of values in theta2
THETA2 = theta2(j); %assigning theta2 values one by one in THETA2
%input values of coordinates
x0 = 0;
y0 = 0;
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);
x2 = x1 + l2*cosd(THETA2);
y2 = y1+ l2*sind(THETA2);
%Ploting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([0 2 0 2])
pause (0.1)
M(ct) = getframe(gcf); %getting the frame and storing in M
ct=ct+1;
end
end
movie(M)
videofile = VideoWriter('Forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Stimulation video link mentioned below
"Errors 1" I experienced while executing this program are listed below
clear all
close all
clc
% Inputs data of links
l1 = 1.0; %length of link 1
l2 = 0.8; %length of link 2
theta1 = linspace(0,90,10); %angle made by link 1 with x axis
theta2 = linspace(0,90,10); %angle made by link 2 with x axis
ct=1;
for i=1:length(theta1) %calling number of values in theta1
THETA1 = theta1(i); %assigning theta1 values one by one in THETA1
for j=1:length(theta2) %calling number of values in theta2
THETA2 = theta2(i); %assigning theta2 values one by one in THETA2
%error faced in the above THETA2 since 'j' has to assign instead of 'i'
%input values of coordinates
x0 = 0;
y0 = 0;
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);
x2 = x1 + l2*cosd(THETA2);
y2 = y1+ l2*sind(THETA2);
%Ploting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([0 2 0 2])
pause (0.1)
M(ct) = getframe(gcf); %getting the frame and storing in M
ct=ct+1;
end
end
movie(M)
videofile = VideoWriter('Forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Output: In the above case link 1 and link 2 covered the angle from 0 to 90 degree in an equally rather than with respect to link 1, link 2 didn't move so here motion completed in 10 steps rather than 100 steps
"Errors 2" I experienced while executing this program are listed below
clear all
close all
clc
% Inputs data of links
l1 = 1.0; %length of link 1
l2 = 0.8; %length of link 2
theta1 = linspace(0,90,10); %angle made by link 1 with x axis
theta2 = linspace(0,90,10); %angle made by link 2 with x axis
ct=1;
for i=1:length(theta1) %calling number of values in theta1
THETA1 = theta1(i); %assigning theta1 values one by one in THETA1
for j=1:length(theta2) %calling number of values in theta2
THETA2 = theta2(j); %assigning theta2 values one by one in THETA2
%input values of coordinates
x0 = 0;
y0 = 0;
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);
x2 = x1 + l2*cosd(THETA2);
y2 = y1+ l2*sind(THETA2);
%Ploting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis[(0 2 0 2)]
pause (0.1)
M(ct) = getframe(gcf); %getting the frame and storing in M
ct=ct+1;
end
end
movie(M)
videofile = VideoWriter('Forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Output :
>> stimulation_forward_kinematics_report_final
Error: File: stimulation_forward_kinematics_report_final.m Line: 31 Column: 5
Invalid expression. When calling a function or indexing a variable, use parentheses.
Otherwise, check for mismatched delimiters.
Results and conclusion
Thus executed a program for simulation and workspace of forward kinematics of a 2R Robotic Arm using MATLAB.