Project

forward kinematics of a robotic arm

% forward kinematics of a 2R - robotic arm
clear all
close all
clc

%inputs
l1 = 2;
l2 = 1;
theta1 = linspace(0,90,15);
theta2 = linspace(0,90,15);

%ct is a variable for storing each frame into "M" and then incrementing for
%next frame position in M
ct = 1;
%for loop for getting position of manipulator at different values of theta1
%& theta2
for i = 1:length(theta1)
    Theta1 = theta1(i);
    for j = 1:length(theta2)
        Theta2 = theta2(j);
    x0 = 0;
    y0 = 0;
    %x1 & x2 are equations to get postions of end of link 1 for various
    %theta1 values
    x1 = l1*cosd(Theta1);
    y1 = l1*sind(Theta1);
    
    %x2 & y2 are equations to get positions of end og link 2 for various
    %theta2 values
    x2 = x1+l2*cosd(Theta2);
    y2 = y1+l2*sind(Theta2);
    
    %function to plot the arms from the coordinates of link ends found from
    %equations.
    plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
    
    axis([-0.1 3.5 -0.1 3.5])
    pause(0.03)
    
    %storing each frame of graph plotted in M 
    M(ct) = getframe(gcf);
    ct = ct+1;
   
    end
    
end

%making a movie by using all the frames stored in M 
movie(M)
%saving it in an appropriate file format and naming the video file to access it easily
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI')
open(videofile)
writeVideo(videofile,M)
close(videofile)

A youtube link to the animation video made is given below

https://youtu.be/swP6SNyriAU

This has a lot of applications in the industrial field to understand the workspace of the robotic arms, even the complex ones, and hence design accordingly.

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.