Challenge

Week 2- 2R Robotic Arm Challenge

2D ROBOTIC ARM:

It is a type of mechanical arm,usually it’s perform a similar function like a human arm.In the 2r robotics arm,the two links and manipulator were connected by the joints and the joints allow to perform either rotational motion or linear displacement.The links of the manipulator can be consider to form a kinematic chain

AIM:

To stimulate the forward kinematics of a 2R robotic arm

%  program in Matlab to simulate the forward kinematics of a 2R Robotic arm

clear all
close all
clc

% pre defined values as inputs

l1=3 %length of link1
l2=1 %length of link2

theta1= linspace(0,90,15);
theta2= linspace(0,90,15);

% defining the counter

ct=1

% initializing the angles

THETA1=0
THETA2=0

% introducing the for loop for getting path of the arm

for i=1: length(theta1);
    THETA1=theta1(i); % angle made by link 1 w.r.t to base
    for j=1: length(theta2);
        THETA2=theta2(j); % angle made by link 2 w.r.t to base
        
        x0=0;
        y0=0;
        
        x1=l1*cosd(THETA1);
        y1=l1*sind(THETA1);
        
        x2=x1+l2*cosd(THETA2);
        y2=y1+l2*sind(THETA2);
        
        % plotting graph
        
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',5,'color','r'); % plot variables
        
        axis([-5 5 0 5]); % fixing the axis
        
        pause(0.04) %time between changing plots
        M(ct)= getframe(gcf); % frames for making video
        ct=ct+1; % incrementing the counter
        
    end
    
end

% creating a movie clip

movie(M);

v= VideoWriter('Forward_Kinematics_of_2D_robotic_arm.avi','Uncompressed AVI');

open(v)         %open the video file

writeVideo(v,M) % convert image to frame

close(v)        % close video file

YOUTUBE VIDEO LINK:

2D ROBOTIC ARM ANIMATION

ERRORS FACED AND THEIR SOLUTION:

SOLUTION FOR ERRORS:

Mistyped t2 instead of theta2 and it was taken care of and similarly there have been errors like COS INSTEAD OF COSD as evrything should be in degrees and such mistype errors. Except that the rest code went without errors

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.