Challenge

Week 2- 2R Robotic Arm Challenge

Objective: To simulate the forward kinematics of 2R Robotic Arm.

Theory: A 2R robotic arm (manipulator) has two links arranged in a way that the first link is attached to the hinged support (point 1) by a rotational joint. The other end of the first link is connected to the second link by means of another rotational joint (point 2). The other end of the second link is fixed with an end effector (point 3) as shown in the following figure.

Code: The objective is to write a code that simulates the 2R robotic arm.

Let us assign the three points with following co-ordinates:

Point 1 – (X0, Y0); Point 2 – (X1, Y1); Point 3 – (X2, Y2)

The length of first link is L1 and the length of second link is L2.

The first link makes an angle θ1 and the second link makes an angle θ2 with the horizontal.

Let us assume (X0, Y0) = (0, 0).

We can calculate the other point co-ordinates as

(X1, Y1) = (L1*cos θ1, L1*sin θ1)

(X2, Y2) = (L1*cos θ1 + L2*cos θ2, L1*sin θ1 + L2*sin θ2)

Matlab Code:

%Animation of 2R robotic manipulator

clear all

close all

clc

%Inputs

L1 = 1;

L2 = 0.5;

theta1 = linspace(0,90,10);

theta2 = linspace(0,90,10);

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.1 1.5 0 1.5])

pause(0.1)

M(ct) = getframe(gcf);

ct = ct+1;

end

end

movie(M);

videofile = VideoWriter('Forward_kinematics.avi','Uncompressed AVI');

open(videofile)

writeVideo(videofile,M)

close(videofile)

Result:

The position of two links of the manipulator for various angles of θ1 and θ2 are simultaneously shown in the following figure giving an idea of the end effector workspace.

The animated file presenting the figures of the manipulator at different angles can be viewed at the following link.

https://www.youtube.com/watch?v=g2L45z-z3kI

Conclusion:

We have successfully created a video file of 2R robotic arm with both links at different angles made to the horizontal.

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.