Project

Forward Kinematics of 2-R Robotic Arm

Aim:

To determine the workspace of the 2-R Robotic arm

Governing Equation:

`x1 = l1 * cosd(Theta1)`

`y1 = l1 * sind(Theta1)`

`x2 =x1 + l2 * cosd(Theta2)`

`y2 = y1 + l2 * sind(Theta2)`

x1, y1= end coordinates of first link

x2, y2 = end coordinates of the second link

l1, l2 = length of link 1 and 2 respectively

Theta1, Theta2 = theta for each position of the robotic arm for link 1 and 2 respectively, in which each theta is identified by iteration (for loop)

Objective:

To determine the workspace of a 2-R robotic arm for various when the length of the links are given.

First get the angles by the linspace command for 0 to 90 degree. Then identify the coordinates for the respected links to get the plots for required angles.

Explanation:

%Program to calculte the workspace of robotic arm

%forward kinematics
close all
clear all
clc

%input
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
l1 = 1;
l2 = 0.5;

%counter variable 
ct = 1

%loop to iterate over different workspaces of the robotic arm
for i = 1: length(theta1)
 Theta1= theta1(i)
 for j = 1:length(theta2)
      Theta2 = theta2(j);
    
      %coordinates
      x0 = 0;
      y0 = 0;
      %calculating x and y coordinates
      x1 = l1*cosd(Theta1);
      y1 = l1*sind(Theta1);
      
      x2 = x1 + l2*cosd(Theta2);
      y2 = y1 + l2*sind(Theta2);
      
      %plot
      
      plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
      axis([-0.1 1.5 0 1.5])
      pause(0.3);     %the interval at which each movement of arm is animated
      
      %to save the file 
      file_text = sprintf("output%05d.png",ct)
      saveas(gca,file_text)
      
      ct = ct + 1; 
 end 
end

Generate angles using linspace command which gives an array of angles of fixed length with equal intervals i.e., from 0 – 90 degree.

Initialize a counter variable for counting through the number of iterations and for using it while saving a plot.

Then initialize a for loop to iterate through theta to get the whole set of theta2 for each theta1, i.e.,.. if theta1 and theta2 have 10,10 values respectively, the for each theta1 there are 10 values of theta2.

Then plot the graph using plot command and set it axis length to

(-0.1,1.5), (0,1.5) for x and y axes respectively ,i.e. (x0,x1) and (y0,y1).

Now give each output a unique name( i.e. each position of the arm) and save it in the new file using ‘sprintf’ command using counter variable for each frame.

Then save each frame using saveas command and give gca(get current frame, file name) as parameters.

Then increase counter variable by +1 for each iteration which will be helpful in saving the file with unique name which obstructs overwriting of the old file.

Finally close the for loop using the end command.

Conclusion:

The movement of the 2-R robotic arm i.e. its workspace is determined.

Another possibility of the problem is that we can make the robotic arm for any number of angle theta, other than what I have done to determine the workspace of the robotic arm.

This is the result of the project,

https://drive.google.com/file/d/1v8TEaf7qYvh8dExh1GZv0agv63tQFEiY/view?usp=sharing

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.