Project

2R ROBOTIC ARM CHALLENGE

AIM:

To simulate the forward kinematics of 2R robotic arm using matlab.

CO-ORDINATE OF LINKS:

The above image shows the Robotic Arm

First co-ordinate of link 1:

(X0 , Y0) = (0,0)

Second co-ordinate of link 1 & First co-ordinate of link 2

(X1 ,Y1) = (l1cosΘ1,l1sinΘ1)

Second co-ordinate of link 2

( X2 ,Y2 ) = (X1+l2cosΘ2,Y1+l2sinΘ2 )

l1 = length of link 1

l2 = length of link 2

Θ1 = Angle made by link 1

Θ2 = Angle made by link 2

OBJECTIVE:

The main objective of the project is to write the code for forward kinematics of robotic arm and make the animation of it.

WORKFLOW OF THE PROJECT:

  1. Initially we assume the length of link1 and link2 and vary the angle between links and X-axis to different degrees.
  2. Then we plot the graph of the individual values.
  3. At last we merge all the plots and make the animation of the different polts obtained.

PROGRAMMING LANGUAGE USED- MATLAB

MATLAB CODE:

%A program for forward kinematics of 2R robotic arm 
clear all
close all
clc

%inputs
%length of link 1 in meters
l1=1;
%length of link 2 in meters
l2=0.5;
%angle of link 1
theta1=linspace(0,90,10);
%angle of link 2
theta2=linspace(0,360,10);

%loop counter variable ct
ct=1;
for i=1:length(theta1)
    THETA1=theta1(i);
    for j=1:length(theta2)
        THETA2=theta2(j);
        
%first coordinate of link 1       
x0=0;
y0=0;

%Second coordinate of link 1 &First cordinate of link 2
x1=l1*cosd(THETA1);
y1=l1*sind(THETA1);

%Second cordinate of link 2
x2=x1+l2*cosd(THETA2);
y2=y1+l2*sind(THETA2);

%plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'marker','o','linewidth',3);
axis([-0.1 1.5 0 1.5])
legend('link 1','link 2');
pause(0.1);
M(ct)= getframe(gcf);
ct=ct+1;
 end
end

%making of the movie from the collected frame
movie(M);
%saving the movie in avi format
videofile = VideoWriter('roboforloop.avi','Uncompressed AVI');
%opening of the video file
open(videofile);
writeVideo(videofile,M);
%closing thevideo file
close(videofile);

CODE EXPLAINATION:

  1. Initially, length of link 1 and link 2 is assigned and the angle of link1 and link2 is varied by using linspace command.
  2. After that we initialize the loop counter(ct) and use the for loops for multiple iteration to get different position of link1 and link2.
  3. After that plotting all the co-ordinate values and saving it in the variable (M).
  4. Lastly we use movie command for saving all the values from (M) for making the animation and saving it in the avi format.

OUTPUT:

The animation link is provided below:

https://youtu.be/EI5Nahj6_ss

CONCLUSION:

Thus the forward kinematics of the 2R robotic arm was successfully simulated by using matlab.

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.