Project

Forward Kinematics of a 2R Robotic Arm

Project Title: Forward Kinematics of a 2R Robotic Arm

1.AIM:

Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm

2.USED EQUATIONS AND THEROY IN THE PROJECT:

Forward kinematic is use of the kinematic equation of mechanical linkage to find the end effect of the linkages is known as a workspace, workspace is referring to possible location robot arm rich. in kinematic different joint and linkages use give the maximum workspace and degree of freedom according purpose of use.

In this project, we know two linkage and two rotary joint robotic arms. This robotic arm work two-dimensional plane. Also, both links are limit restricted up to 90 with respect to the axes.

link 1 make an angle of theta 1 respect to the x axis, link 2 make an angle of theta 2 respect to x axis. length of link 1 is l1 and length of link2 as a l2.

Starting coordinate and ending coordinate of two links are:

Link 1

Link 2

Starting coordinate

ending coordinate

Starting coordinate

ending coordinate

X0

Y0

`x1=l1*cos(theta1)`

`x1=l1*sin(theta1)`

X1

Y1

`x2=l1+l2*cos(theta2)`

`y2=l1+l2*sin(theta2)`

  1. EXPLANATION OF THE CODE:
  • Generally, program start with basic command like close all, clear all, clc.
  • Declared the variable such as length, angle and coordinates along with counter variable ct.
  • Input such as link length angle variable assign the its value angel assigned with linspace command, the value starting, and maximum varies in between angle 0 and 90 also it divides in 10 position.
  • End effecter position changing required the different position of each link use for loop
  • First for loop start 1 and goes to 90 in between iteration value declared, command use length and variable (i). The first for loop output assign the new variable theta1 that’s theta1 and output of each for loop value (i).
  • Second for loop in place in first loop same as a.
  • After second for loop output variable, declare the maths behind its each position in change its new coordinate each time such it [x0 y0], x1= l1*cos(theta1), y1= l1*sin(theta1) and position coordinate of x2 = l2*cos(theta2), y2 = l2*sin(theta2).
  • All coordinate position needs to plot the graph. Use plot command and declare the all possible coordinate, starting coordinate to ending coordinate link 1 and 2.
  • Plot graph axis’s limit defined and getframe command is used and counter variable is incremented.
  • Both for loop end.
  • Generate the animation withe command movie(m) play the movie in matrix, create video file and give the name and file format. Open the video file, close the video file.
  • In case using octave, the different command uses and only save and print it possible not generate animation file its use different software. Those two commands use before the for loop close.
clear all
close all
clc

%Inputs
l1 = 1;
l2 = 0.5;
theta1 = linspace(0,90,10);
theta2 = linspace(0,90,10);
ct = 1;
  for i=1:length(theta1)
    THETA1 = theta1(i);
    for j = 1:length(theta2)
    THETA2 = theta2(j);
    
x0 = 0;
y0 = 0;

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

x2 = x1 + l2*cosd(THETA2);
y2 = y1 + l2*sind(THETA2);

%plotting

plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
axis([-0.1 1.5 0 1.5])
grid on
pause(0.3)
text = sprintf('kinematics%d.png',ct);
saveas(gca,text)
ct= ct +1;
    end
    end

ERRORS FACED IN PROGRAMMING:

Error 1: for loop error in not command window show but it impacts on the result, the plot graph are different shape and size like a link 1 and link 2 length not properly plot.

Error 2: declaration of mathematical variable and assign value but program run give different answer

Error 3: plot syntax error

Error 4: saveas and printif syntax error.

STEPS TAKEN TO OVERCOME THE ERRORS:

Error 1 and 2 difficult to find because command windows not display the which line and which type error check in each line and line also help the matlab documentation but not possible to correct and check the program edit and run many time, each time increasing the program accuracy, finally overcome the this error.

Error 3 much simple check the syntax line and find the simple coma error and correct it.

Error 4 in also syntax error did not declare the file format.

Watch the animation on my YouTub account click the link below:

https://youtu.be/Q51wQwsQv1A

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.