Challenge

Week 3.2 - 2R Robotic Arm Challenge

%forward kinematics of a 2R Robotic Arm


clear all
close all
clc

%input for l1 and l2

l1 = 1;
l2 = 0.5;

%input for theta1 and theta2

theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);

ct=1;  %adding the figure one by one

% calculation of points

for i= 1:length(theta1)          %starting of foor loop of i
    THETA1= theta1(i);           %assining the value one by one from theta1
    for j= 1:length(theta2)      %starting of for loop for j
        THETA2= theta2(j);       %assining the value one by one from theta2

        x0= 0;                   %base point co-ordinate
        y0= 0;                   %base point co-ordinate

        x1= l1*cosd(THETA1);     %co-ordinate of link one 
        y1= l1*sind(THETA1);     %co-ordinate of link one 
        x2= x1+l2*cosd(THETA2);  %co-ordinate of link second
        y2= y1+l2*sind(THETA2);  %co-ordinate of link second

        %plotting
        figure(1)
        plot([x0,x1],[y0,y1],[x1,x2],[y1,y2])
        xlabel('xaxis')
        ylabel('yaxis')
        axis([-0.1 1.5 0 1.5])   %range of xaixs and yaxis
        pause(0.3)               %speed of animation
        M(ct)=getframe(gcf);     %creating animation
        ct=ct+1;                 %all figure addding in one figure and get animation

    end   % end of for loop of j
end       % end of for loop of i

%animation creation

movie(M)
videofile= VideoWriter('arm_robotic.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

%link for the output of forward kinematics of 2R robotic arm

https://youtu.be/2fogi0JH3IA

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.