Project

Simulation of Forward Kinematics of a 2R Robotic Arm

Simulation of Forward Kinematics of a 2R Robotic Arm using MATLAB

Aim : Write a program to simulate the kinematics of a two link robotic arm using Matlab

Theory: Robotics is the science that deals with robot’s design, modeling and controlling. Nowadays robots are used everywhere in everyday life.A two revolute joint (2R) robot configuration with two degrees of freedom is generally well‐suited for small parts insertion and assembly, like electronic components. Although the final goal is to design and manufacture real robotics, it is very useful to perform simulations prior to investigations with real robots. Simulations are easier to setup, less expensive, faster and more convenient to use. it allows better design exploration and helps you enhance your final real robot by selecting suitable parameters for the system you want to design.

Method:

According to above figure

1. Base coordinates are provided as x0 = 0 and y0 = 0. This is taken as the base of link 2 with length length_2=1

2. Link 2 is inclined at an angle theta_1. Therefore the other point of link is calculated as

x1= length_2*cosd(theta_1)
y1= length_2*sind(theta_1)\

3.Link 1 is at an angle theta_2. Using this (x2,y2) of link can be calculated as below

x2=x1+length_1*cosd(theta_2)
y2=y1+length_1*sind(theta2_2)

4.Above steps are repeated for different inclination of the links

5.The data obtained is plotted using

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)

Program:

%forward kinematics of a robotic arm
clear all
close all
clc
%Inputs
l1=1;
l2=0.5;
%Coordinates
x0=0;
y0=0;

theta1=linspace(0,90,10);
theta2=linspace(0,90,10);
ct=1;
for i=1:length(theta1) %for loop on theta1
    
x1=l1*cosd(theta1(i));
y1=l1*sind(theta1(i));

for j=1:length(theta2) %for loop on theta2
x2=x1+l2*cosd(theta2(j));
y2=y1+l2*sind(theta2(j));

%Plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
axis([-0.1 1.5 0 1.5])
pause(0.03)

M(ct)=getframe(gcf);
ct=ct+1;
end

end
movie(M)
videofile=VideoWriter('for_kin.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

Output:

https://youtu.be/Rx1MTqoX42o

Errors encountered while programming

1.All frames are coming into the same image as the hold command use is understood in the end.

2.Random colours are given to links because of multiple use of the plot function.

Conclusion:

The simulation for 2R Robotic arm is done using Matlab and the errors occured during the simulation is also rectified properly.

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.