Challenge

Week 2- 2R Robotic Arm Challenge

Aim :-To Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm.

Objective:- Write a program to simulate forward kinematics of a 2R RODotiC Am To create a Movie/Animation from the plots obtained from the program.

Theory:- 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 offector and it is analogous to tho human hamd -in this project, we consider a 2R robotic arm.

A 2R robotic arm represents a robotic arm with two rotations. i.e. it has two links which rotate or work over a two-dimensional plane with each of links havinga single degree of freedom.

Also, both the links are restricted to a 90 rotation with respect to the axes. Fig below shows the 2R robotic arm naving many parts as described.

1. Let,L 1 & L2 be the lengths of the link-1& link-2 Respectively

Let,THETA1 BE the angle tormed by link-l with horizontal

Let, THETA2 be the angle tormed by link-2 with horizontal

Let the starting and end co-ordinates of link-1 to be (xo,yo) and (x1 ,y1)

Let, the starting and end co-ordinates of ink-2 to be (x1, y1) and (x2,y2)

The code for the following is a s below :-

close all
clc
% Imputs
l1 = 1 ;
l2 = 0.5 ;
theta1 = linspace(0,90,12) ;
theta2  = linspace(0,90,12) ;
ct =1;
%Coordinates
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) ;
%Plotting
    plot([x0 x1],[y0 y1], [x1 x2],[y1 y2], 'linewidth', 2 )
    axis([-0.1 2 0 1.5])
    pause(0.3)
    M(ct)= getframe(gcf); % to get the current frame 
    ct =ct+1;
   
    end 
end
movie(M)
videofile = VideoWriter('robotic_arm.avi','Uncompressed AVI') ;
open(videofile)
write(videofile,M)
close(videofile)

Errors:- the only error that was displayed on the command window was that the variable M is changing size with each iteration and the editor was asking me to prelocate the value of variable M to increase the speed and efficiency of the program

Result/Conclusion :-Thus we have simulated 2R robotic arm by using the matiab programming and also created Movie/ Animation from the plots obtained from the program

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.