Challenge

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

x1 = x0 + L1*cos(θ1)
y1 = y0 + L1*sin(θ1)
The end position of link 1 is also the start position of link 2.
The end position of link 2 is calculated by
x2 = x1 + L2*cos(θ2)
y2 = y1 + L2*sin(θ2)
Then for each position of link 1 & link 2 a plot is made which is captured by frame to make a movie.
A video of '.avi' format is made to save movie.
The movie is then written into the videofile and the final animation is created.
Output :-
The output is obtained in the form of an animated video clip.The link is
https://drive.google.com/file/d/1_nhdNDP_mPW7cM-WLg5a2QMM--DiBpcU/view?usp=sharing
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)
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.