Challenge

Week 2- 2R Robotic Arm Challenge

%clear all
%clc
%close all

% INPUT

% length of first arm
l1 = 1;

% length of second arm
l2 = 0.5;

% Angle of first arm
theta1= linspace(0,90,20);

% Angle of second arm
theta2 = linspace(0,90,20);

videofile=VideoWriter('Forward_kinematic_of_robotic_arm.avi','Uncompressed AVI');
open(videofile)

figure('Name','2R-ROBOTIC ARM ANIMATION')

% Starting point of first arm 
X=0;
Y=0;

for i = 1:length(theta1)
    THETA1 = theta1(i);
    for j = 1:length(theta2)
        THETA2 = theta2(j);
        
        % Ending point of first arm OR Starting point of second arm
        X1 = l1*cosd(THETA1);
        Y1 = l1*sind(THETA1);
        
        % Ending point of second arm
        X2 = X1 + l2*cosd(THETA2);
        Y2 = Y1 + l2*sind(THETA2);
        
        % Plotting
        % To plot link of arm 1 and link of arm 2 to find manipulator position on
        % each point
        plot([X0 X1],[Y0 Y1],[X1 X2],[Y1 Y2],'LineWidth',3 );

        legend('link of first arm','link of second arm')
        
        % Figure dimension
        axis ([-0.1 1.5 0 1.5])
        
      
        frame = getframe(gcf);

        writeVideo(videofile,frame)

        

    end
end

close(videofile)
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.