Challenge

Week 2- 2R Robotic Arm Challenge

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.

Matlab Code:

close all

clear all

clc

l1=10; %length of linkage 1

l2=5; %length of linkage 2

% angle formed by moving linkage 1

theta1=linspace(0,90,40);

% angle formed by moving linkage 2

theta2=linspace(0,90,40);

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:

  • Firstly using clear all, close all and clc commands for clearing the command window,workspace and close any opened plots.
  • Inputing the values for the length of linkage 1 and linkage 2.
  • The linspace command is used to define the range of the arm movement.
  • Fixing the base points as orgin (0,0).
  • For loops are used to iterate the values of theta and using that angles and end points are calculated using the 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)

  • The end points of linkage 1 and linkage 2 is calculated at each angles formed by iterating.
  • The plot command is used to plot the movement of robotic arm.
  • After plotting the graph each frames are captured.
  • From the frames collected a movie is created.
  • 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.

Youtube link of the video file

https://youtu.be/5cJ90VZ15_g

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.