Project

Workspace of 2R ROBOTIC ARM using Matlab Program

AIM

To determine the workspace of 2R ROBOTIC ARM and simulate the forward kinematics using Matlab Program.

THEORY

Kinematic involves analysis of motion without considering the forces causing the motion. In Forward kinematics, the equation of kinematics are solved to compute the displacement of the end effector.

  • It consist of a base, two kinematic pairs with the end effector at the 2nd
  • The length of the link 1 is `l_1` and the angle made by link 1 with the base is `θ_1`.
  • The length of the link 2 is `l_2` and the angle made by link 2 with the base is `θ_2`.
  • The angles of both the links varies from to `0^°` to `90^°`.
  • The length of the links can be computed by the basic trigonometry with `l_1cosθ` on x-axis and `l_1sinθ` on y-axis.
  • The animation of the forward kinematics is done by a matlab code.

Program to determine the workspace of 2R ROBOTIC ARM

%forward kinematics of 2R robotic arm with animation
%clearing the workspace, closing all and clearing the command window
clear all
close all
clc
%Inputs 
%Length of the First Link (m)
l1 =1;
%Length of the Second Link (m) 
l2 =0.5;
%Fixed Position of the First link 
x0 = 0;  %{x axis coordinate}
y0 = 0;  %{y axis coordinate}
%Angle swept by the links 
theta1 =linspace(0,90,19);  %{first link}
theta2 =linspace(0,90,19);  %{Second link}
ct =1;  %{Counter number}
% For each fixed angle of link1 calculating workspace of link2
for i=1:length(theta1)
    THETA1 = theta1(i);        %{indexing each angle of first link}
    for j=1:length(theta2)     
        THETA2 = theta2(j);       %{indexing each angle of Second link}
        x1 = l1*cosd(THETA1);     %{Second link x-coordinate node1} 
        y1 = l1*sind(THETA1);     %{Second link y-coordinate node1}  
        x2 = x1+ l2*cosd(THETA2); %{Second link x-coordinate node2}  
        y2 = y1+ l2*sind(THETA2); %{Second link y-coordinate node2}  
%Plotting
plot([x0 x1],[y0, y1],[x1 x2],[y1 y2],'linewidth',3);
axis([-0.1 1.5 0 1.5]); %{Axis Range}
pause(0.001);            %{to pause the program for n seconds}
M(ct)= getframe(gcf);  %{collect different frames of figures} 
ct =ct+1;              %{Increment Counter} 
    end
end
movie(M) %{Making movie of collected frame} 
%{Assigning the videoname and type}
videofile = VideoWriter('Forward_Kinematics.avi','Uncompressed AVI');
%{to open the file}
open(videofile)   
%{assigning the different frames to videofile} 
writeVideo(videofile,M) 
close(videofile) %{To close the file}

PROCEDURE:

  1. Assign the input variables such as Length of the first link `(l_1)`and length of the second link `(l_2)`
  2. The link which is attached to the base has one co-ordinate `(x_0 ,y_0)` = (0 ,0).
  3. Assign the values of `θ_1` to the variable named theta1.
  4. Assign the values of `θ_2` to the variable named theta2.
  5. For each angle `θ_1` of the first link the workspace of the second link is calculated by varying `θ_2` of the second link.
  6. for loop is utilised to calculate the workspace.
  7. command for i = 1 : length(theta1) increments the loop from an initial value of 1 to the number of elements in theta1
  8. For each fixed theta1, theta2 is computed by using another for loop.
  9. Use the plot command inside the second for loop (i.e for loop of theta2) to plot each position of the links.
  10. Use axis command for specifying the range of x-axis values and y-axis values of the plot.
  11. These plots are then saved to a variable M by using the command getframe(gcf) and with a incremental counter(ct).
  12. Use the command Movie to make a video of the frames from variable M.
  13. Assign the video name and format of the video(here .avi format is used) using the VideoWriter command in Matlab.
  14. Use the command writeVideo to write the video from the variable M.
  15. Use the command close to close the Video.

RESULTS

The link to the videofile is uploaded to youtube and could be viewed below.

ERRORS & CORRECTIONS

Corrections

  • This error was due to spelling error of the code writevideo which was replaced by writeVideo later.

Corrections

  • The error due to specifying the increment counter before collecting the different frames of the figure.

CONCLUSION

The workspace of the 2R ROBOTIC ARM was simulated successfully using Matlab Program.

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.