Week 2- 2R Robotic Arm Challenge
Introduction :-
Kinematics, as a field of study, is often referred to as the 'geometry of motion' and is occassionally seen as a branch of mathematics.
Forward kinematics :-
Forward kinematics refers to the use of the kinematic equations of a robot to compute the position of the end effector from specified values for the joint parameters.
Robotic Arm :-
A robotic arm is a type of mechanical arm usually programmable with similar funtions to a human arm; the arm my be the sum of the mechanism or may be part of a more complex robot.
Explanation of the code :-
Lengths of both the links are taken as input data.
L1 - length of link 1
L2 - length of link 2
Angles made by both the links is taken as input data.
Base position of link 1 is considered as origin(0,0)
Two loops are used to iterate the range of angles traced by both the links.( Angles are in degrees)
For a value of θ1 & θ2 the end position of link 1 is calculated by
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); % Values of angle made by link 1
for j = 1:length(theta2)
THETA2 = theta2(j); % Values of angle made by link 2
x0 = 0;
y0 = 0;
% Calculating the coordinates of end point of link 1
x1 = x0 + l1*cosd(THETA1);
y1 = y0 + l1*sind(THETA1);
% Calculating the coordinates of end point of link 2
x2 = x1 + l2*cosd(THETA2);
y2 = y1 + l2*sind(THETA2);
% Plotting
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3) % To plot the graph
axis([-0.1 1.5 0 1.5])
pause(0.03) % Time interval
M(ct) = getframe(gcf) % Cpturing the current plot to combine
ct = ct+1; % Incrementing
end
end
movie(M) % Making movie from frames obtained
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI'); % Videofile with extension '.avi'
open(videofile) % To open videofile
writeVideo(videofile,M)
close(videofile)