Challenge

Week 3.2 - 2R Robotic Arm Challenge

Aim:

To simulate the forward kinematics of 2R Robotic arm using Matlab

Robotic arm:

A robotic arm is a type of mechanical arm, usually programmable, with similar functions to a human arm; the arm may be the sum total of the mechanism or may be part of a more complex robot. The links of such a manipulator are connected by joints allowing either rotational motion (such as in an articulated robot) or translational (linear) displacement. The links of the manipulator can be considered to form a kinematic chain. The terminus of the kinematic chain of the manipulator is called the end effector and it is analogous to the human hand. However, the term "robotic hand" as a synonym of the robotic arm is often proscribed.

Types of Robotic arm:

  • Articulated arm.
  • Six-axis.
  • Collaborative robot.
  • SCARA.
  • Cartesian.
  • Cylindrical.
  • Spheric

Robotic arm schematic diagram:

The main code goes as:

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

% Forward  kinematics of a robotic arm manipulator
clear all
close all
clc

%Inputs
l1 = 1;
l2 = 0.5;
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);
        x0 = 0;
        y0 = 0;

        x1 = x0 + l1*cosd(THETA1);
        y1 = y0 + 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.03)
        M(ct) = getframe(gcf);
        ct = ct + 1;
    end
end
movie(M)
videofile = VideoWriter('forward kinematics.avi')
open(videofile)
writeVideo(videofile,M)
close(videofile)

Code expalnation:

The arrays theta1 and theta2 are started. The initial value of a frame counting variable, "ct," is 1. Theta1 and Theta2 levels are controlled by two for loops. The positions of the two links are calculated for each value of theta1 using each value of theta2. For each iteration of the loops, the values from the theta1 and theta2 array are stored in the variables THETA1 and THETA2.HETA2 for each iteration of the loops.

The starting points andthe ending points are shown as here.

For Link 1

Start Point x0=0,y0=0x0=0,y0=0

End Points x1=x0+l1cosθ1x1=x0+l1cosθ1

y1=y0+l1sinθ1y1=y0+l1sinθ1

Link 2

End Point x2=x1+l2cosθ2x2=x1+l2cosθ2

y2=y1+l2sinθ2

To plot the graph we use plot command in matlab.To get the second frame 'getframe' command is used inside the second loop.

A blank.avi video file with the name "forward kinematics" is created by the videowriter command and put in the variable videofile.

The frames kept in the array "M" are inserted into the videofile by the writevideo command.

Results:

youtube video link:https://youtu.be/14ddmOQcla4.

youtube Video Link:

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.