Challenge

Week 2- 2R Robotic Arm Challenge

Aim: Simulation of forward kinematics of a robotic arm using Matlab.

Objective: To write a program inorder to find the simulation of forward kinematics of robotic arm and make a video file of the motion of the robotic arm in the plot. Upload the video in the youtube and paste the link.

Theory:

A robotic arm is a mechanical where it contains mechanical linkages with one arm fixed on a fixed point and it will moves making an angle with the base line. From the linkage 1 it is connected to another linkage which moves accordingly. Here we consider a robotic arm which contains two movable linkages and each arm moves 90 degree with respect to the horizontal line. Applications of robotic arm are in various industrial purposes such as welding metal cutting etc.

Equations:

  • Equation for finding the end points of linkage 1 for an angle of (theta1),

x1= x0 + L1.cosd(theta1)

y1= y0 + L1.sind(theta1)

  • Equation for finding the end points of linkage 2 for an angle of (theta2),

x2= x1 +L2.cosd(theta2)

y2= y1 +L2.sind(theta2)

Matlab Code:

close all
clear all 
clc
l1=10; %length of linkage 1
l2=5;  %length of linkage 2

theta1=linspace(0,90,40);  % angle formed by moving linkage 1
theta2=linspace(0,90,40);  % angle formed by moving linkage 2
  
ct=1; 
% iterating each values for theta1 and theta2
for i=1:length(theta1)
    THETA1=theta1(i);
    for j=1:length(theta2)
        THETA2=theta2(j);
        % fixing the base points
        x0=0; 
        y0=0;
         % finding the end points of linkage 1
        x1=l1*cosd(THETA1);
        y1=l1*sind(THETA1);
        % finding the end points of linkage 2
        x2=x1+l2*cosd(THETA2);
        y2=y1+l2*sind(THETA2);
        % plotting all values of end points of linkage 1 and linkage 2
        plot([x0 x1],[y0 y1],[x1 x2],[y1 y2],'linewidth',3)
        % fixing the end points for the plot
        axis([-1 15 0 15]);
        % pause time in seconds while playing each frames
        pause(0.2)
        % Capturing the current plot
        M(ct)=getframe(gcf);
        % increamenting each frame after each frame is captured
        ct=ct+1;
    end
end

% making a movie from all the frames collected above
movie(M);
% creating a videofile in '.avi' format
videofile=VideoWriter('Forward_kinematics_of_robotic_arm.avi','Uncompressed AVI');
open(videofile);
%writing the above movie into a video file
writeVideo(videofile,M);
close(videofile);

Procedure:

  • First of all using clear all, close all and clc commands for clearing all datas in workspace, figures and plots and command window respectively.
  • Inputing the values for the length of linkage 1 and linkage 2.
  • Using the linspace command the range of angles traced by linkages are taken as input.
  • Fixing the base points as orgin (0,0).
  • For loops are used for iterating the values of angles and using that angles end points are calculated using the equations mentioned above in the theory part.
  • The end points of linkage 1 and linkage 2 is calculated at each angles formed by iterating.
  • A plot of these end are made using plot command.
  • After plotting the graph each frames are captured.
  • Then a movie is made from all frames collected.
  • After that a video file is created in '.avi' format for saving the video.
  • At last we will write the movie into the video file created.

Conclusion:

Simulation of the forward kinematics of robotic arm is made using the Matlab programming and the values are plotted in the graph. After plotting each frames are captured and created a video file. The video is uploaded in the youtube and the link is pasted below,

Youtube link:

https://youtube.com/shorts/tG1fRWkoI4A?feature=share

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.