Project

A program in Matlab to simulate the forward kinematics of a 2R Robotic Arm with animation

Forward kinematics of a 2R Robotic arm

Aim : To simulate the forward kinematic of a 2R Robotic arm using MATLAB

Objective :

  1. Program to simulate 2R Robotic arm.
  2. program to create animation of the plot .

Theory :

Kinematics : it is a branch of mechanics that describe the motion of points,bodies and system of bodies without cosidering the forces that cause them to move.

Forward kinematics : it is the use of kinematic equations of a robot compute the postion of the end-effector from specified valves of for the joint parameters.

These robots and various industrial applications

  • welding in automobile insidutries
  • assembly operation
  • spray painting of automobile bodies
  • laser cutting for accurate cutting
  • machine loading and unloading

Project setup :

  • It consist of a base, two arms or kinetic links and two rotational joints. These links will have motion once programmed.
  • The link 1 will make an angle theta1 with respect to the base,similarly link 2 will mae an angle theta2 with respect to link1.
  • now we need to create a plot for various angular position up to which these arms can move,for this we need to identify the co-ordinates.
  • at the base the co-ordinates will be (0,0),at the end of first link and starting of second link the co-ordinates will be (x1,y1) and finally the co-ordinates al the end of link2 (manipulator) will be (x2,y2).

(i.e)

x0 = 0 , y0 = 0 (at the base)

x1 = l1*cos(THETA1) , y1 = l1*sin(THETA1)

x2 = x1+l2*cos(THETA2) , y2 = y1+l2*sin(THETA2)

PROGRAM CODE :

% program to simulate the forward kinematic of a 2R robotic arm 


clear all
close all
clc

%input

l1=1; %length of link1
l2=1; %length of link2

theta1=linspace(0,90,10); %range of motion of angle for link1 
theta2=linspace(0,90,10); %range of motion of angle for link2

gg=1; %counter for iteration

for i=1:length(theta1) %for loop to iterate the position of link 1
   
    THETA1=theta1(i);
    for j=1:length(theta2) %for loop to iterate the position of lion 2 with respect to link 1
       
        THETA2=theta2(j);
        x0=0;  %start postion of link 1
        y0=0;

        x1=l1*cosd(THETA1); %end point of link1 and start point of link 2
        y1=l2*sind(THETA1);

        x2=x1+l1*cosd(THETA2); %end point of link 2
        y2=y1+l2*sind(THETA2);
           
        %plottign the end points relative to the start point of link 1
        
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3);
        axis([-.1 3 0 3])
        pause(0.08) %to pause the frame in between iterations 
        M(gg)=getframe(gcf); % captures the frames grnerated at each count
        gg=gg+1;
       
        
    end
end

movie(M)% generates a movie by combining all the frames in the array M
%The below cmd writes the movie M to videofile under the specified name and
%file format
videofile= VideoWriter('robotic_arm2.avi','uncompressed AVI');
open(videofile)% opens the video file once the animation is defined
writeVideo(videofile,M)% writes the animatio0n to the video file
close(videofile)% to close when the video is done playing

ERROR :

Cannot find an exact (case-sensitive) match for 'videowriter'

The closest match is: VideoWriter in C:\Program Files\MATLAB\R2019b\toolbox\matlab\audiovideo\VideoWriter.m


Error in robotic_arm2 (line 48)
videofile= videowriter('robotic_arm2.avi','uncompressed AVI');
 

this error occured after compiling and then i realised this error is due to the 'v' and 'w' being in lower case. The words VideoWriter and writeVideo are imbuilt functions are case sensitive.

LINK :

link to the animation

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

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.