Project

Forward Kinematic of a 2R Robotic Arm.

INTRODUCTION

A Robotic arm is a type of mechanical arm , usually programmable with similar functions to a human arm, the arm may be the of one or more than one arm in the form of links. In Robotic arm one of the link is connected to manipulaor. A manipulator may be welding tool or machining tool etc. Through programming, designing a robotic arm can handle the whole automatic industrial process. Programming a robotic arm enables manufactures to automate more and to increase their efficiency.

LAYOUT OF 2R ROBOTIC ARM

PROGRAM FOR 2R ROBOTIC ARM

% Forward Kinematic Of A 2R Robotic Arm
close all
clear all
clc

% Input
l1 = 1;                     % Length of arm 1
l2 = 0.5;                   % Length of arm 2
theta1 = linspace(0,90,10); % Values for theta 1
theta2 = linspace(0,90,10); % Values for theta 2

ct = 1;                      % Starting point of frame 
for i = 1:length(theta1)     % Determining the position of theta1 from 'i'
    THETA1 = theta1(i);      % Assigning the value of theta1 to variable
    for j = 1:length(theta2) % Determining the position of theta2 from 'j'
        THETA2 = theta2(j);  % Assigning the value of theta2 to variable  
        
        x0 = 0;                     % Coordinate of arm 1
        y0 = 0;                     % Coordinate of arm 1
        
        x1 = l1*cosd(THETA1);       % Coordinate of arm 1
        y1 = l1*sind(THETA1);       % Coordinate of arm 1
        
        x2 = x1 + l2*cosd(THETA2);  % Coordinate of arm 2    
        y2 = y1 + l2*sind(THETA2);  % Coordinate of arm 2
        
        % Plotting for both the arms or links
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
        
        % Maximum and Minimum limits for both the axis
        axis([-0.1 1.5 0 1.5])
        
        % Pause the frames at interval of time
        pause(0.03)
        
        % To get individual frames
        M(ct) = getframe(gcf);
        
        % Step by Step adding each frames
        ct = ct+1;
    end
   
end

movie(M)                 % Generate movies of frames

% Assigning the file name and profile
videofile = VideoWriter('Forward_Kinematic_Of_A_2R_Robotic_Arm.avi','Uncompressed AVI'); 

open(videofile)          %Open the video file

writeVideo(videofile,M)  % Will be joining th frames

close(videofile)         % Closing the frames






CODE DESCRIPTION

To get the program started we will be using some sort of simple commands as close all, clear all, clc.

STEP 1: Assigning the value for both the arms as length of link 1 is equal to l1 and for link 2 is equal to l2. And for l1 and l2 value is assumed.

STEP 2: Then the values for different angles made by both the arms will be as theta1 for link 1 and for and for link 2 is theta2. For using different values of theta we will be using linspace command which will be extracting the values for theta one by one.

STEP 3: Counter(ct) command will be starting the frames for each values for theta1 and theta2 for both the links.

STEP 4: Using FOR loop will make it easier to follow the each step one by one. Here when i=1 the value for theta's will be assigned as first value for THETA1. Uppercase THETA1 and THETA2 are variables which will be taking the value for theta1 and theta2, and for this countervariable is used to access the particular variable. This same for the theta2 will be using, here will be using (j) so as to locate the value of theta2 and assign it to THETA2.

STEP 5: Then it's time to assign the coordinates of both the links each having their starting point as well as ending point. Such as the starting point of link 1 is (0,0) and ending is assumed to be uaing simple trigonometric as (l1*cosd(theta1), l1*sind(theta1)). For starting point of link 2 (x2, y2) and ending point is (x1+ l2*cosd(theta2), y1+ l2*sind(theta2)). Here we are using (d) after sin and cos so as to calculate the angle in degree.

STEP 6: For animation we need to set frames and for this we need plotting for both the arms in (plot) command. Assuming the line width will make the link more visible and it's animation.

STEP 7: Setting the limits for both the axis will make the animation more compact and to view it.

STEP 8: pause(___) command will pause the frames for a set of interval of time.

STEP 9: To get individual frames we need an array which will be (M) containing each and every frames from starting point of ct=1, which will be equal to getframe this will be taking the frame one by one for different angles for both the arms.

STEP 10: After setting 1 frame it will be +1 and by this way a set of frames is created. This will be an animation.

Movie Animation

STEP 11: To generate movies of frames will be using (movie) command containing the set of frames of an animation.

STEP 12: Will be saving the animation using (VideoWriter) command having filename and profile.

STEP 13: Opening the video by (open) command.

STEP 14: We will be writing the video so as to capture the frames.

STEP 15: Now closing the video by (close ) command.

ANIMATION FOR 2R ROBOTIC ARM :

CONCLUSION : We get to know that for a known length of links for an robotic arm we would easily form an animation and workspace of manipulator for different values of angle made by different links with respect to each other.

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.