Project

forward kinematics motion of a robotic arm

AIM:

The main purpose of the report is to know the forward kinematics of the 2R robotic arm with respect to the change in angles.

OBJECTIVES:

  • By using different angles with the respective base, to determine the position of the robotic arm.
  • In this report, we are considering two links and two angles for the positioning of the robotic arm at various angles.
  • To create a video clip for all the frames that are saved at the positioning of the links that are acted upon using the code for each angle of input.

FORMULAS:

  • To create an equation for the robotic arm, we need to know about the links that are going to be connected and the angles at which both the links are operated with respect to a point.
  • The initial point is considered as the origin and the link 1` is connected to the point of having a fixed length.
  • For each link, we need two-point at the start and the end. The starting point for link 1 is considered as the origin and the end of the link 1 are X1 and Y1 we will get the values from the equation.
  • So, the equation for the link 1 are:

X1 = l1*cosd(theata1)

Y1 = l1*sind(theata1)

  • For the link 2, the initial points are taken as X1 and Y1 for the link 2 and the end point values for the link 2 are X2 and Y2 with respective to the theata2.
  • The values of X2 and Y2 are:

X2 = X1+l2*cosd(theata2)

Y2 = Y1+l2*sind(theata2)

  • From the above equation, we will get the values for X2 and Y2.

the code for forward kinematics motion of a robotic arm.

%program for forward_kinematics_of_a_robotic_arm
clear all
close all
clc

%input values for the arm length(meter)
l1 = 2;
l2 = 0.8;

%input angles(degrees) for robotic arm for the manoeuvre
%theata1 = linspace(1,90,20);
theata1 = [10 30 45 60 75 90 105 120 135 150 165 180];
theata2 = linspace(1,180,40);

%the count command is used to increment the value.
ct = 1;

%for loop to repeat the sequence
for i = 1:length(theata1)
    THEATA1 = theata1(i);
    for j = 1:length(theata2)
        THEATA2 = theata2(j);
        x0 = 0;
        y0 = 0;
        
        x1 = l1*cosd(THEATA1);
        y1 = l1*sind(THEATA1);
        
        x2 = x1+l2*cosd(THEATA2);
        y2 = y1+l2*sind(THEATA2);
        
        %plotting the values
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
        axis([-3 3 -3 3])
        pause(0.005)
        M(ct) = getframe(gcf);
       ct = ct+1;
    end
end

%used to create a movie with use of the frames
movie(M)
videofile = VideoWriter('forward_kinematics.avi','uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)

PROGRAM EXPLANATION:

HEADER:

  • The header consists of clear all, close all, clc.
  • The clear all is used to remove the pre-existing data in the workspace.
  • The close all command is used to close any pre-existing graphs are charts.
  • The clc command is used to clear the command window to see the output of the program.

INPUT FOR THE VARIABLES:

  • The input values are given for the length of the link in meters
  • For link 1, the length is 2 meter and for link 2, the length is 0.8 meter.
  • For the angles for each link, we consider two values for two links.
  • For the first link, the angle is theata1 and for the second link, the angle is considered as theata2.
  • To get more data points for the links we consider different angles of theata.

FOR LOOP:

  • The For-loop command is used to print the values up to the range.
  • It will follow the commands given inside the loop and will end the loop once the program is executed.
  • For loop holds the command for once and will execute the results for the value. And the data is saved in a separate variable for plotting.
  • For two different links, there are two different values of theata. To get different positions of the links we are considering the different values of theata.
  • For link 1, the theata values are given in the form of array and for theata2 the values are given by using linspace command.
  • The initial points of link 1 are considered as origin which is 0,0 and the endpoints are considered as X1 and Y1 with the help of the theata.
  • For link 2, the initial values are X1 and Y1 at the start of link 2(which means the end of link 1).
  • The endpoint of the link 2 is considered with the reference point of the X1 and Y1 by forming an equation to get the values of X2 and Y2.
  • By running this loop, we will get different points for the link 1 and link 2.
  • The plot command is used to plot the values of the link 1 and link 2.
  • The linewidth command is used for the width of the links that are shown in the simulation.
  • The pause command is used to pause the simulation for the specified period of time.
  • The axis command is used to fix the axis range from -x to x and from -y to y.
  • The get frame command is used to store each and every position of the two links.
  • The count is used to increase the count at the end after storing the frame sequentially.

ANIMATION:

  • For animation, we require to create a movie of the frames that are stored in the previous command by using the count variable.
  • The move command is used to create a video of the following frames that are stored in the M.
  • The videofile command which creates the name of the video and type of the file.
  • At the time of preparing a video, the open command is used to prepare the video file where the video is linked and the writevideo command is used to play the video back again.
  • The close command is used to close the video of the videofile.

OUTPUT:

  • The input values of the length of the link and theata values are assigned before the program is executed.
  • There are two things we need to consider at the time of moment, when the link 1 is changed to the new position the link 2 also should operate all the angles at the new position of link 1.
  • For this we require a for loop to do all these tasks that are assigned in the for loop.
  • In this task, the link 1 is operated from 10o to 180o. At each angle of link 1, the theata 2 is operated so that the link 2 will change the position from 0o to 180o.
  • This is how the link 1 and link 2 are operated to show how the robotic arm is operated by using Matlab commands.
  • The link for the output recorded video is linked from a google drive. And the supporting link to my video is given below.

https://drive.google.com/file/d/12O0g1BGgqzjfj0VbnrkOJGVH0tD8ohSk/view?usp=sharing

PROBLEM I FACED WHILE SOLVING THE TASK:

  • while creating a for loop inside a for loop is forgot to keep the end command for the first loop. So Matlab has given a warning to close the loop
  • using the command of VideoWriter in which both the v and w should be capital which I was not aware while writing the code.
  • By taking the assistance from my support engineer, I was aware of the error and rectified it.
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.