Challenge

Week 2- 2R Robotic Arm Challenge

AIM:-

Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm.

OBJECTIVE:-

  • To solve and simulate the forward kinematics of a 2R Robotic Arm and under satnd the movement of manipulator.
  • To create the animation of working of a 2R Robotic Arm.

%FORWARD KINEMATICS OF 2R ROBOTIC ARM MANIPULATOR

clear all
close all
clc

%INPUTS

%l1 is the length of the first link
l1 = 1;
%l2 is the length of the second link
l2 = 0.5;

%theta1 is the angle of link one
theta1 = 45;
%theta2 is the angle of link two
theta2 = 90;

%CORDINATES

%starting point of link one
x0 = 0;
y0 = 0;
%ending point of link1 and starting point of link2
x1 = l1*cosd(theta1);
y1 = l1*sind(theta1);
%ending point of link2
x2 = x1 + l2*cosd(theta2);
y2 = y1 + l2*sind(theta2);

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


%for multi motion

clear all
close all
clc

%l1 is the length of the first link
l1 = 1;
%l2 is the length of the second link
l2 = 0.5;

%to define the angle path of link1
theta1 = linspace(0,90,10);

%to define the angle path of link2
theta2 = linspace(0,90,10);

%ct is the count value of frame
ct = 1;
for i = 1:length(theta1)
THETA1 = theta1(i);
for j = 1:length(theta2)
THETA2 = theta2(j);

%starting point of link one
x0 = 0;
y0 = 0;

%ending point of link1 and starting point of link2
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);

%ending point of link2
x2 = x1 + l2*cosd(THETA2);
y2 = y1 + l2*sind(THETA2);

%formula to plot animation
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'LineWidth',4)

%area of plot in which plot is formed
axis([0 1.5 0 1.5])

%to slow the animation view
pause(0.03)

%to creat a frame
M(ct) = getframe(gcf);

%to provide a individual frame to each frame
ct = ct+1;


end

end

%to make animation movie

%data from an array to the video file
movie(M)
%VideoWriter object to create a video file from an array
videofile = VideoWriter('kinematic_of_robot_arm_multimotion.avi','Uncompressed AVI');
open(videofile)

%data from an array to the video file
writeVideo(videofile,M)
%closes the figure
close(videofile)

%https://drive.google.com/file/d/1DzGfOQMCEtylmTaQLHAx7_BZ74Zka8s1/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.