Challenge

Week 2- 2R Robotic Arm Challenge

https://youtu.be/C5-XmoZPmcc

%program on forwarding kinematics of 2R robotic arm
clear all
clc

%to find the final position of manipulator, we need a few inputs such as
%length of the arm and angle at which they are oriented.

%data
l1= 2; %l1=length of first arm
l2= 1;  %l2=length of second arm

t1=linspace(0,90,7); %t1 and t2 are angle of orientation of 1st and 2nd arm respectively
t2=linspace(0,90,7); %command linspace takes the values from 0 to 90 at equal distribution of value, and of 9 units.
ms=1; %a variable is taken for iteration purpose.
%as the orientation values changes, we have taken the 'for' loop to generate
%all output orientation

%first loop takes the different values of t1(angle of 1st arm) and second
%for loop takes values of t2(angle of the second arm) and as 2nd for loop is
%inside the 1st loop, t2 is drawn on each case of t1.

for i=1:length(t1)
    T1=t1(i); %took T1 and T2 again to take incremental values of t1 and t2 for plotting
 
    for k=1:length(t2)
        T2=t2(k);

      %as base is fixed we consider it as origin
%coordinates are
       x0=0;
       y0=0;
    
       x1=l1*cosd(T1); x2=x1+l2*cosd(T2);
       y1=l1*sind(T1); y2=y1+l2*sind(T2);
        hold on
        plot([x0 x1], [y0 y1], [x1 x2], [y1 y2],'LineWidth',0.5)
        pause(0.1)
        M(ms)=getframe(gcf); %saving the inmages in variable 'M'
        ms=ms+1;
    end
end

%for saving the output animations as a video

movie(M);
videofile=VideoWriter('Robotic_arm.avi','Uncompressed AVI'); %video name is defined and also the type of video (uncompressed) is defined in
%videowriter command and saved in videofile functio
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.