Project

TO SIMULATE THE FORWARD KINEMATICS OF A 2R ROBOTIC ARM

AIM :-

(i) To simulate the forward kinematics of a 2R Robotic arm.

(ii) Finding the final position of the manipulator.

(iii) plotting the position coordinates and creating a animated file for the same.

FORWARD KINEMATICS:- The use of the kinematic equations to compute the position of the end-effector from specified values for the joint parameters.

STEPS USED AND REPRESNTATION OF THE 2R ROBOTIC ARM :-

STEP 1:- Length of Link 1 = L1

  • start point (X0,Y0)=(0,0)
  • End point (X1,Y1) = (L1 cos(theta1), L2 sin(theta1))

STEP 2:- Lenth of Link 2 = L2

  • start point (X1,Y1) = (L1 cos(theta1), L2 sin(theta1))
  • End point (X2,Y2) = (X1+L2 cos(theta2), Y2+L2 sin(theta2))

STEP 3:- calculating the solution set

  • (x0,y0) (X1,Y1) (X2,Y2)

STEP 4:- plotting of graph for links and creating animation file

PROCEDURE:-

  • Length of links will be given.
  • For different positions of links different theta values will be provided by using linspace command and for to execute repeatedly for loop is used.
  • Plot command is used to draw the solution set.
  • To capture and store getframe() command is used
  • Videowriter() command is used to animate and to save the videowriter.

PROGRAM:-

clear all

close all

clc

% inputs

L1 = 1;

L2 = 0.5;

% angles

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)

% coordinates

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.2 3.5 0 4])

pause(0.02)

M(ct) = getframe(gcf);

ct = ct+1;

end

end

% animation file

movie (M)

videofile = VideoWriter('forward_kinematics.avi','uncompressed AVI');

open(videofile)

writeVideo(videofile,M)

close(videofile)

EXPLANATION FOR PROGRAM:-

  • clear all – used to clear all the workspace variables

close all – used to close all the plot output window

clc – used to clear the command window

  • L1 = 1 (length of link 1)

L2 = 0.5 (length of link 2)

  • Theta1 = linspace (0,90,10) :- Theta1 stores the value of link 1

Theta2 =linspace(0,90,10):- Theta 2 stores the values of link 2

  • Linspace command = to make equal intervals between 0 and 90 .

  • For loop = to repeat statement

  • ct =1 (counter is initialized to 0 )

  • for i=1:length(theta1)- for loop between 1 to length of theta1 range and THETA1 stores these values

for j=1:length(theta2)- for loop between 1 to length of theta2 range and THETA2 stores these values

  • x0 = 0;

y0 = 0;

x1 = L1*cosd(THETA1) ( d= theta values in degree)

y1 = L1*sind(THETA1)

x2 = x1+L2*cosd(THETA2)

y2 = y1+L2*sind(THETA2)

  • plot command is used to draw the solution set.
  • axis ([-0.2 3.5 0 4]) used to sets axis limits taken range (-0.2 to 3.5) for X-axis & (0 to1.5) for yaxis.
  • pause (0.02) for smooth plot and animation.
  • M(ct)=getframe(gcf) (Gets a frame from the figure or plot)
  • End – used to terminate the plot.
  • Movie(M) -plays the movie in matrix M once
  • Videofile = VideoWriter('forward_kinematics.avi','uncompressed AVI')- additionally applies uncompressed avi properties to this video write data on avi file
  • open(videofile)-used to open video for writing a video data
  • writeVideo(videofile,M) - to write video data to file
  • close(videofile) - used to close file for writing video data

OUT PUT:- Find the youtube link for the animated file

https://www.youtube.com/watch?v=IXoHITU7q9E

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.