Stimulation of Forward Kinematics of a 2R Robotic arm
Aim of the Project:- Stimulation of a 2 joint planner robotic arm to find it's possible workspace using forward kinematics in matlab.
Background Knowledge:- A serial robot arm can be described as a chain of links that are moved by joints which are actuated by motors. An end-effector or manipulator, also called a robot hand, can be attached to the end of the chain. As other robotic mechanisms, robot arms are typically classified in terms of the number of degrees of freedom. The robotic arm is used for multiple industrial applications, from welding, material handling, and thermal spraying, to painting and drilling. The robotic technology also provides human-like dexterity in a variety of environments.
Robotic arms are widely-used tools that are capable of lifting heavy or hazardous materials that human workers could not otherwise handle. They have been used for decades in factories and laboratories and are a staple science project for middle or high school children. Like other robots, robotic arms consist of a variety of different parts that all contribute to making it properly function. The main parts are controller, arms, end-effector, drives and sensors.
Some instances where robotic arms are very handy in indutries can be seen below,
Kinematics is a branch of mathematics, physics and classic mechanical engineering. There are 2 mostly used kinematics in robotic field, they are : forward kinematics and inverse kinematics. Forward kinematics is frequently used to calculate the position of end effector when we know the degree value of each joint, meanwhile inverse kinematics is used to compute the degree of each joint when we know the position of the end effector. To calculate forward kinematic, we can use simple trigonometry.
Objectives of the project:-
- Compute the positions of the robotic arm using forward kinematics.
- Stimulate the robotic arm according to the program to know the possible workspace for the robotic arm.
- Create an animation of the stimulation of the robotic arm.
Tools Used:- Matlab
Proccedure:-
In this project, we are using a 2R robotic arm for stimulation, which has 2 links connected to each other as revolute pairs where length of link 1 and 2 are `l_1` and `l_2` respectively and degrees of rotation for link 1 and link 2 are `theta_1` and `theta_2` respectively. The link 2 is connected to a manipulator or end-effector which performs the given task. The outline of the robotic arm can be seen as,
Moreover the robotic arm has motors for the movement of the links at the location of the revolute pairs to perform human like tasks as seen below,
Condition assumed in this program is the degrees of rotation for each link of the robotic arm, which is pre-defined i.e rotation is varying from 0 degrees to 90 degrees.
Step 1:- The position of the link 1 i.e having 2 end points is calculated. The starting point is the origin of the robotic arm fixed to a support and the co-oridnates for the same is
(`x_0`,`y_0`) i.e. (0,0) and the ending point is connected to link 2 with co-oridinates (`x_1`,`y_1`) i.e. (`l_1 cos(theta_1)`,`l_1 sin(theta_1)`).
Step 2:- The position of the link 2 i.e having 2 end points is then calculated. The starting point of the link 2 is same as the ending point of link 1 as they are revolute pairs and the co-oridnates for the same is (`x_1`,`y_1`) and the ending point is connected to the manipulator or the end-effector with co-oridinates (`x_2`,`y_2`) i.e. (`x_1+l_2 cos(theta_2)`, `y_1+l_2 sin(theta_2)`)``
The schematic of the above configuration can be seen as,
The following matlab code snippet can be written for the stimulation of forward kinematics of 2R robotic arm as,
%Aim of the program is to stimulate the forward kinematics of a 2R robotic arm
close all
clear all
clc
%inputs
l1 = 1; %length of link 1 of robotic arm is 1 metre
l2 = 0.5; %length of link 2 of robotic arm is 0.5 metre
theta1 = linspace(0,90,10); %creates an array of 10 equally spaced elements and stores in theta1
theta2 = linspace(0,90,10); %creates an array of 10 equally spaced elements and stores in theta2
ct = 1;
for i = 1:length(theta1) %length(theta1) computes the number of elements in theta1
THETA1 = theta1(i); %Everytime THETA1 stores the loop incremented value of theta1
for j = 1:length(theta2) %length(theta2) computes the number of elements in theta2
THETA2 = theta2(j); %Everytime THETA2 stores the loop incremented value of theta2
%co - oridinates of link 1 are [x0,y0] and [x1,y1]
%co - oridinates of link 2 are [x1,y1] and [x2,y2]
x0 = 0;
y0 = 0;
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);
x2 = x1 + l2*cosd(THETA2);
y2 = y1 + l2*sind(THETA2);
%Plotting
plot([x0, x1],[y0, y1],[x1, x2],[y1, y2],'linewidth',5)
axis([-0.1 1.5 0 1.5])
pause(0.01)
M(ct) = getframe(gcf); %captures every frame
ct = ct+1; %counter 'ct' incremented every time inner for loop is excecuted
end
end
movie(M) %creates a movie from all the frames captured
videofile = VideoWriter('Forward_kinematics_of_a_2R_robotic_arm.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
The code snippet of the same in matlab can be seen below,
The inner for loop in the code snippet represents the 10 different positions from 0 degrees to 90 degrees of the link 2 at any single position of the link 1, while the outer for loop represents the 10 different positions of the link 1 from 0 degrees to 90 degrees. To see as a record of the variables and other parameters used in the program, the snapshot of the workspace window in matlab can be seen as,
Note the 'ct' variable at start is 1 in the program and in the workspace window shows value as 101, this shows the total number of for loops executed in the program is 100.
The output of the program is a plot of different positons of the 2 links and some snapshots of the same can be seen as,
The command written at the end of the code snippet is for creating a movie of the animation, movie of the same can be seen as below,
The program above is designed for a 2 link robotic arm with specified positions of the links, modifications of the same can be done as per requirements of more complex applications, one modification of the above is shown below which is a stimulation of a planner 3 link robotic arm,
And the animation movie for the same can be seen,
Conclusion:- In this era of mordenisation with world full of possiblities, robotic applications can yield better, faster and efficient results that can increase productivity, quality and growth for any indutry, the operations to be performed by the robotic arm can be developed as required according to the applications.