Challenge

Week 2- 2R Robotic Arm Challenge

AIM :- To simulate the forward kinematic of the 2R ROBOTIC arm using mat lab

OBJECTIVES :- Write a programe to solve forward kinematic 2R ROBOTIC ARM

THEORY:- A robotic arm id a type of mechinical arm useully programable the arm may be of the wholenofnthe mechanism or mab be part of the morencomplex robot the links of such a manipulator are connected by joints allowinf either rotational motion or translaton displacment .

PROCEDURE :-

Start programming in MATLAB with thesethree commands, as all the previous calculations are erased.
clear: This command clears all the data stored in the workspace previously.
close all: This command closes all the previous figures and plots.
cle:This command clears the command window.

*Now give inputs for the length of link 1 (11) as 1 meter and link 2 (12) as 0.5 meter, theta 1 (thetai) and theta 2 (theta2) as a range from 0 to 90 degrees, 'linspace' command is used for providing equal gap points withinthe range


*Now 'for loop is used for calculating the x and y coordinates of link 1 and link 2. As "thetal' and 'theta2' are arrays and contain multiple values of angle with the x-axis,therefore, we need another variable which stores only one valve at a time so that we can get a set of x and y coordinates that are different that is why two variables are defined for theta 1 and theta 2 that are 'THETAl' and 'THETA2'. Now coordinates for the starting point of link l is defined.

*Then the coordinates of endpoints of link 1 or the coordinates of the starting point of link 2 are defined. Here 'cosd' and 'sind' is used so that the values are stored in degrees.
*Now the coordinates of endpoint of link 2 isdefined in which there is a use ofcoordinates of endpoints of link 1.


*Now plotting of all the points is done using the 'plot' command having a linewidth of 3units. The command used for differentiating the two links is "legend' which helps us to determine the links with color. The labeling of the x-axis and y-axis is done with the use of 'xlabel' command and 'ylabel' command A pause command is used for pausing the program for a certain time before processing a new set of values.


*Now for creating a movie or an animation of the results a counter variable is defined before the first "for' loop command as 'ct' and then a variable 'M' for capturing the current frame every time the 'for' command runs. Then for the increment of the frame 'l' is added to the variable 'ct'. After all this,
both the "for' loop are ended. Now for creating a complete movie a command named 'movie' is used and then fro assigning the file name and file format VideoWriter' command is used, the format used here is'.avi. Then for opening the video file 'open' command is used and then 'writeVideo' command is used which writes the video with plot frames. After this, with the
use of 'close' command the video file is closed .

*Save the program in the desired folder and then run the program by using a shortcut key i.e. 'F5' key or it can also be done with the option present in the top bar. After the successful running of the program, an animation can also be seen running and this animation is saved in the format that
you have assigned in the folder in which the program file is saved.

% forward kinematic of the 2R robotic arm 

clear all 
close all 
clc

%inputs
l1=1;
l2=0.5;

theta1=linspace(0,90,20)
theta2=linspace(0,90,20)

ct=1;
for i=1:length(theta1)
    THETA1=theta1(i);
end

    for j=1:length(theta2)
        THETA2=theta2(j);

        %coordinates fot starting point of link 1

        x0=0;
        y0=0;

        %coordinates for end points of link 1 and also starting points of
        %link 2

        x1=l1*cosd(THETA1);
        y1=l1*sind(THETA1);

        %coordinates for ending point of link 2

        x2=x1+l2*cosd(THETA2);
        y2=y1+l2*sind(THETA2);
        
        %plotting 
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],"LineWidth",3)
        axis([-0.1 1.8 0 1.8])
        legend('link1','link2')
        xlabel('x-axis')
        ylabel('y-axis')
        pause(0.01)

        %for creating the animation 
        M(ct)=getframe (gcf);
        ct=ct+1; 
    end

    
    movie(M) 
    videofile=VideoWriter("robitc.m",'Uncompressed AVI');
    open(videofile)
    writeVideo(videofile,M)
    close(videofile)

RESULTS

https://drive.google.com/file/d/1KO0oewyQcgRI3muPK-BwVb1bqp3G01ze/view?usp=sharing

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.