Challenge

Week 2- 2R Robotic Arm Challenge

2R Robotic Arm Challenge

PROGRAM

close all
clear all
clc

%INITIALISATION OF VARIABLES
theta1=linspace(0,90,20);%CREATE COLUME MATRIX TO STORE  THE ANGULAR MOVEMENT OF LINK 1 
theta2=linspace(0,90,20);% CREATE COLUME MATRIX TO STORE  THE ANGULAR MOVEMENT OF LINK 2
THETA1=0;% TEMPORARY VARIABLE TO STORE THE LINK1 ANGLE
THETA2=0;% TEMPORARY VARIABLE TO STORE THE LINK2 ANGLE
l1=1;%LENGTH OFLINK 1
l2=0.5;%LENGTH OF LINK 2
ct=1; %VARIABLE TO STORE COUNT NUMBER

%CALCULATION OF LINK POSITION
for i=1:length(theta1)
    THETA1=theta1(i);% STORING THE VALUE OF LINK 1 INTO TEMPORARY VARIABLE THETA1
    for j=1:length(theta2)
        THETA2=theta2(j);%STORING THE VALUE OF LINK 2 INTO TEMPORARY VARIABLE THETA2
        
        x0=0;
        y0=0;
        
        x1=l1*cosd(THETA1);% FINDING X COORDINATE OF LINK1
        y1=l1*sind(THETA1);% FINDING Y COORDINATE OF LINK1
        
        x2=x1+l2*cosd(THETA2); % FINDING X COORDINATE OF LINK2
        y2=y1+l2*sind(THETA2);% FINDING Y COORDINATE OF LINK2
        
        %PLOTTING
        figure(1)
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3) %COMMAND TO PLOT THE KINEMATIC LINK SYSTEM
        legend('LINK 1','LINK 2')%DISPLAY THE LINK IN THE PLOT
        title('2R ROBOTIC ARM SIMULATION')% TITLE OF THE PLOT IS DISPLAYED
        axis([-0.1 2 -0.25 2])%REGION OF SPECIFICATION WHERE PLOT IS TO BE DISPLAYED
        pause(0.1) % PAUSE THE PLOT COMMAND
        
        %OBTAINING FRAME OF PLOT AND SAVNG INTO A ARRAY M
        M(ct)=getframe(gcf);
        ct=ct+1;%INCREAMENTING THE COUNT VALUE
    end
end

%CREATE ANIMATED VIDEO
movie(M)% PLAY THE ARRAY M ONCE TO DISPLAY
videofile=VideoWriter('forward_kinematics.avi','Uncompressed AVI'); % TEMPORARY FILE 'videofile ' TO SAVE THE FRAMES
open(videofile)
writeVideo(videofile,M)%WRITE THE 'videofile' WITH M ARRAY CONTAING FRAMES
close(videofile)

Aim:

  1. To find the final position of the manipulator if the link anles theta 1 and theta2 are given
  2. To simlate the link mechanism of a 2R Robotic arm and save the animated file in the system

A mechanical linkage is an assembly of systems connected to manage forces and movement. The movement of a body, or link, is studied using geometry so the link is considered to be rigid. The connections between links are modeled as providing ideal movement, pure rotation or sliding for example, and are called joints. A linkage modeled as a network of rigid links and ideal joints is called a kinematic chain.

In the current study 2 link system is modelled as Robotic Arm at the end wich manipulator is stationed. The program involve movement of the link system over different time. 2 links are stationed such that the link can move through an angle of 0 to 90 degrees.

Assumptions:

Length of link 1= 1.5 m

Length of link 2= 1 m

Angle through which link 1 can move= 0 to 90 degree

Angle through which link 2 can move= 0 to 90 degree

Explanation

  • Iniialisation of variables

Variables are requied to be initialsed before execution of files. The specification of the variables are initialised as below

theta1=linspace(0,90,20); %COMMAND TO FIND THE ANGLES BETWEEN 0 T 90 WITH 20 VALUES

theta2=linspace(0,90,20);%COMMAND TO FIND THE ANGLES BETWEEN 0 T 90 WITH 20 VALUES

THETA1=0;%INITIALISING THE VARIABLE FOR CALCULATION OF POSITION 1

THETA2=0;%INITIALISING THE VARIABLE FOR CALCULATION OF POSITION 2

l1=1.5;% LENGTH OF LINK 1 IS ASSIGNED WITH 1.5 M

l2=1; % LENGTH OF LINK2 IS ASSIGNED WITH 1 M

ct=1; % INITIALISATION OF VARIABLE FOR COUNT VALUE

  • Calculation of link position

for i=1:length(theta1);

THETA1=theta(i);

for j=1:length(theta2);

THETA2=theta(j);

x0=0;

y0=0;

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.1)

  • Create Animated file

M(ct)=getframe(gcf);

movie(M)

videofile= VideoWriter('forward_kinematics','Uncompressed AVI')

open(videofile)

writeVideo(videofile,M)

close(videofile)'

Results

2R robotic arm of the system provide an animated video which can be downloaded by clicking into the below link.

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

The video shows that as the link 2 completes its full movement of 0to 90 degree after which the link 1 moves to the next position. The movement continues till the link 1 moves to 90 from the horizontal axis.

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.