Forward kinematics of 2R robotic arm
Introduction
Robot kinematics applies geometry to the study of the movement of multi-degree of freedom kinematic chains that form the structure of robotic systems. The emphasis on geometry means that the links of the robot are modeled as rigid bodies and its joints are assumed to provide pure rotation or translation.
Robot kinematics studies the relationship between the dimensions and connectivity of kinematic chains and the position, velocity and acceleration of each of the links in the robotic system, in order to plan and control movement and to compute actuator forces and torques. The relationship between mass and inertia properties, motion, and the associated forces and torques is studied as part of robot dynamics.
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 substitution of the joint parameters into the kinematics equations requires solution of the set of polynomial constraints to determine the set of possible end-effector locations.
inverse kinematics is the mathematical process of calculating the variable joint parameters needed to place the end of a kinematic chain, such as a robot manipulator or animation character's skeleton, in a given position and orientation relative to the start of the chain. Given joint parameters, the position and orientation of the chain's end, e.g. the hand of the character or robot, can typically be calculated directly using multiple applications of trigonometric formulas, a process known as forward kinematics. However, the reverse operation is, in general, much more challenging.
Inverse kinematics is also used to recover the movements of an object in the world from some other data, such as a film of those movements, or a film of the world as seen by a camera which is itself making those movements. This occurs, for example, where a human actor's filmed movements are to be duplicated by an animated character.
%program to simulate the forward kinematics of a 2R robotic arm
clear all
close all
clc
%length of the link 1 and 2 respectively
l1 = 2;
l2 = 1;
%position of the arm in degree WRT x axis
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
%to capture the frames
ct=1;
%here the double for loop is used because for every value of theta1, in that position there will be 10 values of theta2 and thus there will be a total of 100 outputs which will be the result and for loop helps in the execution in a proper manner
for i=1:length(theta1)
T1=theta1(i)
for j=1:length(theta2)
T2 = theta2(j)
%defining the origin
x0 = 0;
y0 = 0;
%calculation for the position of x1 and y1 respectively and we have used cosd because we need the value in degree and not in radians
x1 = l1*cosd(T1)
y1 = l1*sind(T1)
%calculation for the position of x2 and y2 respectively
x2 = x1 + l2*cosd(T2);
y2 = y1 + l2*sind(T2);
%plotting the graph for the multiple positions in the arm. We can also use the line command but this is a way is much more shorter and helps us in animation as we can use the pause command to stop and the defined intervals
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
%labeling the x and y axis respectively
xlabel('x axis')
ylabel('y axis')
%to turn on the grids
grid on
% defining the axis
axis([-1 5 -1 5])
%shows the next data in every 0.1 secs
pause(0.1)
% retrieves every frame one by one and stores in the array H and ct=ct+1; increments the value to capture the next frame
H(ct)=getframe(gcf);
ct = ct+1;
end
end
% creating a video file and saving it and writing the necessary details in it
movie(H)
videofile = VideoWriter('forward_kinematics_ishaan.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,H)
close(videofile)
Result
Click here to see the animation
Animation of forward kinematics of 2R robotic arm