Challenge

Week 2- 2R Robotic Arm Challenge

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

A robotic arm is mechanical arm with similar function to human arm,It consist of two kinematics pairs known as link 1 and link 2 with manipulator, this manipulator joined in link2 with rotating motion (robot arm) or linear displacement. the manipulator is also called as end effector and its analogos to human hand.

The robortics arm are used for

welding

painting

automotive robot solution

package industry

Diagram

Inputs

L1 = length of link 1

L2 = length of link 2

Theta 1 = angle made by link 1 with horizontal

Theta 2 = angle made by link 2 with horizontal

CODE

clear all
close all
clc

% inputs
%length of first arm
l1 = 1;
%length of second arm
l2 = 0.5;
%angle of first arm
theta1 = linspace(0,90,10);
%angle of second arm
theta2 = linspace(0,90,10);

% initiate the counter values
ct=1;

for i = 1:length(theta1)
THETA1 = theta1(i);
for j = 1:length(theta2)
THETA2 = theta2(j);
x0 = 0;
y0 = 0;

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


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

%plotting
plot([x0 x1], [y0 y1],[x1 x2], [y1 y2], 'linewidth',3)
axis([-0.5 1.5 0 1.5])
pause(0.03)
M(ct) = getframe(gcf);
ct = ct+1;

end
end

movie(M)
videofile = VideoWriter('forward_kinematics.avi');
open(videofile)
writeVideo(videofile,M)
close(videofile)

Output

The output of this program as come out with an animation video attached at below as link

Explanation

Theta 1 and Theta 2 has initial value to calculate the link2 with equation of finding THETA 1 THETA 2 by determining

the values, by using frame counting command 'ct' is initial at matlab

The posotion of the end points for each of the links are calculated using the equation

Link 1

start point = x0 = 0 , y0 = 0

end point = x1 = x0 + l1cos(theta1)

x1 = x0 + l1sin(theta1)

Link 2

end point = x2 = x1 + l2cos(theta2)

x2 = x1 + l2sin(theta2)

The graph is plotted using plot command, the 'getframe(gcf)' used to inside the second loop(controlling second link position)

to get current frame

The Movie 'M' command is used to play the video of plotting graph

The VideoWriter command create an empty videofile by name of 'forwardKinematics' in .avi formate and its stored in videofile

Result:

https://www.dropbox.com/t/J5kg2gf9G6GHmcVS

Above link is the animation of robotics kinematics arm

() [] , . '' * %  ; = + - _
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.