Challenge

Week 2- 2R Robotic Arm Challenge

toTo write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm

Initial position of robotic arm with link length of link1= 1m & link2 = 0.5 m with angle of 45 degree & 30 degree.

% to calulate forward kinematics of 2R Robotic Arm Challenge
clear all
close all
clc

%inputs
% link length
l1 = 1;
l2 = 0.5;

thetha1=45;
thetha2=30;

% co-ordinates of arm link

x0=0;
y0=0;

x1= l1*cosd(thetha1);
y1= l1*sind(thetha1);

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

%plotting

line([x0 x1],[y0 y1],'linewidth',3,'color','b')
line([x1 x2],[y1 y2],'linewidth',3,'color','r')

With movement of robotic arm with 0 to 90 degree

%to calulate forward kinematics of 2R Robotic Arm Challenge
clear all
close all
clc

%inputs
% link length
l1 = 1;
l2 = 0.5;

thetha1=linspace(0,90,10);
thetha2=linspace(0,90,10);

for i =1:length(thetha1)
    THETHA1=thetha1(i);
    for j=1:length(thetha2)
        THETHA2=thetha2(i)

        x0=0;
        y0=0;

         x1= l1*cosd(THETHA1);
         y1= l1*sind(THETHA1);

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

%plotting

line([x0 x1],[y0 y1],'linewidth',3,'color','b')
line([x1 x2],[y1 y2],'linewidth',3,'color','r')
pause(0.1)
    end
end

To perform a perfect robotic arm action with plot code

%to calulate forward kinematics of 2R Robotic Arm Challenge
clear all
close all
clc

%inputs
% link length
l1 = 1;
l2 = 0.5;

thetha1=linspace(0,90,10);
thetha2=linspace(0,90,10);
ct=1;
for i =1:length(thetha1)
    THETHA1=thetha1(i);
    for j=1:length(thetha2)
        THETHA2=thetha2(j)

        x0=0;
        y0=0;

         x1= l1*cosd(THETHA1);
         y1= l1*sind(THETHA1);

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

%plotting

plot([x0 x1],[y0 y1],[x1,x2],[y1,y2],'LineWidth',3)
axis([-1 2 0 3])
pause(0.03)

M(ct)=getframe(gcf);
ct=ct+1;

    end
end

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

https://drive.google.com/file/d/18PmnhrfyfcFqO2G19C-Rsb3uu5FzAyKy/view?usp=sharing

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.