Project

Matlab Kinematics of a 2R Robotic Arm

In this Code we explain the kinematics of a 2R Robotic Arm:

Description: We basically define the workspace of the 2R Robotic Arm, by workspace we mean the possible locations that the robotic arm can resch, or in other words the total area that the robotic arm can cover when in motion is what is described in this code below,

We use the following formulae, to define the co-ordinates of the Robotic Arm:

x0 = 0;

y0 = 0; (This is the origin, or the point that defines the base of the robotic arm).

x1 = L1*cos (theta1)

y1 = L1*sin(theta1) (This is the next point in the robotic arm, it defines the end point of Robotic arm 1 and starting point of robotic arm 2)

x2 = x1 + L2*cos (theta2)

y2 = y1 + L2*sin(theta2) (This is the ending point of the robotic arm)

Using these formulae we code to define the workspace of the 2R Robotic Arm as given below:

%Forward Kineatics of a 2R Robotic Arm using Animation%
close all
clear all
clc
%Defining Inputs%
L1 = 0.5;
L2 = 0.5;
theta1 = linspace(0, 90, 15);       %We need an array of angles %
theta2 = linspace (0, 90, 15);      %Trying to study motion, so for each theta, we need a cooresponding position%
ct = 1;                             %We define a counter, we will use this counter in our for loop%
for i = 1 : length(theta1)
    THETA1 = theta1(i)              %Im storing the value of theta in a variable thats updates itself with each iteration%
    for j = 1 : length (theta2)     %For each theta1, there is a corresponding increment in 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)));
        
        %PLOTTING%
        %hold on%                     %We want both the plots that we plot to appear, hence we use Hold On, However it will be removed because we will be using one command for both plots%
        plot([x0 x1], [y0 y1], [x1 x2], [y1 y2], \'linewidth\', 3);
        axis([-1 1 -1 1]);        %After defining thr axis, the output will be a plot with 
        pause (0.02);                  %Pause defines the time between corresponding frames%  
        %Making the Movie File%
        M(ct) = getframe(gcf);        %we are taking each frame and storing it in an array%
        ct = ct+1;                    %we are incrementing the counter for each frame%
    end
end
movie(M)                              %we are making the movie with the array M, which contains the frames%
videofile = VideoWriter (\'ForwardKinematicsRoboticArm.avi\',\'Uncompressed AVI\');
open(videofile);
writeVideo(videofile, M);
close(videofile);       

Results:

Screenshot of the motion of the Robotic Arm:
\"Robotic

The link to access the video is as given below:
https://drive.google.com/file/d/14gTqBXLhbJgd0yPoRVSHTFma9NNVaHbk/view?usp=sharing

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.