Challenge

Week 2- 2R Robotic Arm Challenge

% FWD kinematics of a 2R robotic ARM(multiple output/animation)
% With for loop
clear
close
clc


%input
l1 = 1;                          %pre-defining the length of arm
l2 = 0.5;                        %pre-defining the length of arm
theta1 = linspace(0,90,10);      %angle for link 1 which contains 10 values
theta2 = linspace(0,90,10);      %angle for link 2 which contains 10 values 

ct = 1;                          %using counter
for i = 1:length(theta1)          %using for loop to get animated fig
    THETA1 = theta1(i);
    for j = 1:length(theta2)
        THETA2 = theta2(j);
        x0 = 0;                    %x coordinate
        y0 = 0;                    %y coordinate

        x1 = l1*cosd(THETA1);      %cosd is used to input value in degree
        y1 = l2*sind(THETA1);      %sind is used to input value in degree

        x2 = x1 + l2*cosd(THETA2);     %
        y2 = y1 + l2*sind(THETA2);     %

        %plotting graph
        
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
        axis([-0.1 1.5 0 1.5])
        title('Robotic ARM Animation ')
        pause(0.01)
        M(ct)=getframe(gcf);
        ct = ct+1;                 %incrementing value of counter by 1 
    end
end

%using Movie code to generate a video/animation
movie(M)
videofile = VideoWriter('Robotic_arm_2R','Uncompressed AVI');     %saving file in avi format
open(videofile)
writeVideo(videofile,M)
close(videofile)



%Explaination - 
%Robotic ARM is similar to Human ARM which is ususally programmable according to work need.
%So, in this program basically we are animating a total workspace of a
%robotic arm by calculating the length of the of arm with the number of
%possible rotational motion.

Problems faced while programming :- 

*I was unable to simulate the arm movement properly in online MATLAB.

*Ans was getting error while creating animation/movie file.

Solution for the above :-

*Run the same program using MATLAB software in pc to avoid these error.

Link for the Animation on youtube :-

https://youtu.be/Fglh2sbvW20

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.