Challenge

Week 2- 2R Robotic Arm Challenge

AIM:

To Simulate Forward Kinematics of a 2R Robotic Arm using MATLAB program.

OBJECTIVES:
1.) To demonstrate forward kinematics of robotic arm.
2.) Creating an animated video to show different position of links.
3.) To explain the full explaination of the Matlab program.

Theory Required
A robot arm is a type of robot consisting of parts linked together in the same way as those of a human arm, posessing relatve motion with one another that are programmed to execute a specific task or job quickly, efficiently, and extremely accurately.
They’re most often used for the rapid, consistent performance of heavy
and/or highly repetitive procedures over extended periods of time, and are especially valued in the industrial production, manufacturing, machining and assembly sectors.
It must be noted that the kinematics of robotic arm is restricted to 2-D Plane.

Program

clear all
close all
clc
% Inputs
% Length of Link1 and Link2 in meters (m)
L1=1;
L2=0.5;
% theta_1 and theta_2 are the orientation of the links in Degrees
theta_1=linspace(0,90,11);
theta_2=linspace(0,90,21);
% Initial Coordinates of Link 1
x_0=0;
y_0=0;
ct=1;
% Taking values of Theta_1 & Theta_2 in order
for i=1:length(theta_1)
THETA_1 = theta_1(i);
for j = 1:length(theta_2)
THETA_2=theta_2(j);
% Final Coordinates of Link1 and starting coordinates of link 2
x_1=x_0+L1*cosd(THETA_1);
y_1=y_0+L1*sind(THETA_1);
% Calculating the coordinates of the end of link-2
% End coordinates for link-1 and starting coordinates for link-2
x_2=x_1+L2*cosd(THETA_2);
y_2=y_1+L2*sind(THETA_2);
% Simulation & Plotting of robotic arm
plot([x_0 x_1],[y_0 y_1],[x_1 x_2],[y_1 y_2], "linewidth",2);
axis([-0.1 1.5 0 1.5]);
pause(0.03);
% Getting the frame identified by the handle ct
M(ct) = getframe(gcf);
% Incrementing ct so that each frame is captured in M
ct=ct+1;
end
end
% Making a movie from collected frames
movie(M);
% Creating a video file of '.avi' format to save the animation
videofile=VideoWriter('forward_kinematics_of_2R_robotic_arm.avi','Uncompressed AVI');
open(videofile);
% Writing the movie in the videofile created
writeVideo(videofile, M);
close(videofile);


Explaination of the program

1.) Length of the Respective Links L1 & L2 has been taken as 1m and 0.5 m.
2.) Angles traced by both Links has been taken into consideration over a range for simulation.
3.) Initial Coordinates are x_0 and y_0
4.) x_1, x_2 & y_1,y_2 are calculated using General Mathematics.
5.) A plot is being made whhich captures each and every frame so as to get the animation.
6.) A Video File in .'avi'format is made so as to create the final animation.

Error which took place while programming.

1.) Not Varying theta_1 & theta_2 using for loops.
2.) Omission of end term after placing two for Loops.
3.) Using cos term instead of cosd.

OUTPUT

The animation can be viewed form the you tube Link as follows.

https://youtu.be/EX7MdmJHzP0

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.