Project

SIMULATE FORWARD KINEMATICS OF A ROBOTIC ARM

1.AIM :

Simulate the forward kinematics of a 2R Robotic arm using MATLAB

2.GOVERNING EQUATIONS :

A 2R Robotic arm has 2 links and a manipulator as shown in figure:-

Link 1 is inclined be at an angle θ1 with the base and link 2 be at an angle θ2 with the base.

Let length of link 1 and link 2 be l1 and l2 respectively.

Coordinates of link joints are (x0,y0), (x1,y1) and (x2,y2).

Suppose link 1 is at origin so (x0,y0) will be (0,0), therefore using trignometry the other 2 coordinates will be

X1=l1*cos(θ1) and Y1=l1*sin(θ1)

X2=x1+l2*cos(θ2) and Y2=y1+l2*sin(θ2)

3.OBJECTIVES :

Objective of the project is to simulate the working of a 2R robotic arm and know its workspace.

4. MATLAB program :

MATLAB program for the same is mentioned below, the comments in the code give the explanation of each line.

%Simulate forward kinematics of 2R robotic arm program
clear all
close all
clc

%input of length of arms from user
l1=input('enter length of arm 1 : ');
l2=input('enter length of arm 2 : ');

%angle of arm 1 with the x - axis initialized as array with values varying
%from 0 to 90 degrees with a difference of 10 between two values
theta1=linspace(0,90,10);

%angle of arm 2 with the x - axis initialized as array with values varying
%from 0 to 90 degrees with a difference of 10 between two values
theta2=linspace(0,90,10);

%initializing a couter varaible
cnt=1;

%for loop for controlling the movement of arm 1
for i=1:length(theta1)

    THETA1=theta1(i);
    
    %for loop for controlling the movement of arm 2 corresponding to each
    %movement of arm 1
    for j=1:length(theta2)
    
        THETA2=theta2(j);
        
        % calcultion of coordinates
        x0=0;
        y0=0;

        x1=l1*cosd(THETA1);
        y1=l1*sind(THETA1);  

        x2=x1+l2*cosd(THETA2);
        y2=y1+l2*sind(THETA2);
        
        %plotting the coordinates of arm
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
        axis([-0.1 1.5 0 1.5]);
        pause(0.3);
        
       % storing the current plot figure in an array 'A' at position of value of ct
        A(cnt)=getframe(gcf);
        
        %increasing the value of counter by 1
        cnt=cnt+1;
        
    end
end

%command to generate the movie of array 'A'
movie(A);

%creating a video named forward_kinematics_animation of type '.avi'
videofile=VideoWriter('forward_kinematics_animation.avi','Uncompressed AVI');

%opening the videofile
open(videofile);

%write the movie generated using array 'A' to the videofile
writeVideo(videofile,A);

%closing the videofile
close(videofile);

Tne animation video obtained by the program can be viewed using the below link:-

https://youtu.be/5UV-ekcDMH0

Errors faced:-

1) The syntax of command movie() was wriiten wrong, as it can be seen in imahe the letter 'm' was capitalized.

2) The limits in for loop for the variables 'i' and 'j' was set wrong, although the results were correct but it won't work in any other situtation.

5.CONCLUSION :

The workspace of the robotic arm can be easily determined by plotting the position of arm at different angles and combining those plots into an animation. Detemining the workspace helps to know the area covered and it will make the designing process easier.

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.