Challenge

Week 3.2 - 2R Robotic Arm Challenge

AIM :-

To Write a program in Matlab to simulate the forward kinematics of a 2R Robotic Arm, as shown in the video.

OBJECTIVE :-

simulate the forward kinematics of a 2R Robotic by Arm using the matlab.

Errors :-

1. mentioned sin cos in degrees and some links are missing

rectifiying by sind,cosd.

2. Error

x1,y1 and x2,y2 coordinate error by ,inproper giving THETA 1 and THETA 2

Rectified

3. Error

Here so many plots are shown in window beacuse using the command hold

Rectified

4. Error

Small error in line 34 instead giving writevideo given the Writervideo

Rectified

5. Error

Saved video file was not played beacuse interpted the edit window while running the code

CODE :-

% program to compute the two arm robotic manupilator
clear all
close all
clc

l1 = 1;                                           % length of link 1 is to 1
l2 = 0.5;                                         % length of link 2 is to 0.5
theta1 = linspace(0,90,50);                       % link 1 angle theta 1 is 0 to 90
theta2 = linspace(0,90,50);                       % similarly theta for 2
ct = 1;                                          % counter is set to 1 initiatially

for i = 1:length(theta1)                          % FOR loop is 1 to its length of theta 1
    THETA1 = theta1(i);
    for j = 1:length(theta2)                      % nested FOR loop for theta 2
        THETA2= theta2(j);
    
        x0=0;                                     % coordinates x0 is 0
        y0=0;                                     % cordinates y0 is 0

        x1=l1*cosd(THETA1);                        % coordinate x1 is l1 times costheta1
        y1=l1*sind(THETA1);                        % similarly for y coordinate
 
        x2=x1+l2*cosd(THETA2);
        y2=y1+l2*sind(THETA2);
        
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)         % ploting
        title('forward kinematics')                                 % adding a title to plot
        axis([-0.1 2 0 2]);                                         % increasing the limits of plot axis
        M(ct)= getframe(gcf);                                       % getting every frame
        ct=ct+1;                                                    % adding previous frame to next frame
    end                                                             % ENDFOR                                     
end                                                                 % ENDFOR
movie(M)                                                            % creating all frames into a movie 
Videofile=VideoWriter('forward_kinematics.avi','motion JPEG AVI');  % saving it into a specific filename   
open(Videofile)                                                     % opening the file
writeVideo(Videofile,M)                                             % write it to video file 
close(Videofile)                                                    % closing the video file

VIDEO LINK :- https://drive.google.com/file/d/1uFUfMzm66W6uHGD_H4Bxszpmm7bc4Hyi/view?usp=sharing

https://drive.google.com/file/d/1uFUfMzm66W6uHGD_H4Bxszpmm7bc4Hyi/view?usp=sharing

CONCLUSIN :-

Hence the forward kinemaitcs of 2r robotic arm is generated by using the matlab.

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.