Challenge

Week 2- 2R Robotic Arm Challenge

Aim

To stimulate the 'Forward Kinematics' of a 2R Robotic Arm using MATLAB

Objective

1. Write a program to simulate forward kinematics of a 2R Robotic Arm

2. Animating and create a movie from the plots obtained fram the program

Theory

Robotic arm:- A robotic arm is a type of mechanical arm,usually programmable,with similar functions to

human arm. The arm may be sum total of the mechanism or may be of a more comlex robot. The links

of such a manipulator are connected by joints allowing either rotational motion(such as in an atriculated

robot) or translationaal(linear) displacement. The links of the manipulator can be considered to form a

kinematic chain. The terminus of a kinematic chain of the manipulator is called the end effector and it

is analogous to human hand.

Applications:- The robotic arm are used in various applications such as

1. Welding

2. Painting

3. Automotive Robotic Solution

4. Food,Beverage,Sanitation

5. Package industry

Schemaric Diagram

Inputs

l1 = length of link 1

l2 = length of link 2

theta1 = angle made by link 1 with horizontal

theta2 = angle made by link 2 with horizontal

Matlab Code

clear all
close all
clc

%Inputs
l1 = 1;
l2 = 0.5;

theta1 = linspace(90,0,10);
theta2 = linspace(90,0,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);
    
    %Ploting
    
    plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
    axis([-0.1 1.5 0  1.5])
    pause(0.03)
    
    M(ct) = getframe(gcf)
    ct = ct+1;
    
 end
 
end

movie(M)
videofile = VideoWriter('forward_kinematics.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
    
    

Youtube Video LInk

https://youtu.be/B2mVHSExRgo

Googledrive link

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

Explanation

theta1 and theta2 arrays are initialized.A variable for frame counting 'ct' is intialized the value 1.Two for

loops are defined for controlling value of theta1 and theta2. For each value of theta1,the positions of the

two links are found out using each value of theta2.The value from theta1 and theta2 array are stored into

variables THETA1 and THETA2 for each iteration of loops.

The position of the end points for each of the links are calculated using the equations given below:-

Link 1

Start Point x0 =0,y0 = 0

End Points x1 = x0 + l1costheta1

y1 = y0 + l1sintheta1

Link 2

End Point x2 = x1 + l2costheta2

y2 = y1 + l2sintheta2

The graph is plotted using the plot command.The'getframe(gcf)'command is used insid the second loop

(controlling second link position) to get the current frame and store it as an image into the array'M'.

The videowriter command creates an empty video file by the name 'forward kinematics' in.avi format and

it is stored in the variable video file.

The writevideo command inserts the frames stored in the array'M' into the videofile.

Results

The video file was made and published.

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.