Project

Animated Motion of Forward Kinematics of 2R Robotic Arm On Matlab

Aim:- To stimulate forward kinematics of 2R robotic arm with animated video.

Theory:-

The 2R robotic arm is a two link and three joint arm. It is a like a human hand used for different application like picking up objects, Joining two objects, etc. It is also used in industry for different purposes. Application depends upon the manipulator used.

The forward kinematics is used for calculating length and angle for links from which we can get information that can arm pick the object at a fixed distance. Forward kinematics refers to the use of the kinematics equations of a robot to compute the position of the end effector from specified values for the joint parameters.The essential concept of forward kinematic animation is that the positions of particular parts of the model at a specified time are calculated from the position and orientation of the object, together with any information on the joints of an articulated model.

In this program we are animating different position of link1 and link2 at different angles.

Algorithm:-

  1. The given project is performed on Matlab.
  2. The Input like length of links (l1,l2), angles made by links (theta1,theta2), starting point(x0=0,y0=0) is given.
  3. For loop is used to obtain different frames for animation. angles theta1=THETA1, theta2=THETA2.
  4. The co-ordinates of point2 is obtained for following formula:- x1=l1*cosd(THETA1) y1=l1*sind(THETA1)
  5. The co-ordinates of point3 is obtained for following formula:- x2=x1+l2*cosd(THETA2) y2=y1+l2*sind(THETA2)
  6. After obtaining co-ordinates graph is plotted using values of x0,y0,x1,y1,x2,y2.
  7. In this movie function is used for animating different frames obtained from calculation
  8. Videofile is used to save video in AVI format.
  9. The output is in the form of video.

Code for Project:-

% Forward Kinematics of 2R Robotic Arm%

%Inputs Given
l1=1;                           %Length of first link
l2=0.5;                         %Length of second link
theta1=linspace(0,90,10);       %Angle made by first link varying 0 to 90 degrees
theta2=linspace(0,90,10);       %Angle made by first link varying 0 to 90 degrees
x0=0;
y0=0;
ct=1;                           %counter to catch each frame of plot

for i=1:length(theta1)        % For loop to calculate x1,y1,x2,y2 co-ordinates for various position of arm
    THETA1=theta1(i);
    for j=1:length(theta2)   % The counter(ct) will will run for each value between 0 to 90 degrees
    THETA2=theta2(j);
    x1=l1*cosd(THETA1);
    y1=l1*sind(THETA1);

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

%Plotting graph to show different positions of arm
plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
axis([-0.1 1.5 0 1.5])
grid on
M(ct)=getframe(gcf);
ct=ct+1;
pause(0.03);                  %For interval between each execution of frame
    end
end
% To show animation of robotic arm at different angles
movie(M);
videofile=VideoWriter('Kinematics.avi','Uncompressed AVI');    % To create video file in avi format of animation
open(videofile);
writeVideo(videofile,M);
close(videofile);

Errors Occured:-

Error is corrected by using plot function instead of line function and pause is changed to 0.03

Output:-

The output of this project is in video format uploaded on youtube which link is given below:-

https://youtu.be/M_DklA-ABZE

Description:-

  • The value of length of link is taken as l1=1 and l2=0.5
  • The value of angle is changing between 0 to 90 degrees for both theta1 and theta2.
  • The starting point is taken as x0=0 and y0=0.
  • Video is in AVI format.
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.