Challenge

Week 2- 2R Robotic Arm Challenge

Google Drive Link - https://drive.google.com/file/d/1aVzmoxakrLv27T-frUdTmSU2zbRD3-Y-/view?usp=sharing

Explanation -

1) the coordinates of the arm 1 base :

x0 = 0

y0 = 0

2) the coordinates of the arm 2 base :

x1 = arm1 * cos(θ1)

y1 = arm2 * sin(θ2)

3) the coordinates of the upper end of arm2:

x2 = x1 + arm2 * cos(θ2)

y2 = y1 + arm2 * sin(θ2)

Code :

clear all
close all
clc

%inputs for length of first and second arm
l1 = 1 ;   
l2 = 0.5;

%inputs for range of angles by which the arm will rotate
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);

    
% for the increment of the frames 'ct' is used and set to value 1
ct = 1;
%for plotting the required values 
for i = 1:length(theta1)
    Theta1 = theta1(i);
    for j = 1:length(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);
        
        %for plot command
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
        %for axis command
        axis([-0.1 1.5 0 1.5])
        %for pause between the frames
        pause(0.03)
        %to capture the frame
        M(ct) = getframe(gcf);
        %for incrementing the frame
        ct = ct + 1;
       
    end
end

%for saving the animation video
movie(M)
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
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.