Week 3.2 - 2R Robotic Arm Challenge
AIM
- To trace out the expected final position of the manipulator.
THEORY
Forward Kinematics
Forward kinematics specifies the joint parameters and computes the configuration of the chain. For serial manipulators, this is achieved by direct substitution of the joint parameters into the forward kinematics equations for the serial chain. For parallel manipulators, substituting the joint parameters into the kinematics equations requires the solution of a set of polynomial constraints to determine the set of possible end-effectors locations.
Structure of Robot Manipulator
The two main parts in the robotic arm are Links and Joints. A robotic arm is a chain of joints and links.
Link: A link is defined as a single part which can be a resistant body or a combination of resistant bodies having inflexible connections and having a relative motion with respect to other parts of the machine.
Joint: A joint is a connection between two or more links, which allows some motion, or potential motion, between the connected links. Joints are also called Kinematic pairs.

Kinematics of a Robotic Arm

- In a two-joint robotic arm, given the angles of the joints, the kinematics equations give the location of the tip of the arm.
- Provided the limits for the angles of the joints, we can trace the path covered by the arms in summary. The angles of joints are made with the x-axis.
- The above figure defines the required variable considered in the code.
CODE
% Forward Kinematics of a 2R robotic arm manipulator %
close all
clear all
clc
% Inputs
l1 = 1; % length of link 1
l2 = 0.5; % length of link 2
theta1 = linspace(0,90,10); % angle between x-axis and link 1
theta2 = linspace(0,90,10); % angle between x-axis and link 2
% variable to store frames
ct = 1;
% for loop to assign the changing value of theta1 in variable THETA1
for i = 1:length(theta1)
THETA1 = theta1(i);
% for loop to assign the changing value of theta2 in variable THETA2
for j = 1:length(theta2)
THETA2 = theta2(j);
% Coordinates
% origin
x0 = 0;
y0 = 0;
% link 1
x1 = l1*cosd(THETA1);
y1 = l1*sind(THETA1);
% link 2
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
% Animation
movie(M)
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
OUTPUT
- Illustration showing all possible theta1 and theta2 values

- Animation
Error Faced
- The animation was only created with the last frame. The variable created to store each frame should be stated before starting the ‘for loop’.
- Appropriate pausing time should be considered in order to capture efficient depicting animation.