Project

  • AIM:- Simulation of forward kinematics of 2R robotic arm in MATLAB
  • THEORY:- 2R robotic arm is mechanism of mainly three links in which one is fixed and other two is movable. All the link are joint to each other with a turning joint and the position of output link varies with input link. Here, we have to simulate the all the position of links with respect to each other by using MATLAB.
  • ASSUMPTION:- Here, I am taking the input link as link1 and output link as link2 and the position of one end of link1 is at (x0,y0) and other common end between both links is (x1,y1) and the position of output of link2 is (x2,y2). Here,I am going to simulate the kinematics of links only between 0 to 90 degree angle. I am considering the length of link1 is 1 and length of link2 is 0.5 .

PROCEDURE:- To simulate the kinematics of arms firstly i am gonna try to plot the pictorial view of link on the MATLAB i.e I will draw the plot

% plotting of forward kinematics
clear all
close all
clc

%inputs 
l1 = 1;
l2 = 0.5;

theta1 = 45;
theta2 = 30;

x0 = 0;
y0 = 0;
x1 = l1*cosd(theta1);
y1 = l1*sind9theta1);
x2 = x1+l2*cosd(theta2);
y2 = y1+l2*sind(theta2);

% plotting

line([x0 x1],[y0 y1],'linewidth',3,'color','b');
line([x1 x2],[y1 y2],'linewidth',3,'color','r');
 

of link1 and link2 at some random position by using LINE command the result will be

After plotting the pictorial view now to simulate the kinematics at all the position we have programme it for every position and all the input position should be change gradually so that we can demonstrate the behaviour of output link.

For this now i am taking the range of theta1 and theta2 upto 90 degree and setting it's range in 10 segments i.e demonstrating it at 1o input position of link1 withinn 0 to 90 degree.Now,for changing inputs automatically in MATLAB i will use loop command so that input angle can vary one after one and to plot it we will use counter(ct) command and to generate plot of every position use figure(ct) and hold on after run it, will get all positions plot but i have to combine all the frame in one plot and make a simulation of kinematics of links. So, for making the animation of all  the frame i will use M(ct)=getframe(gcf) it will collect all the frame and dump into one file by using it to create a movie use movie(M) command and make videofile by using VideoWrite.  

% forward kinematics of 2R Robotic arm

clear all
close all
clc

%inputs

l1 = 1;
l2 = 0.5;

theta1=[0,90,10];
theta2=[0,90,10];

ct=1
for i=1:length(theta1)
     THETA1=theta1(i);
for j=1:length(theta2)
     THETA2=theta2(j);
  
   x0 = 0;
   y0 = 0;
   x1 = l1*cosd(THETA1);
   y1 = l1*sind(THETA1);
   x2 = x1+l2*cosd(THETA2);
   Y2 = y1+l2*sind(THETA2);

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('forward_kinematics.avi','uncompressed AVI');
open(videofile)
writevideo(videofile,M);
close all

finally,result will be

<iframe frameborder="0" src="https://www.facebook.com/plugins/video.php?href=www.facebook.com/100009692771846/videos/1157147677951647&show_text=0&width=560" scrolling="no" allowtransparency="true"></iframe>

CONCLUSION :- By using this simulation we can easily analyze the area of workspace of  robotics arms if we want then we can also find out here the angular velocity and acceleration of links.

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.