Project

Forward Kinematics of a 2R Robotic Arm

AIM:

To create a program that replicates the forward kimatics of a 2R Robotic Arm.

OBJECTIVE:

To not only understand the principles behind the movement of a 2R Robotic Arm but also to analyse the coding behind the same.

MATHEMATICAL MODEL:

The main equations required to conduct the simulation consist of the following in order to determine the robotic arm's start and end positions. These are given by:

- Arm 1 End 'x' Co-Ordinate = Arm 1 Length * cos(Angle b/w base and arm)

- Arm 1 End 'y' Co-Ordinate = Arm 1 Length * sin(Angle b/w base and arm)

- Arm 2 End 'x' Co-Ordinate = Arm 1 End 'x' Co-Ordinate + Arm 2 Length * cos(Angle b/w plane at the end of Arm 1 and Arm 2)

- Arm 2 End 'y' Co-Ordinate = Arm 1 End 'y' Co-Ordinate + Arm 2 Length * cos(Angle b/w plane at the end of Arm 1 and Arm 2)

MATLAB PROGRAM:

In order to conduct the final simulation, the starting co-ordinates taken for the first arm is (0,0). The length of the first arm is taken as 1m and the second as 0.5m. Finally, 20 values are considered for either angle varying between 0 and 90 degrees in order to analyse the final simulation before obtaining the required animation.

The coding for the simulation is given below:

close all
clear all
clc

l1 = 1;
l2 = 0.5;

theta1 = linspace(0,90,20); %To consider a number of angles the first link
                            %makes with the base.
theta2 = linspace(0,90,20); %To consider a number of angles the second link
                            %makes with the second base (located at the end
                            %of the first).

ct = 1;                     %Counter to increment plots of the first link
                            %after all cases of the respective 
                            %second link is completed, when plotting.

for i = 1:length(theta1)    %FOR loop to increment first link position.
    THETA1 = theta1(i);     
    for j = 1:length(theta2) %FOR loop to vary second link positions.
        THETA2 = theta2(j); 
        x0 = 0;              %Link 1 starting x-co-ordinate.
        y0 = 0;              %Link 1 starting y-co-ordinate.
        
        x1 = l1*cosd(THETA1); %Link 1 ending x-co-ordinate.
        y1 = l1*sind(THETA1); %Link 1 ending y-co-ordinate.
        
        x2 = x1+l2*cosd(THETA2); %Link 2 ending x-co-ordinate.
        y2 = y1+l2*sind(THETA2); %Link 2 ending y-co-ordinate.
        
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3) %To plot
                                                            %Robotic Arm
                                                            %positions for
                                                            %all links
                                                            %at each
                                                            %iteration.
        axis([-0.1 1.5 0 1.5])
        pause(0.01)
        m(ct)=getframe(gcf);  %To collect frames by using a new array.
        ct = ct+1;    
    end
end

movie(m)     %To allow for a smooth animation of previous plots to be 
             %obtained.
videofile = VideoWriter('Forward_Kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile, m)
close(videofile)

The youtube link for the animation obtained is available here:

https://youtu.be/KO05igrHQdk

CONCLUSION:

The required simulation was conducted successfully with no errors reported during the simulation.

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.