Project

Simulating forward kinematics of the 2R Robotic Arm

Aim : To write a Matlab program for Simulating forward kinematics of the 2R Robotic Arm.

Objectives :

  • To gain insight of the area covered by the 2R robotic arm in 2D space.
  • To simulate the motion of the 2R Robotic arm in 2D Workspace.

Introduction:

A robot arm, or robot manipulator, is constructed from two types of joints, prismatic and revolute. A revolute joint rotates on a single plane along an axis centered at the joint, while prismatic joint moves linearly, extending along a line. The transformation from joint angles to the location of the end effector is called forward kinematics.

Theory:

We have a 2R robotic arm configuration, as shown in the figure below. Link 1 is connected to the base by a revolute joint, end of the link 1 is connected with the link 2. When link 1 one changes its angle`theta_1`, link 2 also moves in space. link 2 also have same degree of freedom as link 1. Suppose one motor is connected to rotate link2 about point (x1,y1). It will try to cover more area in 2D space. For this project, we are restricting the movement in 1_st Quadrant only. Now link can also rotate with a certain angle. Lets both `theta_1`and`theta_2` are changing by 90 degrees.

`0 <=theta_1<=90`

`0<=theta_2<=90`

Here,

Length of the link1 = 1 m;

Length of the link2 = 0.5m;

`theta_1` = angle traced by the link1;

`theta_2` = angle traced by the link2.

We will be basic equations to calculate the position of the robotic arm and trace its motion as it moves.

Suppose, just for this we will be moving `theta_2` by completely for a change in `theta_1`.

Code for simulating the motion:

% Program to simulate the kinematics of the of 2R Robotic arm
clear all
close all
clc

%Assigning input variables
 
 l1 = 1;                                    % Length of the link 1 (m)
 l2 = 0.5;                                  % Length of the link 2 (m)
 
%Angle through which link 1 is changing (Degrees)
theta1 = linspace(0,90,10);                 %linspace for dividing the interval in equal parts%


theta2 = linspace(0,90,10);                %Angle through which link 2 is changing (Degrees)

% Main Code for doing the kinematics
ct =1;
for i = 1:length(theta1) 
    THETA1 = theta1(i)                      %taking out the first value of the theta1%
    for r = 1:length(theta2)                %For one value of theta1, theta2 is changing all its values%
        THETA2 = theta2(r)
        % Positions of the extreme points of the link (End of link1 is start of link2)
        
        x0=0;                               %Base(Fixed_point)_Link_1
        y0=0;
        % Ending point position of the link1 and starting point of the link2
        x1 = l1*cosd(THETA1);
        y1 = l1*sind(THETA1);
        % Ending point position of link2
        x2 = x1 + l2*cosd(THETA2);
        y2 = y1 + l2*sind(THETA2);
        plot([x0,x1],[y0, y1],[x1, x2],[y1, y2],'linewidth',2);
        axis([-0.1 1.5 0 1.5])
        R(ct) = getframe(gcf); 
        %to get the plot frames and save them%
        ct = ct + 1;
    end
end
%Code for creating the short movie visualizing the motion of the robotic arm
movie(R)
Videofile = VideoWriter('Forward_kinematics_of_2R_Robotic_arm','uncompressed avi')
open(Videofile)
writeVideo(Videofile,R)
close(Videofile)
        

Output :

Animation of the Robotic arm :

Thank You.

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.